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

   ### Describe the bug
   
   Simple SELECT DISTINCT ON query triggers failure in datafusion `Internal 
error: Failed due to a difference in schemas`
   
   ### To Reproduce
   
   Open datafusion-cli and run the commands to get the error:
   ```
   > create view test as values (1,1),(1,2),(2,0),(3,1),(3,2);
   0 row(s) fetched. 
   Elapsed 0.001 seconds.
   
   > select * from test;
   +---------+---------+
   | column1 | column2 |
   +---------+---------+
   | 1       | 1       |
   | 1       | 2       |
   | 2       | 0       |
   | 3       | 1       |
   | 3       | 2       |
   +---------+---------+
   5 row(s) fetched. 
   Elapsed 0.001 seconds.
   
   > select distinct on (column1) * from test;
   Optimizer rule 'replace_distinct_aggregate' failed
   caused by
   replace_distinct_aggregate
   caused by
   Internal error: Failed due to a difference in schemas, original schema: 
DFSchema { inner: Schema { fields: [Field { name: "column1", data_type: Int64, 
nullable: true, dict_id: 0, dict_is_ordered: false, metadata: {} }, Field { 
name: "column2", data_type: Int64, nullable: true, dict_id: 0, dict_is_ordered: 
false, metadata: {} }], metadata: {} }, field_qualifiers: [Some(Bare { table: 
"test" }), Some(Bare { table: "test" })], functional_dependencies: 
FunctionalDependencies { deps: [] } }, new schema: DFSchema { inner: Schema { 
fields: [Field { name: "column1", data_type: Null, nullable: true, dict_id: 0, 
dict_is_ordered: false, metadata: {} }], metadata: {} }, field_qualifiers: 
[Some(Bare { table: "test" })], functional_dependencies: FunctionalDependencies 
{ deps: [] } }.
   This was likely caused by a bug in DataFusion's code and we would welcome 
that you file an bug report in our issue tracker
   ```
   
   
   ### Expected behavior
   
   proper result should be returned
   
   ### Additional context
   
   Seen in 
   ```
   $ datafusion-cli -V
   datafusion-cli 42.0.0
   ```


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