-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Open
Labels
enhancementNew feature or requestNew feature or request
Description
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
datafusion/datafusion/expr/src/expr.rs
Line 2951 in 0ff8984
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
ConfigOptionsparam 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), output0(since parsing0results inInt64(0)). When formattingInt32(0), keepInt32(0).
Additional context
May be quite easy to update after we finish #15178
Weijun-H and xudong963
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request