HaoYang670 commented on issue #3499:
URL:
https://github.com/apache/arrow-datafusion/issues/3499#issuecomment-1306672468
By the way, there is no bug when you select from a view. For example:
```
❯ create view v as select 1 as a;
0 rows in set. Query took 0.003 seconds.
❯ explain select cast (a as float) from v;
+---------------+----------------------------------------------------+
| plan_type | plan |
+---------------+----------------------------------------------------+
| logical_plan | Projection: CAST(v.a AS Float32) |
| | Projection: a, alias=v |
| | Projection: Int64(1) AS a |
| | EmptyRelation |
| physical_plan | ProjectionExec: expr=[CAST(a@0 AS Float32) as v.a] |
| | ProjectionExec: expr=[a@0 as a] |
| | ProjectionExec: expr=[1 as a] |
| | EmptyExec: produce_one_row=true |
| | |
+---------------+----------------------------------------------------+
2 rows in set. Query took 0.007 seconds.
❯ explain select cast (a as float) from (select 1 as a);
+---------------+-------------------------------------+
| plan_type | plan |
+---------------+-------------------------------------+
| logical_plan | Projection: a |
| | Projection: Int64(1) AS a |
| | EmptyRelation |
| physical_plan | ProjectionExec: expr=[a@0 as a] |
| | ProjectionExec: expr=[1 as a] |
| | EmptyExec: produce_one_row=true |
| | |
+---------------+-------------------------------------+
2 rows in set. Query took 0.003 seconds.
```
This is because that we ignore the qualifier when finding the field
```rust
match e.display_name() {
Ok(name) => match
input_schema.field_with_unqualified_name(&name) {
Ok(field) => Expr::Column(field.qualified_column()),
// expression not provided as input, do not convert to a
column reference
Err(_) => e,
},
Err(_) => e,
```
--
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]