alamb commented on code in PR #15077:
URL: https://github.com/apache/datafusion/pull/15077#discussion_r1986065153


##########
datafusion/sqllogictest/test_files/explain_tree.slt:
##########
@@ -519,6 +519,52 @@ physical_plan
 17)│       format: arrow       │
 18)└───────────────────────────┘
 
+# Query for sort.
+query TT
+explain SELECT * FROM table1 ORDER BY string_col;
+----
+logical_plan
+01)Sort: table1.string_col ASC NULLS LAST
+02)--TableScan: table1 projection=[int_col, string_col, bigint_col, date_col]
+physical_plan
+01)┌───────────────────────────┐
+02)│          SortExec         │
+03)│    --------------------   │
+04)│         sort keys:        │
+05)│  [string_col@1 ASC NULLS  │
+06)│            LAST]          │
+07)└─────────────┬─────────────┘
+08)┌─────────────┴─────────────┐
+09)│       DataSourceExec      │
+10)│    --------------------   │
+11)│          files: 1         │
+12)│        format: csv        │
+13)└───────────────────────────┘
+
+# Query for sort with limit.
+query TT
+explain SELECT * FROM table1 ORDER BY string_col LIMIT 1;
+----
+logical_plan
+01)Sort: table1.string_col ASC NULLS LAST, fetch=1
+02)--TableScan: table1 projection=[int_col, string_col, bigint_col, date_col]
+physical_plan
+01)┌───────────────────────────┐
+02)│          SortExec         │
+03)│    --------------------   │
+04)│          limit: 1         │
+05)│                           │
+06)│         sort keys:        │
+07)│  [string_col@1 ASC NULLS  │
+08)│            LAST]          │

Review Comment:
   I wonder if there is some way to avoid the redundancy of `sort keys` 🤔 
   
   For example I think this would be look better (not sure how to do it)
   
   ```
   01)┌───────────────────────────┐
   02)│          SortExec         │
   03)│    --------------------   │
   07)│   string_col@1 ASC NULLS  │
   08)│            LAST           │
   05)│                           │
   04)│          limit: 1         │
   09)└─────────────┬─────────────┘



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to