houqp opened a new issue #1372:
URL: https://github.com/apache/arrow-datafusion/issues/1372
**Describe the bug**
`SELECT a FROM table ORDER BY b` will throw an error in datafusion because b
is not a projected column.
The error can be reproduced with the following dataframe code as well:
```rust
let schema = Schema::new(vec![
Field::new("a", DataType::Int32, false),
Field::new("b", DataType::Int32, false),
]);
let batch = RecordBatch::try_new(
Arc::new(schema.clone()),
vec![
Arc::new(Int32Array::from(vec![1, 10, 10, 100])),
Arc::new(Int32Array::from(vec![2, 12, 12, 120])),
],
)
.unwrap();
let mut ctx = ExecutionContext::new();
let provider = MemTable::try_new(Arc::new(schema),
vec![vec![batch]]).unwrap();
ctx.register_table("t", Arc::new(provider)).unwrap();
let df = ctx.table("t").unwrap()
.select(vec![col("a")])
.unwrap()
.sort(vec![Expr::Sort {
expr: Box::new(col("b")),
asc: false,
nulls_first: true,
}])
.unwrap();
let results = df.collect().await.unwrap();
```
**To Reproduce**
Try to sort on unprojected column.
**Expected behavior**
`SELECT a FROM table ORDER BY b` should work without an error
**Additional context**
https://github.com/roapi/roapi/issues/110
--
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]