-
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
Fixed JSON_OBJECT issue #3891
base: main
Are you sure you want to change the base?
Fixed JSON_OBJECT issue #3891
Conversation
You need to create a jira case |
Requested account. Account will be under ***@***.*** ***@***.***>”.
… On Jul 29, 2024, at 12:49 PM, Cancai Cai ***@***.***> wrote:
You need to create a jira case
—
Reply to this email directly, view it on GitHub <#3891 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/A6XQV2343WGPJXHOXGMQ5M3ZOZXCDAVCNFSM6AAAAABLUTBLHCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDENJWGQZDGOJTG4>.
You are receiving this because you authored the thread.
|
CALCITE-6505 has been created. |
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.
you need to write at least one test to exercise this code.
you also need to use the same title for the commit message and PR as you used in the JIRA case.
String keyName = call.operand(i).toSqlString(this).toString(); | ||
String value = call.operand(i + 1).toSqlString(this).toString(); | ||
keyName = keyName.substring(1, keyName.length() - 1); | ||
String jsonFragment = String.format("'\"%s\": ' || COALESCE(CASE WHEN %s::varchar ~'^-?\\\\d*(\\\\.\\\\d+)?$' THEN %s::varchar ELSE quote_ident(%s) END, 'null')", keyName, value, value, value); |
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 deserves an explanation as a comment
import org.apache.calcite.sql.SqlNode; | ||
import org.apache.calcite.sql.SqlUserDefinedTypeNameSpec; | ||
import org.apache.calcite.sql.SqlWriter; | ||
import org.apache.calcite.sql.*; |
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.
Calcite does not like * imports.
Redshift has no JSON_OBJECT function, this rewrites JSON_OBJECT using ANSI SQL.