[
https://issues.apache.org/jira/browse/CALCITE-5265?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17609834#comment-17609834
]
Mou Wu commented on CALCITE-5265:
---------------------------------
[~libenchao] Thanks for your response. I think INSERT is different from
Merge/Delete/Update, because there is no SqlSelect in Merge/Delete/Update, for
example: for Delete, "delete from emps where empno in (select 12)", the
parentheses for "select 12" is necessary. May you write a unit test for Select
in Merge/Delete/Update if i don't quite understand what's you mean?
# I update the Jira title to "Unparsing should not add parentheses for SELECT
in INSERT".
# I haven't add these tests to covering Merge/Delete/Update because those
reasons above.
# I add a issue: https://issues.apache.org/jira/browse/CALCITE-5299
> Unparsing should not add parentheses for SELECT in INSERT
> ---------------------------------------------------------
>
> Key: CALCITE-5265
> URL: https://issues.apache.org/jira/browse/CALCITE-5265
> Project: Calcite
> Issue Type: Bug
> Reporter: Mou Wu
> Assignee: Mou Wu
> Priority: Trivial
> Labels: pull-request-available
> Time Spent: 10m
> Remaining Estimate: 0h
>
> Add a case in RelToSqlConverterTest:
> {code:java}
> // code placeholder
> @Test void testInsertValueWithDynamicParams() {
> final String sql = "insert into \"DEPT\" values (?,?,?)";
> final String expected = ""
> + "INSERT INTO \"SCOTT\".\"DEPT\" (\"DEPTNO\", \"DNAME\", \"LOC\")\n"
> + "SELECT ? AS \"DEPTNO\", ? AS \"DNAME\", ? AS \"LOC\"\n"
> + "FROM (VALUES (0)) AS \"t\" (\"ZERO\")";
> sql(sql)
> .schema(CalciteAssert.SchemaSpec.JDBC_SCOTT)
> .ok(expected);
> }{code}
> will fail, because actual sql is with parentheses, maybe it's all right with
> parentheses, but the behavior is different from Union operator, you can see
> testInsertValuesWithDynamicParams in RelToSqlConverterTest class.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)