[
https://issues.apache.org/jira/browse/CALCITE-5265?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17609110#comment-17609110
]
Benchao Li commented on CALCITE-5265:
-------------------------------------
The problem exists for {{SqlSelect}} in
{{Merge}}/{{Delete}}/{{Insert}}/{{Update}}, according to the
[PR|https://github.com/apache/calcite/pull/2910]:
1. Could you update the JIRA title to "Unparsing should not add parentheses for
SELECT in MERGE/DELETE/INSERT/UPDATE"
2. Could you add more tests to cover the above cases I mentioned
3. I found that although we have added {{FrameTypeEnum.WITH}} in
[{{SqlPrettyWriter}}|https://github.com/apache/calcite/blob/a505b25eacc473c6ec0ef8abd40c1ccae86297b6/core/src/main/java/org/apache/calcite/sql/pretty/SqlPrettyWriter.java#L400],
but we are actually [not in the {{WITH}} frame while unparsing
{{SqlSelect}}|https://github.com/apache/calcite/blob/a505b25eacc473c6ec0ef8abd40c1ccae86297b6/core/src/main/java/org/apache/calcite/sql/SqlWith.java#L105-L108],
hence unparsing {{WITH}} statement also could be improved, if you agree with
this, could you open another follow up JIRA to fix this?
> Select operator' parentheses should be same with Union operator
> ---------------------------------------------------------------
>
> 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)