-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
[CALCITE-6437]For druid sql JSON_OBJECT() function results in RUNTIME_FAILURE when querying INFORMATION_SCHEMA.COLUMNS #3821
base: main
Are you sure you want to change the base?
Conversation
@AlbericByte Please create a new issue in JIRA. |
add the jira in the description : CALCITE-6437 |
In order to make it easier to keep track of the correspondence of issues in JIRA and github the issue title should match exactly the JIRA title. |
Please add a unit test that fails before the fix. |
Got it, thanks for the tips |
|
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.
Besides the comment I left, this looks fine
core/src/test/resources/sql/agg.iq
Outdated
@@ -3247,7 +3247,7 @@ select json_object('deptno': deptno, 'employees': json_arrayagg(json_object('ena | |||
+-------------------------------------------------------------------------------------------+ | |||
(6 rows) | |||
|
|||
!ok | |||
!ok2 |
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.
this change looks strange
@@ -3777,5 +3777,22 @@ select distinct sum(deptno + '1') as deptsum from dept order by 1; | |||
+---------+ | |||
(1 row) | |||
|
|||
!ok | |||
|
|||
# Test cases for [CALCITE-6437] For druid sql JSON_OBJECT() function results in RUNTIME_FAILURE when querying |
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.
This SQL can run success without this PR. And according to this change, I doubt this is a good way to fix this issue in Calcite.
the issue arises from the fact that Druid tries to implement Comparing against So I think another way to solve this is to introduce |
|
Quality Gate passedIssues Measures |
@NobiGo @kgyrtkirk @mihaibudiu in Druid the return type of json_object function is ExpressionType.NESTED_DATA, but in Calcite, the return type of json_object is VARCHAR(2000). From current calcite logic, if can not find the sqlfunction in RexImpTable, calcite will throw exception. And actually in druid, we have implement json_object in JsonObjectExprMacro. is there any api to register new SqlJsonObjectFunction with NESTED_DATA in druid? so i can register a new SqlJsonObjectFunction with NESTED_DATA output. i tried to reused SqlStdOperatorTable.JSON_OBJECT in druid, and also add cast or json_query to wrap the json_object, but it will fail because the SqlStdOperatorTable.JSON_OBJECT return varchar, or cast donot support NESTED_DATA. seems i can not find better solution outside calcite, could you please give me a guidance. Thanks |
What is the status of this PR? Is it ready or more work is needed? |
There are many functions in Calcite which are "overloaded", which behave differently depending on the SQL dialect. You can define a new function, with the same name, but a different implementation for Druid. |
This pull request has been marked as stale due to 30 days of inactivity. It will be closed in 90 days if no further activity occurs. If you think that’s incorrect or this pull request requires a review, please simply write any comment. If closed, you can revive the PR at any time and @mention a reviewer or discuss it on the [email protected] list. Thank you for your contributions. |
Fix the druid json_object issue.
Description
jira: CALCITE-6437
druid issue: apache/druid#16356
We can overwrite to be SqlJsonObjectFunction
add one more construction of SqlJsonObjectFunction as following
and update JsonObjectOperatorConversion in druid as following: