-
Notifications
You must be signed in to change notification settings - Fork 560
Add basic PostgreSql Array literal support #5997
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Add basic PostgreSql Array literal support #5997
Conversation
Basic support of Array Literal The array_value_expression must be positioned, in the extension expression rule, after the double_colon expr to allow parser rule to use it inside array literals.
Basic Integration tests for array literals Note: In Postgresql JDBC arrays of date types cannot yet be used with LocalDate. This is an issue with the Postgresql JDBC driver and arrays Update PostgreSqlTest.kt
| IntermediateType(REAL).nullableIf(temporalExprType.javaType.isNullable) | ||
| } | ||
| plsqlTriggerVarExpression != null -> IntermediateType(TEXT) | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gets the list of array elements as SqlExpr - maybe all same type or different types.
The last type in typeOrdering (numeric) will be used where mixed numeric arrays are resolved. SELECT ARRAY[1.0, 2, 3::LONG] -> numeric[].
IF any elements are NULL the result is nullable type.
| } | ||
|
|
||
| extension_expr ::= json_object_agg_stmt | json_agg_stmt | plsql_trigger_var_expression | is_json_expression | overlaps_operator_expression | range_operator_expression | extract_temporal_expression | double_colon_cast_operator_expression | contains_operator_expression | at_time_zone_operator_expression | regex_match_operator_expression | match_operator_expression | json_function_stmt | array_agg_stmt| string_agg_stmt | json_expression | boolean_not_expression | window_function_expr { | ||
| extension_expr ::= json_object_agg_stmt | json_agg_stmt | plsql_trigger_var_expression | is_json_expression | overlaps_operator_expression | range_operator_expression | extract_temporal_expression | double_colon_cast_operator_expression | array_value_expression | contains_operator_expression | at_time_zone_operator_expression | regex_match_operator_expression | match_operator_expression | json_function_stmt | array_agg_stmt| string_agg_stmt | json_expression | boolean_not_expression | window_function_expr { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
array_value_expression needs to be ordered after double_colon_cast_operator_expression as the rule has higher precedence
| double_colon_cast_operator ::= '::' type_name | ||
|
|
||
| double_colon_cast_operator_expression ::= ( {bind_expr} | {literal_expr} | {cast_expr} | {function_expr} | {column_expr} ) double_colon_cast_operator [ double_colon_cast_operator ] * { | ||
| double_colon_cast_operator_expression ::= ( array_value_expression | {bind_expr} | {literal_expr} | {cast_expr} | {function_expr} | {column_expr} ) double_colon_cast_operator [ double_colon_cast_operator ] * { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See extension_expr ordering
🚧 🕳️ 👷 Basic array literal support using
ARRAY.🚨 Note:
SELECT ARRAY[DATE '2020-01-01', DATE '2020-01-02']returnsjava.sql.Date[] as LocalDates are not supported by PostgreSQL arrays and currently fails - see related issue #5591TODO:
More local testing
CHANGELOG.md's "Unreleased" section has been updated, if applicable.