Is your feature request related to a problem or challenge?
When parsing scalar expressions, DataFusion makes queries quite complicated:
> select 3, array_length([1, 2, 4, 5, 10000, 2.4]);;
+----------+-----------------------------------------------------------------------------------------+
| Int64(3) | array_length(make_array(Int64(1),Int64(2),Int64(4),Int64(5),Int64(10000),Float64(2.4))) |
+----------+-----------------------------------------------------------------------------------------+
| 3 | 6 |
+----------+-----------------------------------------------------------------------------------------+
Such detailed comparison isn't needed in most cases and adds unnecessary cognitive complexity for developers. Moreover, it also breaks the original query - if you put select Int64(3), you'll get Error during planning: Invalid function 'int64'
Describe the solution you'd like
In most cases, the simplest version will be enough. On the example above it is:
> select 3, array_length([1, 2, 4, 5, 10000, 2.4]);
+---+---------------------------------------------+
| 3 | array_length(make_array(1,2,4,5,10000,2.4)) |
+---+---------------------------------------------+
| 3 | 6 |
+---+---------------------------------------------+
IMO there are three ways how to fix this problem:
- Just remove
:? here for all cases
|
Expr::Literal(v) => write!(f, "{v:?}"), |
This will make queries simpler everywhere. The downside is that we lose some information, e.g., type info in the shell (which one can argue isn't needed and can be checked separately)
- Disable verbose as a
ConfigOptions param and make it changeable (via datafusion-cli or sdk).
- Use short names only if parsing back preserves the correct type. For example, when formatting
Int64(0), output 0 (since parsing 0 results in Int64(0)). When formatting Int32(0), keep Int32(0).
Additional context
May be quite easy to update after we finish #15178
Is your feature request related to a problem or challenge?
When parsing scalar expressions, DataFusion makes queries quite complicated:
Such detailed comparison isn't needed in most cases and adds unnecessary cognitive complexity for developers. Moreover, it also breaks the original query - if you put
select Int64(3), you'll getError during planning: Invalid function 'int64'Describe the solution you'd like
In most cases, the simplest version will be enough. On the example above it is:
IMO there are three ways how to fix this problem:
:?here for all casesdatafusion/datafusion/expr/src/expr.rs
Line 2951 in 0ff8984
This will make queries simpler everywhere. The downside is that we lose some information, e.g., type info in the shell (which one can argue isn't needed and can be checked separately)
ConfigOptionsparam and make it changeable (via datafusion-cli or sdk).Int64(0), output0(since parsing0results inInt64(0)). When formattingInt32(0), keepInt32(0).Additional context
May be quite easy to update after we finish #15178