You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by "xiedeyantu (via GitHub)" <gi...@apache.org> on 2025/12/16 14:46:03 UTC
[PR] [CALCITE-7335] RelToSqlConverter generate sql containing Scala subqueries includes redundant parentheses [calcite]
xiedeyantu opened a new pull request, #4690:
URL: https://github.com/apache/calcite/pull/4690
See [CALCITE-7335](https://issues.apache.org/jira/browse/CALCITE-7335)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-7335] RelToSqlConverter generate sql containing Scala subqueries includes redundant parentheses [calcite]
Posted by "xiedeyantu (via GitHub)" <gi...@apache.org>.
xiedeyantu commented on PR #4690:
URL: https://github.com/apache/calcite/pull/4690#issuecomment-3662818538
@NobiGo Since you asked the question, please take a look if you have time. Thanks.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-7335] RelToSqlConverter generate sql containing Scala subqueries includes redundant parentheses [calcite]
Posted by "mihaibudiu (via GitHub)" <gi...@apache.org>.
mihaibudiu commented on code in PR #4690:
URL: https://github.com/apache/calcite/pull/4690#discussion_r2625034178
##########
core/src/main/java/org/apache/calcite/sql/fun/SqlStdOperatorTable.java:
##########
@@ -2401,9 +2401,15 @@ public class SqlStdOperatorTable extends ReflectiveSqlOperatorTable {
SqlCall call,
int leftPrec,
int rightPrec) {
- final SqlWriter.Frame frame = writer.startList("(", ")");
- call.operand(0).unparse(writer, 0, 0);
- writer.endList(frame);
+ final SqlNode operand = call.operand(0);
+ if (operand.getKind() == SqlKind.SELECT) {
+ operand.unparse(writer, leftPrec, rightPrec);
+ } else {
+ final SqlWriter.Frame frame =
Review Comment:
thanks
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-7335] RelToSqlConverter generate sql containing Scala subqueries includes redundant parentheses [calcite]
Posted by "xiedeyantu (via GitHub)" <gi...@apache.org>.
xiedeyantu commented on code in PR #4690:
URL: https://github.com/apache/calcite/pull/4690#discussion_r2625031880
##########
core/src/main/java/org/apache/calcite/sql/fun/SqlStdOperatorTable.java:
##########
@@ -2401,9 +2401,15 @@ public class SqlStdOperatorTable extends ReflectiveSqlOperatorTable {
SqlCall call,
int leftPrec,
int rightPrec) {
- final SqlWriter.Frame frame = writer.startList("(", ")");
- call.operand(0).unparse(writer, 0, 0);
- writer.endList(frame);
+ final SqlNode operand = call.operand(0);
+ if (operand.getKind() == SqlKind.SELECT) {
+ operand.unparse(writer, leftPrec, rightPrec);
+ } else {
+ final SqlWriter.Frame frame =
Review Comment:
Yes, this test can run into else([link](https://github.com/apache/calcite/blob/f19e854c39e5a43aea2323e455229bd8dfc6dcdb/core/src/test/java/org/apache/calcite/rel/rel2sql/RelToSqlConverterTest.java#L6372)).
```
WHEN 0 THEN NULL WHEN 1 THEN MIN(`product_class_id`) ELSE (SELECT NULL
UNION ALL
SELECT NULL) END AS `$f0`
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-7335] RelToSqlConverter generate sql containing Scala subqueries includes redundant parentheses [calcite]
Posted by "mihaibudiu (via GitHub)" <gi...@apache.org>.
mihaibudiu commented on code in PR #4690:
URL: https://github.com/apache/calcite/pull/4690#discussion_r2624017327
##########
core/src/main/java/org/apache/calcite/sql/fun/SqlStdOperatorTable.java:
##########
@@ -2401,9 +2401,15 @@ public class SqlStdOperatorTable extends ReflectiveSqlOperatorTable {
SqlCall call,
int leftPrec,
int rightPrec) {
- final SqlWriter.Frame frame = writer.startList("(", ")");
- call.operand(0).unparse(writer, 0, 0);
- writer.endList(frame);
+ final SqlNode operand = call.operand(0);
+ if (operand.getKind() == SqlKind.SELECT) {
+ operand.unparse(writer, leftPrec, rightPrec);
+ } else {
+ final SqlWriter.Frame frame =
Review Comment:
does this happen?
do you know if there is a test for this case?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-7335] RelToSqlConverter generate sql containing Scala subqueries includes redundant parentheses [calcite]
Posted by "xiedeyantu (via GitHub)" <gi...@apache.org>.
xiedeyantu commented on code in PR #4690:
URL: https://github.com/apache/calcite/pull/4690#discussion_r2625334844
##########
core/src/test/java/org/apache/calcite/rel/rel2sql/RelToSqlConverterTest.java:
##########
@@ -11095,6 +11095,23 @@ private void checkLiteral2(String expression, String expected) {
.ok(expected);
}
+ /** Test case of
+ * <a href="https://issues.apache.org/jira/browse/CALCITE-7335">[CALCITE-7335]
+ * RelToSqlConverter generate sql containing Scala subqueries
+ * includes redundant parentheses</a>. */
+ @Test void testScalarSubqueryInSelectList() {
+ final String sql = "SELECT \n"
Review Comment:
Good catch! Since it was a minor change, I just force-pushed it. Thank you for your review.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-7335] RelToSqlConverter generate sql containing Scala subqueries includes redundant parentheses [calcite]
Posted by "NobiGo (via GitHub)" <gi...@apache.org>.
NobiGo commented on code in PR #4690:
URL: https://github.com/apache/calcite/pull/4690#discussion_r2625321181
##########
core/src/test/java/org/apache/calcite/rel/rel2sql/RelToSqlConverterTest.java:
##########
@@ -11095,6 +11095,23 @@ private void checkLiteral2(String expression, String expected) {
.ok(expected);
}
+ /** Test case of
+ * <a href="https://issues.apache.org/jira/browse/CALCITE-7335">[CALCITE-7335]
+ * RelToSqlConverter generate sql containing Scala subqueries
+ * includes redundant parentheses</a>. */
+ @Test void testScalarSubqueryInSelectList() {
+ final String sql = "SELECT \n"
Review Comment:
LGTM, just a minor issue that needs improvement—could you format this SQL? If it ends with a newline, then no space is needed.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-7335] RelToSqlConverter generate sql containing Scala subqueries includes redundant parentheses [calcite]
Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #4690:
URL: https://github.com/apache/calcite/pull/4690#issuecomment-3663351700
## [](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=4690) **Quality Gate passed**
Issues
 [0 New issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=4690&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)
 [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=4690&issueStatuses=ACCEPTED)
Measures
 [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_calcite&pullRequest=4690&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)
 [100.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=4690&metric=new_coverage&view=list)
 [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=4690&metric=new_duplicated_lines_density&view=list)
[See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=4690)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-7335] RelToSqlConverter generate sql containing Scala subqueries includes redundant parentheses [calcite]
Posted by "xiedeyantu (via GitHub)" <gi...@apache.org>.
xiedeyantu merged PR #4690:
URL: https://github.com/apache/calcite/pull/4690
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-7335] RelToSqlConverter generate sql containing Scala subqueries includes redundant parentheses [calcite]
Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #4690:
URL: https://github.com/apache/calcite/pull/4690#issuecomment-3661047896
## [](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=4690) **Quality Gate passed**
Issues
 [0 New issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=4690&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)
 [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=4690&issueStatuses=ACCEPTED)
Measures
 [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_calcite&pullRequest=4690&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)
 [100.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=4690&metric=new_coverage&view=list)
 [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=4690&metric=new_duplicated_lines_density&view=list)
[See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=4690)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org