jayzhan211 opened a new issue, #26645:
URL: https://github.com/apache/datafusion/issues/26645

   ### Describe the bug
   
   When `SanityCheckPlan` rejects a plan because an operator cannot run on an 
unbounded input, the error message
   prints the operator with `{:?}`. That is the operator's full `Debug` output: 
its plan properties, equivalence
   properties, metrics and, for a TopK sort, the dynamic filter state. For a 
single `SortExec` the message is
   several thousand characters long, and the part a user needs (which operator, 
on which columns) is hard to find.
   
   The other two errors in the same file already print the plan as text with 
`get_plan_string`
   (`does not satisfy order requirements`, `does not satisfy distribution 
requirements`).
   
   ### To Reproduce
   
   In `datafusion-cli`, from `datafusion/core/tests/data`:
   
   ```sql
   CREATE UNBOUNDED EXTERNAL TABLE t (a0 INT, a INT, b INT, c INT, d INT)
   STORED AS CSV LOCATION 'window_2.csv' OPTIONS ('format.has_header' 'true');
   
   SELECT * FROM t ORDER BY d LIMIT 1;
   ```
   
   Output (shortened):
   
   ```
   Error: SanityCheckPlan
   caused by
   Error during planning: Cannot execute pipeline breaking queries, operator: 
SortExec { input: LazyMemTableExec { .. }, expr: LexOrdering { exprs: 
[PhysicalSortExpr { expr: Column { name: "d", index: 4 }, options: SortOptions 
{ descending: false, nulls_first: false } }], set: {Column { name: "d", index: 
4 }} }, metrics_set: ExecutionPlanMetricsSet { ... }, preserve_partitioning: 
false, fetch: Some(1), common_sort_prefix: [], cache: PlanProperties { 
eq_properties: EquivalenceProperties { ... }, ... }, filter: Some(RwLock { 
data: TopKDynamicFilters { ... } }) }
   ```
   
   ### Expected behavior
   
   The message names the operator the way `EXPLAIN` shows it, for example:
   
   ```
   Error during planning: Cannot execute pipeline breaking queries, operator: 
SortExec: TopK(fetch=1), expr=[d@4 ASC NULLS LAST], 
preserve_partitioning=[false]
   ```
   
   ### Additional context
   
   The message is built in 
`datafusion/physical-optimizer/src/sanity_checker.rs`, in 
`check_finiteness_requirements`:
   
   ```rust
   plan_err!(
       "Cannot execute pipeline breaking queries, operator: {:?}",
       input
   )
   ```
   
   A one-line display of the operator (`displayable(input).one_line()`) would 
match `EXPLAIN`.
   No existing test checks this message's text, so a fix should add one, for 
example a sqllogictest
   `statement error` case on an unbounded table.
   
   ### Willingness to contribute
   
   I cannot contribute a fix for this bug at this time. (Leaving it for a new 
contributor.)
   


-- 
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