You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by "dssysolyatin (via GitHub)" <gi...@apache.org> on 2025/10/08 20:14:02 UTC

[PR] [CALCITE-7220] RelToSqlConverter throws exception for UPDATE with self-referencing column in SET [calcite]

dssysolyatin opened a new pull request, #4572:
URL: https://github.com/apache/calcite/pull/4572

   (no comment)


-- 
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-7220] RelToSqlConverter throws exception for UPDATE with self-referencing column in SET [calcite]

Posted by "dssysolyatin (via GitHub)" <gi...@apache.org>.
dssysolyatin merged PR #4572:
URL: https://github.com/apache/calcite/pull/4572


-- 
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-7220] RelToSqlConverter throws exception for UPDATE with self-referencing column in SET [calcite]

Posted by "dssysolyatin (via GitHub)" <gi...@apache.org>.
dssysolyatin commented on code in PR #4572:
URL: https://github.com/apache/calcite/pull/4572#discussion_r2415025967


##########
core/src/main/java/org/apache/calcite/rel/rel2sql/RelToSqlConverter.java:
##########
@@ -1141,16 +1138,21 @@ public Result visit(TableModify modify) {
       return result(sqlInsert, ImmutableList.of(), modify, null);
     }
     case UPDATE: {
+      final List<String> updateColumnList =
+          requireNonNull(modify.getUpdateColumnList(),
+              () -> "modify.getUpdateColumnList() is null for " + modify);
       final Result input = visitInput(modify, 0);
+      final SqlSelect sourceSelect = input.asSelect();
+      final SqlNodeList expressionList = sourceSelect.getSelectList()

Review Comment:
   Although, It works, but it depends on the TableModify.input being built in a specific way. (Also `MERGE` work in the same way).
   
   A better approach might be to pass into `exprList` aliasContext which looks like
   ```
   aliasContext(ImmutableMap("p", modify.getRowType().get), false)
   ```
   and rely on ModifyTable.getExpressionList() instead



-- 
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-7220] RelToSqlConverter throws exception for UPDATE with self-referencing column in SET [calcite]

Posted by "dssysolyatin (via GitHub)" <gi...@apache.org>.
dssysolyatin commented on code in PR #4572:
URL: https://github.com/apache/calcite/pull/4572#discussion_r2416247477


##########
core/src/main/java/org/apache/calcite/rel/rel2sql/RelToSqlConverter.java:
##########
@@ -1141,16 +1138,21 @@ public Result visit(TableModify modify) {
       return result(sqlInsert, ImmutableList.of(), modify, null);
     }
     case UPDATE: {
+      final List<String> updateColumnList =
+          requireNonNull(modify.getUpdateColumnList(),
+              () -> "modify.getUpdateColumnList() is null for " + modify);
       final Result input = visitInput(modify, 0);
+      final SqlSelect sourceSelect = input.asSelect();

Review Comment:
   Let's assume we have this input expression:
   ```
   UPDATE `foodmart`.`product` SET `product_name` = `product_name` || 'calcite' WHERE `product_id` > 10
   ```
   
   calcite parser will parse it as:
   ```
   SqlUpdate(
       targetColumnList = [product_name], 
       sourceExpressionList = [`product_name` || 'calcite'], 
       condition = `product_id` > 10,
       sourceSelect = null <-- sourceSelect is null
   )
   ```
   
   Then, `ValidatorImpl.createSourceSelectForUpdate` changes it into:
   ```
   SqlUpdate(
       targetColumnList = [product_name], 
       sourceExpressionList = [`product_name` || 'calcite'], 
       condition = `product_id` > 10,
       sourceSelect = "SELECT *, `product_name` || 'calcite' AS `EXPR$0` FROM `foodmart`.`product` WHERE `product_id` > 10"
   )
   ```
   
   Next, `SqlToRelConverter` converts it into this logical plan:
   ```
   LogicalTableModify(
     table=[[foodmart, product]], operation=[UPDATE], 
     updateColumnList=[[product_name]], 
     sourceExpressionList=[[CAST(||($3, 'calcite')):VARCHAR(60) NOT NULL]], 
     flattened=[true]
   )
     LogicalProject(product_class_id=[$0], product_id=[$1], <all 14 fields>,  EXPR$0=[||($3, 'calcite')])
       LogicalFilter(condition=[>($1, 10)])
         LogicalTableScan(table=[[foodmart, product]])
   ```
   
   `LogicalTableModify.sourceExpressionList` is built using the blackboard from LogicalProject, but it doesn’t use expressions directly from `LogicalProject`. (This is one more reason my previous fix was incorrect. It lost type coercion in this case).
   
   Now, answer on your question: "What is this SqlSelect node"
   
   `RelToSqlConverter` transforms `TableModify.input` into:
   ```
   SELECT `product_class_id`, `product_id`, `brand_name`, `product_name`, `SKU`, `SRP`, `gross_weight`, `net_weight`, `recyclable_package`, `low_fat`, `units_per_case`, `cases_per_pallet`, `shelf_width`, `shelf_height`, `shelf_depth`, `product_name` || 'calcite' AS `EXPR$0`
   FROM `foodmart`.`product`
   WHERE `product_id` > 10
   ```
   
   Calcite takes the WHERE clause for the UPDATE from this SELECT. (This is not completely correct. if we later support `UPDATE FROM` syntax, it will be wrong. Instead, we should build the `WHERE` clause based on the `SELECT` context, rather than reusing parts of the `SELECT`)
   
   We also need to convert `TableModify.sourceExpressionList` into a `SqlNode` using the context of this SELECT, similar to how we use the LogicalProject blackboard when converting a SqlNode to a RelNode. My current fix uses this approach



-- 
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-7220] RelToSqlConverter throws exception for UPDATE with self-referencing column in SET [calcite]

Posted by "dssysolyatin (via GitHub)" <gi...@apache.org>.
dssysolyatin commented on code in PR #4572:
URL: https://github.com/apache/calcite/pull/4572#discussion_r2449453489


##########
core/src/main/java/org/apache/calcite/rel/core/TableModify.java:
##########
@@ -55,7 +55,18 @@
  * <ul>
  * <li>For {@code INSERT}, those rows are the new values;
  * <li>for {@code DELETE}, the old values;
- * <li>for {@code UPDATE}, all old values plus updated new values.
+ * <li>for {@code UPDATE}, all old values plus updated new values;
+ * <li>for {@code MERGE}, the rows may contain fields for both {@code INSERT} and {@code UPDATE}

Review Comment:
   I just added the missing documentation. I reviewed how the whole SqlInsert/SqlDelete/SqlMerge flow works and added the missing docs.
   
   > is this just adding missing documentation, or is it a new feature you are adding?
   
   If this kind of question comes up in a PR review, I agree. (Though it’s pretty annoying to make a separate task just to update the docs)
   
   > if it's missing documentation is should probably stay in a separate commit.



-- 
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-7220] RelToSqlConverter throws exception for UPDATE with self-referencing column in SET [calcite]

Posted by "dssysolyatin (via GitHub)" <gi...@apache.org>.
dssysolyatin commented on code in PR #4572:
URL: https://github.com/apache/calcite/pull/4572#discussion_r2443283190


##########
core/src/main/java/org/apache/calcite/rel/rel2sql/RelToSqlConverter.java:
##########
@@ -1141,16 +1138,21 @@ public Result visit(TableModify modify) {
       return result(sqlInsert, ImmutableList.of(), modify, null);
     }
     case UPDATE: {
+      final List<String> updateColumnList =
+          requireNonNull(modify.getUpdateColumnList(),
+              () -> "modify.getUpdateColumnList() is null for " + modify);
       final Result input = visitInput(modify, 0);
+      final SqlSelect sourceSelect = input.asSelect();

Review Comment:
   Fixed. @mihaibudiu If possible, please recheck PR. Also, I have revised my view regarding `TableModify.getSourceExpressionList()`. Please check the latest comment in Jira



-- 
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-7220] RelToSqlConverter throws exception for UPDATE with self-referencing column in SET [calcite]

Posted by "dssysolyatin (via GitHub)" <gi...@apache.org>.
dssysolyatin commented on code in PR #4572:
URL: https://github.com/apache/calcite/pull/4572#discussion_r2420428013


##########
core/src/main/java/org/apache/calcite/rel/rel2sql/RelToSqlConverter.java:
##########
@@ -1141,16 +1138,21 @@ public Result visit(TableModify modify) {
       return result(sqlInsert, ImmutableList.of(), modify, null);
     }
     case UPDATE: {
+      final List<String> updateColumnList =
+          requireNonNull(modify.getUpdateColumnList(),
+              () -> "modify.getUpdateColumnList() is null for " + modify);
       final Result input = visitInput(modify, 0);
+      final SqlSelect sourceSelect = input.asSelect();

Review Comment:
   I will try to include something. 
   
   Also, I found an issue with subqueries like this:
   ```
   UPDATE <table> SET product_id = (SELECT product_id FROM <table> LIMIT 1)
   ```
   
   I’ll fix it as part of this ticket. It seems someone has already worked on it https://github.com/apache/calcite/pull/2788. I’ll review it and see if I can reuse some of those changes.



-- 
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-7220] RelToSqlConverter throws exception for UPDATE with self-referencing column in SET [calcite]

Posted by "dssysolyatin (via GitHub)" <gi...@apache.org>.
dssysolyatin commented on code in PR #4572:
URL: https://github.com/apache/calcite/pull/4572#discussion_r2416249809


##########
core/src/main/java/org/apache/calcite/rel/rel2sql/RelToSqlConverter.java:
##########
@@ -1141,16 +1138,21 @@ public Result visit(TableModify modify) {
       return result(sqlInsert, ImmutableList.of(), modify, null);
     }
     case UPDATE: {
+      final List<String> updateColumnList =
+          requireNonNull(modify.getUpdateColumnList(),
+              () -> "modify.getUpdateColumnList() is null for " + modify);
       final Result input = visitInput(modify, 0);
+      final SqlSelect sourceSelect = input.asSelect();
+      final SqlNodeList expressionList = sourceSelect.getSelectList()

Review Comment:
   Yes, it is not good. Logic of `RelToSqlConverter` should not depend on logic of `ValidationImpl`. Fixed



##########
core/src/main/java/org/apache/calcite/rel/rel2sql/RelToSqlConverter.java:
##########
@@ -1141,16 +1138,21 @@ public Result visit(TableModify modify) {
       return result(sqlInsert, ImmutableList.of(), modify, null);
     }
     case UPDATE: {
+      final List<String> updateColumnList =
+          requireNonNull(modify.getUpdateColumnList(),
+              () -> "modify.getUpdateColumnList() is null for " + modify);
       final Result input = visitInput(modify, 0);
+      final SqlSelect sourceSelect = input.asSelect();
+      final SqlNodeList expressionList = sourceSelect.getSelectList()

Review Comment:
   Yes, it is not good. Logic of `RelToSqlConverter` should not depend on logic of `ValidatorImpl`. Fixed



-- 
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-7220] RelToSqlConverter throws exception for UPDATE with self-referencing column in SET [calcite]

Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #4572:
URL: https://github.com/apache/calcite/pull/4572#issuecomment-3385184065

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=4572) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 New issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=4572&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=4572&issueStatuses=ACCEPTED)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_calcite&pullRequest=4572&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [100.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=4572&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=4572&metric=new_duplicated_lines_density&view=list)  
     
   [See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=4572)
   
   


-- 
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-7220] RelToSqlConverter throws exception for UPDATE with self-referencing column in SET [calcite]

Posted by "dssysolyatin (via GitHub)" <gi...@apache.org>.
dssysolyatin commented on code in PR #4572:
URL: https://github.com/apache/calcite/pull/4572#discussion_r2416256439


##########
core/src/main/java/org/apache/calcite/rel/rel2sql/SqlImplementor.java:
##########
@@ -1810,6 +1814,69 @@ private boolean isWindowTableFunctionRex(RexNode rex) {
     };
   }
 
+  /**
+   * A context that uses a select list.
+   */
+  final class SelectListContext extends BaseContext {

Review Comment:
   Just moved `SelectListContext` from `Result` to other contexts so it can be used inside `RelToSqlConverter`.



-- 
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-7220] RelToSqlConverter throws exception for UPDATE with self-referencing column in SET [calcite]

Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #4572:
URL: https://github.com/apache/calcite/pull/4572#issuecomment-3443560244

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=4572) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [1 New issue](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=4572&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=4572&issueStatuses=ACCEPTED)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_calcite&pullRequest=4572&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [97.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=4572&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [12.8% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=4572&metric=new_duplicated_lines_density&view=list)  
     
   [See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=4572)
   
   


-- 
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-7220] RelToSqlConverter throws exception for UPDATE with self-referencing column in SET [calcite]

Posted by "dssysolyatin (via GitHub)" <gi...@apache.org>.
dssysolyatin commented on code in PR #4572:
URL: https://github.com/apache/calcite/pull/4572#discussion_r2443272059


##########
core/src/main/java/org/apache/calcite/sql/validate/implicit/TypeCoercionImpl.java:
##########
@@ -766,16 +765,10 @@ private boolean coerceSourceRowType(
           targetType);
     case UPDATE:
       SqlUpdate update = (SqlUpdate) query;
-      final SqlNodeList sourceExpressionList = update.getSourceExpressionList();
-      if (sourceExpressionList != null) {
-        return coerceColumnType(sourceScope, sourceExpressionList, columnIndex, targetType);
-      } else {
-        // Note: this is dead code since sourceExpressionList is always non-null
-        return coerceSourceRowType(sourceScope,
-            castNonNull(update.getSourceSelect()),
-            columnIndex,
-            targetType);
-      }
+      return coerceSourceRowType(sourceScope,

Review Comment:
   Coerce whole source SELECT instead of just sourceExpressionList, then grab the last N items from sourceSelect and assign them to expressionList inside `validateUpdate`, because sourceSelect already contains expressionList



##########
core/src/test/resources/org/apache/calcite/test/SqlToRelConverterTest.xml:
##########


Review Comment:
   Changes in these tests:
   1. Casts are inside LogicalProject instead of LogicalTableModify
   2. LogicalTableModify now only contains RexInputRef 
   
   



##########
core/src/main/java/org/apache/calcite/sql/validate/SqlValidatorImpl.java:
##########
@@ -5599,15 +5599,6 @@ protected void checkTypeAssignment(
     // matched
     boolean isUpdateModifiableViewTable = false;
     if (query instanceof SqlUpdate) {
-      final SqlNodeList targetColumnList =

Review Comment:
   It’s not needed anymore because the whole source select is now validated



##########
core/src/test/resources/org/apache/calcite/test/TypeCoercionConverterTest.xml:
##########
@@ -281,8 +281,8 @@ LogicalUnion(all=[false])
     </Resource>
     <Resource name="plan">
       <![CDATA[
-LogicalTableModify(table=[[CATALOG, SALES, T1]], operation=[UPDATE], updateColumnList=[[t1_varchar20, t1_date, t1_int]], sourceExpressionList=[[CAST(123):VARCHAR(20) NOT NULL, CAST(2020-01-03 10:14:34):DATE NOT NULL, CAST(12.3:DECIMAL(3, 1)):INTEGER NOT NULL]], flattened=[false])
-  LogicalProject(t1_varchar20=[$0], t1_smallint=[$1], t1_int=[$2], t1_bigint=[$3], t1_real=[$4], t1_double=[$5], t1_decimal=[$6], t1_timestamp=[$7], t1_date=[$8], t1_binary=[$9], t1_boolean=[$10], EXPR$0=[123], EXPR$1=[2020-01-03 10:14:34], EXPR$2=[12.3:DECIMAL(3, 1)])
+LogicalTableModify(table=[[CATALOG, SALES, T1]], operation=[UPDATE], updateColumnList=[[t1_varchar20, t1_date, t1_int]], sourceExpressionList=[[$11, $12, $13]], flattened=[false])
+  LogicalProject(t1_varchar20=[$0], t1_smallint=[$1], t1_int=[$2], t1_bigint=[$3], t1_real=[$4], t1_double=[$5], t1_decimal=[$6], t1_timestamp=[$7], t1_date=[$8], t1_binary=[$9], t1_boolean=[$10], EXPR$0=['123':VARCHAR(20)], EXPR$1=[2020-01-03], EXPR$2=[12])

Review Comment:
   It’s correct that `CAST(2020-01-03 10:14:34):DATE NOT NULL` got simplified to `2020-01-03`. This didn’t happen before because the cast used to be inside LogicalTableModify and was applied to a RexInputRef. But now it’s in the `selectList` and applied directly to literals, so RexSimplify just folded it



-- 
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-7220] RelToSqlConverter throws exception for UPDATE with self-referencing column in SET [calcite]

Posted by "dssysolyatin (via GitHub)" <gi...@apache.org>.
dssysolyatin commented on code in PR #4572:
URL: https://github.com/apache/calcite/pull/4572#discussion_r2416247477


##########
core/src/main/java/org/apache/calcite/rel/rel2sql/RelToSqlConverter.java:
##########
@@ -1141,16 +1138,21 @@ public Result visit(TableModify modify) {
       return result(sqlInsert, ImmutableList.of(), modify, null);
     }
     case UPDATE: {
+      final List<String> updateColumnList =
+          requireNonNull(modify.getUpdateColumnList(),
+              () -> "modify.getUpdateColumnList() is null for " + modify);
       final Result input = visitInput(modify, 0);
+      final SqlSelect sourceSelect = input.asSelect();

Review Comment:
   Let's assume we have this input expression:
   ```
   UPDATE `foodmart`.`product` SET `product_name` = `product_name` || 'calcite' WHERE `product_id` > 10
   ```
   
   calcite parser will parse it as:
   ```
   SqlUpdate(
       targetColumnList = [product_name], 
       sourceExpressionList = [`product_name` || 'calcite'], 
       condition = `product_id` > 10,
       sourceSelect = null <-- sourceSelect is null
   )
   ```
   
   Then, `ValidatorImpl.createSourceSelectForUpdate` changes it into:
   ```
   SqlUpdate(
       targetColumnList = [product_name], 
       sourceExpressionList = [`product_name` || 'calcite'], 
       condition = `product_id` > 10,
       sourceSelect = "SELECT *, `product_name` || 'calcite' AS `EXPR$0` FROM `foodmart`.`product` WHERE `product_id` > 10"
   )
   ```
   
   Next, `SqlToRelConverter` converts it into this logical plan:
   ```
   LogicalTableModify(
     table=[[foodmart, product]], operation=[UPDATE], 
     updateColumnList=[[product_name]], 
     sourceExpressionList=[[CAST(||($3, 'calcite')):VARCHAR(60) NOT NULL]], 
     flattened=[true]
   )
     LogicalProject(product_class_id=[$0], product_id=[$1], <all 14 fields>,  EXPR$0=[||($3, 'calcite')])
       LogicalFilter(condition=[>($1, 10)])
         LogicalTableScan(table=[[foodmart, product]])
   ```
   
   `LogicalTableModify.sourceExpressionList` is built using the blackboard from LogicalProject, but it doesn’t use expressions directly from `LogicalProject`. (This is one more reason my previous fix was incorrect. It lost type coercion in this case).
   
   Now, answer on your question: "What is this SqlSelect node"
   
   `RelToSqlConverter` transforms `TableModify.input` into:
   ```
   SELECT `product_class_id`, `product_id`, `brand_name`, `product_name`, `SKU`, `SRP`, `gross_weight`, `net_weight`, `recyclable_package`, `low_fat`, `units_per_case`, `cases_per_pallet`, `shelf_width`, `shelf_height`, `shelf_depth`, `product_name` || 'calcite' AS `EXPR$0`
   FROM `foodmart`.`product`
   WHERE `product_id` > 10
   ```
   
   Calcite takes the WHERE clause for the UPDATE from this SELECT. ~(This is not completely correct. if we later support `UPDATE FROM` syntax, it will be wrong. Instead, we should build the `WHERE` clause based on the `SELECT` context, rather than reusing parts of the `SELECT`)~
   
   We also need to convert `TableModify.sourceExpressionList` into a `SqlNode` using the context of this SELECT, similar to how we use the LogicalProject blackboard when converting a SqlNode to a RelNode. My current fix uses this approach



-- 
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-7220] RelToSqlConverter throws exception for UPDATE with self-referencing column in SET [calcite]

Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #4572:
URL: https://github.com/apache/calcite/pull/4572#issuecomment-3419617208

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=4572) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [1 New issue](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=4572&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=4572&issueStatuses=ACCEPTED)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_calcite&pullRequest=4572&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [97.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=4572&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [13.9% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=4572&metric=new_duplicated_lines_density&view=list)  
     
   [See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=4572)
   
   


-- 
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-7220] RelToSqlConverter throws exception for UPDATE with self-referencing column in SET [calcite]

Posted by "dssysolyatin (via GitHub)" <gi...@apache.org>.
dssysolyatin commented on code in PR #4572:
URL: https://github.com/apache/calcite/pull/4572#discussion_r2415025967


##########
core/src/main/java/org/apache/calcite/rel/rel2sql/RelToSqlConverter.java:
##########
@@ -1141,16 +1138,21 @@ public Result visit(TableModify modify) {
       return result(sqlInsert, ImmutableList.of(), modify, null);
     }
     case UPDATE: {
+      final List<String> updateColumnList =
+          requireNonNull(modify.getUpdateColumnList(),
+              () -> "modify.getUpdateColumnList() is null for " + modify);
       final Result input = visitInput(modify, 0);
+      final SqlSelect sourceSelect = input.asSelect();
+      final SqlNodeList expressionList = sourceSelect.getSelectList()

Review Comment:
   Although, It works, but it depends on the TableModify.input being built in a specific way. (Also `MERGE` work in the same way).
   
   A better approach might be to pass into `exprList` aliasContext which looks like
   ```
   exprList(aliasContext(ImmutableMap("p", modify.getRowType().get), false), modify.getSourceExpressionList())
   ```
   and rely on `ModifyTable.getSourceExpressionList()` instead



-- 
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-7220] RelToSqlConverter throws exception for UPDATE with self-referencing column in SET [calcite]

Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #4572:
URL: https://github.com/apache/calcite/pull/4572#issuecomment-3385005469

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=4572) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 New issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=4572&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=4572&issueStatuses=ACCEPTED)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_calcite&pullRequest=4572&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [100.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=4572&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=4572&metric=new_duplicated_lines_density&view=list)  
     
   [See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=4572)
   
   


-- 
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-7220] RelToSqlConverter throws exception for UPDATE with self-referencing column in SET [calcite]

Posted by "dssysolyatin (via GitHub)" <gi...@apache.org>.
dssysolyatin commented on code in PR #4572:
URL: https://github.com/apache/calcite/pull/4572#discussion_r2443295738


##########
core/src/test/resources/org/apache/calcite/test/TypeCoercionConverterTest.xml:
##########
@@ -281,8 +281,8 @@ LogicalUnion(all=[false])
     </Resource>
     <Resource name="plan">
       <![CDATA[
-LogicalTableModify(table=[[CATALOG, SALES, T1]], operation=[UPDATE], updateColumnList=[[t1_varchar20, t1_date, t1_int]], sourceExpressionList=[[CAST(123):VARCHAR(20) NOT NULL, CAST(2020-01-03 10:14:34):DATE NOT NULL, CAST(12.3:DECIMAL(3, 1)):INTEGER NOT NULL]], flattened=[false])
-  LogicalProject(t1_varchar20=[$0], t1_smallint=[$1], t1_int=[$2], t1_bigint=[$3], t1_real=[$4], t1_double=[$5], t1_decimal=[$6], t1_timestamp=[$7], t1_date=[$8], t1_binary=[$9], t1_boolean=[$10], EXPR$0=[123], EXPR$1=[2020-01-03 10:14:34], EXPR$2=[12.3:DECIMAL(3, 1)])
+LogicalTableModify(table=[[CATALOG, SALES, T1]], operation=[UPDATE], updateColumnList=[[t1_varchar20, t1_date, t1_int]], sourceExpressionList=[[$11, $12, $13]], flattened=[false])
+  LogicalProject(t1_varchar20=[$0], t1_smallint=[$1], t1_int=[$2], t1_bigint=[$3], t1_real=[$4], t1_double=[$5], t1_decimal=[$6], t1_timestamp=[$7], t1_date=[$8], t1_binary=[$9], t1_boolean=[$10], EXPR$0=['123':VARCHAR(20)], EXPR$1=[2020-01-03], EXPR$2=[12])

Review Comment:
   Folding happens when `SqlToRelConverter.convertSelect` creates a `Project` using `RelBuilder.projectNamed`, because `RexSimplify` is called inside `projectNamed`. It was likely different before, since `bb.convertExpression` probably does not call `RexSimplify`



-- 
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-7220] RelToSqlConverter throws exception for UPDATE with self-referencing column in SET [calcite]

Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #4572:
URL: https://github.com/apache/calcite/pull/4572#issuecomment-3383181224

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=4572) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [2 New issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=4572&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=4572&issueStatuses=ACCEPTED)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_calcite&pullRequest=4572&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [90.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=4572&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=4572&metric=new_duplicated_lines_density&view=list)  
     
   [See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=4572)
   
   


-- 
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-7220] RelToSqlConverter throws exception for UPDATE with self-referencing column in SET [calcite]

Posted by "dssysolyatin (via GitHub)" <gi...@apache.org>.
dssysolyatin commented on code in PR #4572:
URL: https://github.com/apache/calcite/pull/4572#discussion_r2416256439


##########
core/src/main/java/org/apache/calcite/rel/rel2sql/SqlImplementor.java:
##########
@@ -1810,6 +1814,69 @@ private boolean isWindowTableFunctionRex(RexNode rex) {
     };
   }
 
+  /**
+   * A context that uses a select list.
+   */
+  final class SelectListContext extends BaseContext {

Review Comment:
   Moved `SelectListContext` from `Result` to other contexts so it can be used inside `RelToSqlConverter`.



-- 
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-7220] RelToSqlConverter throws exception for UPDATE with self-referencing column in SET [calcite]

Posted by "dssysolyatin (via GitHub)" <gi...@apache.org>.
dssysolyatin commented on code in PR #4572:
URL: https://github.com/apache/calcite/pull/4572#discussion_r2449495723


##########
core/src/main/java/org/apache/calcite/sql/SqlMerge.java:
##########
@@ -148,10 +148,19 @@ public SqlNode getCondition() {
 
   /**
    * Gets the source SELECT expression for the data to be updated/inserted.
+   *
+   * <p>The source SELECT column order:
+   * <ul>
+   *   <li>`WHEN NOT MATCHED THEN INSERT` only: [new values...]</li>
+   *   <li>`WHEN MATCHED THEN UPDATE` only: [old table columns..., updated new values...]</li>
+   *   <li>Both `NOT MATCHED THEN INSERT` and `WHEN MATCHED THEN UPDATE`: [insert new values...,
+   *   old table columns..., updated new values...]</li>
+   * </ul>
    * Returns null before the statement has been expanded by
-   * {@link SqlValidatorImpl#performUnconditionalRewrites(SqlNode, boolean)}.
+   * {@link SqlValidatorImpl#performUnconditionalRewrites(SqlNode, boolean)} and

Review Comment:
   This particular sentence isn’t mine; Julian added it. I won’t argue about its correctness because English is my second language. It’s definitely not “expand” in the usual sense, like when “SELECT *” expands into “SELECT name, age.” or like "expand view". Technically it fits into dictionary definition "to increase something in size"
   
   > Returns null before the statement has been expanded by
   



-- 
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-7220] RelToSqlConverter throws exception for UPDATE with self-referencing column in SET [calcite]

Posted by "mihaibudiu (via GitHub)" <gi...@apache.org>.
mihaibudiu commented on code in PR #4572:
URL: https://github.com/apache/calcite/pull/4572#discussion_r2417407575


##########
core/src/main/java/org/apache/calcite/rel/rel2sql/RelToSqlConverter.java:
##########
@@ -1141,16 +1138,21 @@ public Result visit(TableModify modify) {
       return result(sqlInsert, ImmutableList.of(), modify, null);
     }
     case UPDATE: {
+      final List<String> updateColumnList =
+          requireNonNull(modify.getUpdateColumnList(),
+              () -> "modify.getUpdateColumnList() is null for " + modify);
       final Result input = visitInput(modify, 0);
+      final SqlSelect sourceSelect = input.asSelect();

Review Comment:
   This is a great explanation, could you add parts of it as comments in the code?
   This will help a lot of other people.



-- 
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-7220] RelToSqlConverter throws exception for UPDATE with self-referencing column in SET [calcite]

Posted by "dssysolyatin (via GitHub)" <gi...@apache.org>.
dssysolyatin commented on code in PR #4572:
URL: https://github.com/apache/calcite/pull/4572#discussion_r2420428013


##########
core/src/main/java/org/apache/calcite/rel/rel2sql/RelToSqlConverter.java:
##########
@@ -1141,16 +1138,21 @@ public Result visit(TableModify modify) {
       return result(sqlInsert, ImmutableList.of(), modify, null);
     }
     case UPDATE: {
+      final List<String> updateColumnList =
+          requireNonNull(modify.getUpdateColumnList(),
+              () -> "modify.getUpdateColumnList() is null for " + modify);
       final Result input = visitInput(modify, 0);
+      final SqlSelect sourceSelect = input.asSelect();

Review Comment:
   I will try to include something. 
   
   Also, I found an issue with subqueries like this:
   ```
   UPDATE <table> SET product_id = (SELECT product_id FROM <table> LIMIT 1)
   ```
   
   I’ll fix it as part of this ticket. It seems someone has already worked on it 3 years ago https://github.com/apache/calcite/pull/2788. I’ll review it and see if I can reuse some of those changes.



-- 
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-7220] RelToSqlConverter throws exception for UPDATE with self-referencing column in SET [calcite]

Posted by "dssysolyatin (via GitHub)" <gi...@apache.org>.
dssysolyatin commented on code in PR #4572:
URL: https://github.com/apache/calcite/pull/4572#discussion_r2443270077


##########
core/src/main/java/org/apache/calcite/rel/rel2sql/RelToSqlConverter.java:
##########
@@ -1141,16 +1138,21 @@ public Result visit(TableModify modify) {
       return result(sqlInsert, ImmutableList.of(), modify, null);
     }
     case UPDATE: {
+      final List<String> updateColumnList =
+          requireNonNull(modify.getUpdateColumnList(),
+              () -> "modify.getUpdateColumnList() is null for " + modify);
       final Result input = visitInput(modify, 0);
+      final SqlSelect sourceSelect = input.asSelect();
+      final SqlNodeList expressionList = sourceSelect.getSelectList()

Review Comment:
   The previous solution was also fine because the TableModify documentation defines a contract for how TableModify.input should look



-- 
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-7220] RelToSqlConverter throws exception for UPDATE with self-referencing column in SET [calcite]

Posted by "dssysolyatin (via GitHub)" <gi...@apache.org>.
dssysolyatin commented on code in PR #4572:
URL: https://github.com/apache/calcite/pull/4572#discussion_r2449497837


##########
core/src/main/java/org/apache/calcite/rel/rel2sql/SqlImplementor.java:
##########
@@ -1810,6 +1814,69 @@ private boolean isWindowTableFunctionRex(RexNode rex) {
     };
   }
 
+  /**
+   * A context that uses a select list.
+   */
+  final class SelectListContext extends BaseContext {
+    private final boolean aliasRef;
+    private final SqlNodeList selectList;
+
+    SelectListContext(

Review Comment:
   Yeah, no problem



-- 
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-7220] RelToSqlConverter throws exception for UPDATE with self-referencing column in SET [calcite]

Posted by "dssysolyatin (via GitHub)" <gi...@apache.org>.
dssysolyatin commented on code in PR #4572:
URL: https://github.com/apache/calcite/pull/4572#discussion_r2443273543


##########
core/src/test/resources/org/apache/calcite/test/TypeCoercionConverterTest.xml:
##########
@@ -281,8 +281,8 @@ LogicalUnion(all=[false])
     </Resource>
     <Resource name="plan">
       <![CDATA[
-LogicalTableModify(table=[[CATALOG, SALES, T1]], operation=[UPDATE], updateColumnList=[[t1_varchar20, t1_date, t1_int]], sourceExpressionList=[[CAST(123):VARCHAR(20) NOT NULL, CAST(2020-01-03 10:14:34):DATE NOT NULL, CAST(12.3:DECIMAL(3, 1)):INTEGER NOT NULL]], flattened=[false])
-  LogicalProject(t1_varchar20=[$0], t1_smallint=[$1], t1_int=[$2], t1_bigint=[$3], t1_real=[$4], t1_double=[$5], t1_decimal=[$6], t1_timestamp=[$7], t1_date=[$8], t1_binary=[$9], t1_boolean=[$10], EXPR$0=[123], EXPR$1=[2020-01-03 10:14:34], EXPR$2=[12.3:DECIMAL(3, 1)])
+LogicalTableModify(table=[[CATALOG, SALES, T1]], operation=[UPDATE], updateColumnList=[[t1_varchar20, t1_date, t1_int]], sourceExpressionList=[[$11, $12, $13]], flattened=[false])
+  LogicalProject(t1_varchar20=[$0], t1_smallint=[$1], t1_int=[$2], t1_bigint=[$3], t1_real=[$4], t1_double=[$5], t1_decimal=[$6], t1_timestamp=[$7], t1_date=[$8], t1_binary=[$9], t1_boolean=[$10], EXPR$0=['123':VARCHAR(20)], EXPR$1=[2020-01-03], EXPR$2=[12])

Review Comment:
   It’s correct that `CAST(2020-01-03 10:14:34):DATE NOT NULL` got simplified to `2020-01-03`. It’s in the `selectList` and applied directly to typed literals, so RexSimplify just folded it



-- 
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-7220] RelToSqlConverter throws exception for UPDATE with self-referencing column in SET [calcite]

Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #4572:
URL: https://github.com/apache/calcite/pull/4572#issuecomment-3383144726

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=4572) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [4 New issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=4572&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=4572&issueStatuses=ACCEPTED)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_calcite&pullRequest=4572&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [90.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=4572&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=4572&metric=new_duplicated_lines_density&view=list)  
     
   [See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=4572)
   
   


-- 
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-7220] RelToSqlConverter throws exception for UPDATE with self-referencing column in SET [calcite]

Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #4572:
URL: https://github.com/apache/calcite/pull/4572#issuecomment-3443518067

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=4572) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [2 New issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=4572&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=4572&issueStatuses=ACCEPTED)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_calcite&pullRequest=4572&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [97.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=4572&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [12.8% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=4572&metric=new_duplicated_lines_density&view=list)  
     
   [See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=4572)
   
   


-- 
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-7220] RelToSqlConverter throws exception for UPDATE with self-referencing column in SET [calcite]

Posted by "dssysolyatin (via GitHub)" <gi...@apache.org>.
dssysolyatin commented on code in PR #4572:
URL: https://github.com/apache/calcite/pull/4572#discussion_r2415025967


##########
core/src/main/java/org/apache/calcite/rel/rel2sql/RelToSqlConverter.java:
##########
@@ -1141,16 +1138,21 @@ public Result visit(TableModify modify) {
       return result(sqlInsert, ImmutableList.of(), modify, null);
     }
     case UPDATE: {
+      final List<String> updateColumnList =
+          requireNonNull(modify.getUpdateColumnList(),
+              () -> "modify.getUpdateColumnList() is null for " + modify);
       final Result input = visitInput(modify, 0);
+      final SqlSelect sourceSelect = input.asSelect();
+      final SqlNodeList expressionList = sourceSelect.getSelectList()

Review Comment:
   Although it works, it relies on the fact that TableModify.input is built in a specific way. (`MERGE` works the same way).
   
   A better approach might be to pass into `exprList` aliasContext which looks like
   ```
   exprList(aliasContext(ImmutableMap("p", modify.getRowType().get), false), modify.getSourceExpressionList())
   ```
   and rely on `ModifyTable.getSourceExpressionList()` instead



-- 
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-7220] RelToSqlConverter throws exception for UPDATE with self-referencing column in SET [calcite]

Posted by "mihaibudiu (via GitHub)" <gi...@apache.org>.
mihaibudiu commented on code in PR #4572:
URL: https://github.com/apache/calcite/pull/4572#discussion_r2415044684


##########
core/src/main/java/org/apache/calcite/rel/rel2sql/RelToSqlConverter.java:
##########
@@ -1141,16 +1138,21 @@ public Result visit(TableModify modify) {
       return result(sqlInsert, ImmutableList.of(), modify, null);
     }
     case UPDATE: {
+      final List<String> updateColumnList =
+          requireNonNull(modify.getUpdateColumnList(),
+              () -> "modify.getUpdateColumnList() is null for " + modify);
       final Result input = visitInput(modify, 0);
+      final SqlSelect sourceSelect = input.asSelect();

Review Comment:
   What is this this SqlSelect node?



##########
core/src/main/java/org/apache/calcite/rel/rel2sql/RelToSqlConverter.java:
##########
@@ -1141,16 +1138,21 @@ public Result visit(TableModify modify) {
       return result(sqlInsert, ImmutableList.of(), modify, null);
     }
     case UPDATE: {
+      final List<String> updateColumnList =
+          requireNonNull(modify.getUpdateColumnList(),
+              () -> "modify.getUpdateColumnList() is null for " + modify);
       final Result input = visitInput(modify, 0);
+      final SqlSelect sourceSelect = input.asSelect();

Review Comment:
   What is this SqlSelect node?



-- 
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-7220] RelToSqlConverter throws exception for UPDATE with self-referencing column in SET [calcite]

Posted by "mihaibudiu (via GitHub)" <gi...@apache.org>.
mihaibudiu commented on code in PR #4572:
URL: https://github.com/apache/calcite/pull/4572#discussion_r2446206698


##########
core/src/main/java/org/apache/calcite/rel/core/TableModify.java:
##########
@@ -55,7 +55,18 @@
  * <ul>
  * <li>For {@code INSERT}, those rows are the new values;
  * <li>for {@code DELETE}, the old values;
- * <li>for {@code UPDATE}, all old values plus updated new values.
+ * <li>for {@code UPDATE}, all old values plus updated new values;
+ * <li>for {@code MERGE}, the rows may contain fields for both {@code INSERT} and {@code UPDATE}

Review Comment:
   is this just adding missing documentation, or is it a new feature you are adding?
   if it's a new feature, it should probably be a separate JIRA case.
   if it's missing documentation is should probably stay in a separate commit.



##########
core/src/main/java/org/apache/calcite/rel/rel2sql/SqlImplementor.java:
##########
@@ -1810,6 +1814,69 @@ private boolean isWindowTableFunctionRex(RexNode rex) {
     };
   }
 
+  /**
+   * A context that uses a select list.
+   */
+  final class SelectListContext extends BaseContext {
+    private final boolean aliasRef;
+    private final SqlNodeList selectList;
+
+    SelectListContext(

Review Comment:
   I know you didn't write this class, but I can't quickly figure out what aliasRef means, if you know maybe you can add some JavaDoc.



##########
core/src/main/java/org/apache/calcite/sql/SqlMerge.java:
##########
@@ -148,10 +148,19 @@ public SqlNode getCondition() {
 
   /**
    * Gets the source SELECT expression for the data to be updated/inserted.
+   *
+   * <p>The source SELECT column order:
+   * <ul>
+   *   <li>`WHEN NOT MATCHED THEN INSERT` only: [new values...]</li>
+   *   <li>`WHEN MATCHED THEN UPDATE` only: [old table columns..., updated new values...]</li>
+   *   <li>Both `NOT MATCHED THEN INSERT` and `WHEN MATCHED THEN UPDATE`: [insert new values...,
+   *   old table columns..., updated new values...]</li>
+   * </ul>
    * Returns null before the statement has been expanded by
-   * {@link SqlValidatorImpl#performUnconditionalRewrites(SqlNode, boolean)}.
+   * {@link SqlValidatorImpl#performUnconditionalRewrites(SqlNode, boolean)} and

Review Comment:
   do you mean "returns null if called before ... have been invoked?"



-- 
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-7220] RelToSqlConverter throws exception for UPDATE with self-referencing column in SET [calcite]

Posted by "dssysolyatin (via GitHub)" <gi...@apache.org>.
dssysolyatin commented on code in PR #4572:
URL: https://github.com/apache/calcite/pull/4572#discussion_r2460812303


##########
core/src/main/java/org/apache/calcite/rel/rel2sql/SqlImplementor.java:
##########
@@ -1810,6 +1814,69 @@ private boolean isWindowTableFunctionRex(RexNode rex) {
     };
   }
 
+  /**
+   * A context that uses a select list.
+   */
+  final class SelectListContext extends BaseContext {
+    private final boolean aliasRef;
+    private final SqlNodeList selectList;
+
+    SelectListContext(

Review Comment:
   Done.



-- 
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-7220] RelToSqlConverter throws exception for UPDATE with self-referencing column in SET [calcite]

Posted by "dssysolyatin (via GitHub)" <gi...@apache.org>.
dssysolyatin commented on code in PR #4572:
URL: https://github.com/apache/calcite/pull/4572#discussion_r2416247477


##########
core/src/main/java/org/apache/calcite/rel/rel2sql/RelToSqlConverter.java:
##########
@@ -1141,16 +1138,21 @@ public Result visit(TableModify modify) {
       return result(sqlInsert, ImmutableList.of(), modify, null);
     }
     case UPDATE: {
+      final List<String> updateColumnList =
+          requireNonNull(modify.getUpdateColumnList(),
+              () -> "modify.getUpdateColumnList() is null for " + modify);
       final Result input = visitInput(modify, 0);
+      final SqlSelect sourceSelect = input.asSelect();

Review Comment:
   Let's assume we have this input expression:
   ```
   UPDATE `foodmart`.`product` SET `product_name` = `product_name` || 'calcite' WHERE `product_id` > 10
   ```
   
   calcite parser will parse it as:
   ```
   SqlUpdate(
       targetColumnList = [product_name], 
       sourceExpressionList = ['calcite'], 
       sourceSelect = null <-- sourceSelect is null
   )
   ```
   
   Then, `ValidatorImpl.createSourceSelectForUpdate` changes it into:
   ```
   SqlUpdate(
       targetColumnList = [product_name], 
       sourceExpressionList = [`product_name` || 'calcite'], 
       sourceSelect = "SELECT *, `product_name` || 'calcite' AS `EXPR$0` FROM `foodmart`.`product` WHERE `product_id` > 10"
   )
   ```
   
   Next, `SqlToRelConverter` converts it into this logical plan:
   ```
   LogicalTableModify(
     table=[[foodmart, product]], operation=[UPDATE], 
     updateColumnList=[[product_name]], 
     sourceExpressionList=[[CAST(||($3, 'calcite')):VARCHAR(60) NOT NULL]], 
     flattened=[true]
   )
     LogicalProject(product_class_id=[$0], product_id=[$1], <all 14 fields>,  EXPR$0=[||($3, 'calcite')])
       LogicalFilter(condition=[>($1, 10)])
         LogicalTableScan(table=[[foodmart, product]])
   ```
   
   `LogicalTableModify.sourceExpressionList` is built using the blackboard from LogicalProject, but it doesn’t use expressions directly from `LogicalProject`. (This is one more reason my previous fix was incorrect. It lost type coercion in this case).
   
   Now, answer on your question: "What is this SqlSelect node"
   
   `RelToSqlConverter` transforms `TableModify.input` into:
   ```
   SELECT `product_class_id`, `product_id`, `brand_name`, `product_name`, `SKU`, `SRP`, `gross_weight`, `net_weight`, `recyclable_package`, `low_fat`, `units_per_case`, `cases_per_pallet`, `shelf_width`, `shelf_height`, `shelf_depth`, `product_name` || 'calcite' AS `EXPR$0`
   FROM `foodmart`.`product`
   WHERE `product_id` > 10
   ```
   
   Calcite code takes the WHERE clause for the UPDATE from this SELECT. We also need to convert `TableModify.sourceExpressionList` into a SqlNode based on the context of this SELECT (as we do when we convert SqlNode to RelNode). My current fix use this approach



-- 
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-7220] RelToSqlConverter throws exception for UPDATE with self-referencing column in SET [calcite]

Posted by "dssysolyatin (via GitHub)" <gi...@apache.org>.
dssysolyatin commented on code in PR #4572:
URL: https://github.com/apache/calcite/pull/4572#discussion_r2416247477


##########
core/src/main/java/org/apache/calcite/rel/rel2sql/RelToSqlConverter.java:
##########
@@ -1141,16 +1138,21 @@ public Result visit(TableModify modify) {
       return result(sqlInsert, ImmutableList.of(), modify, null);
     }
     case UPDATE: {
+      final List<String> updateColumnList =
+          requireNonNull(modify.getUpdateColumnList(),
+              () -> "modify.getUpdateColumnList() is null for " + modify);
       final Result input = visitInput(modify, 0);
+      final SqlSelect sourceSelect = input.asSelect();

Review Comment:
   Let's assume we have this input expression:
   ```
   UPDATE `foodmart`.`product` SET `product_name` = `product_name` || 'calcite' WHERE `product_id` > 10
   ```
   
   calcite parser will parse it as:
   ```
   SqlUpdate(
       targetColumnList = [product_name], 
       sourceExpressionList = [`product_name` || 'calcite'], 
       condition = `product_id` > 10,
       sourceSelect = null <-- sourceSelect is null
   )
   ```
   
   Then, `ValidatorImpl.createSourceSelectForUpdate` changes it into:
   ```
   SqlUpdate(
       targetColumnList = [product_name], 
       sourceExpressionList = [`product_name` || 'calcite'], 
       condition = `product_id` > 10,
       sourceSelect = "SELECT *, `product_name` || 'calcite' AS `EXPR$0` FROM `foodmart`.`product` WHERE `product_id` > 10"
   )
   ```
   
   Next, `SqlToRelConverter` converts it into this logical plan:
   ```
   LogicalTableModify(
     table=[[foodmart, product]], operation=[UPDATE], 
     updateColumnList=[[product_name]], 
     sourceExpressionList=[[CAST(||($3, 'calcite')):VARCHAR(60) NOT NULL]], 
     flattened=[true]
   )
     LogicalProject(product_class_id=[$0], product_id=[$1], <all 14 fields>,  EXPR$0=[||($3, 'calcite')])
       LogicalFilter(condition=[>($1, 10)])
         LogicalTableScan(table=[[foodmart, product]])
   ```
   
   `LogicalTableModify.sourceExpressionList` is built using the blackboard from LogicalProject, but it doesn’t use expressions directly from `LogicalProject`. (This is one more reason my previous fix was incorrect. It lost type coercion in this case).
   
   Now, answer on your question: "What is this SqlSelect node"
   
   `RelToSqlConverter` transforms `TableModify.input` into:
   ```
   SELECT `product_class_id`, `product_id`, `brand_name`, `product_name`, `SKU`, `SRP`, `gross_weight`, `net_weight`, `recyclable_package`, `low_fat`, `units_per_case`, `cases_per_pallet`, `shelf_width`, `shelf_height`, `shelf_depth`, `product_name` || 'calcite' AS `EXPR$0`
   FROM `foodmart`.`product`
   WHERE `product_id` > 10
   ```
   
   Calcite code takes the WHERE clause for the UPDATE from this SELECT. We also need to convert `TableModify.sourceExpressionList` into a SqlNode based on the context of this SELECT (as we do when we convert SqlNode to RelNode). My current fix use this approach



-- 
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-7220] RelToSqlConverter throws exception for UPDATE with self-referencing column in SET [calcite]

Posted by "dssysolyatin (via GitHub)" <gi...@apache.org>.
dssysolyatin commented on code in PR #4572:
URL: https://github.com/apache/calcite/pull/4572#discussion_r2415025967


##########
core/src/main/java/org/apache/calcite/rel/rel2sql/RelToSqlConverter.java:
##########
@@ -1141,16 +1138,21 @@ public Result visit(TableModify modify) {
       return result(sqlInsert, ImmutableList.of(), modify, null);
     }
     case UPDATE: {
+      final List<String> updateColumnList =
+          requireNonNull(modify.getUpdateColumnList(),
+              () -> "modify.getUpdateColumnList() is null for " + modify);
       final Result input = visitInput(modify, 0);
+      final SqlSelect sourceSelect = input.asSelect();
+      final SqlNodeList expressionList = sourceSelect.getSelectList()

Review Comment:
   Although, It works, but it depends on the TableModify.input being built in a specific way. (Also `MERGE` work in the same way).
   
   A better approach might be to pass into `exprList` aliasContext which looks like
   ```
   exprList(aliasContext(ImmutableMap("p", modify.getRowType().get), false), modify.getSourceExpressionList())
   ```
   and rely on ModifyTable.getExpressionList() instead



-- 
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-7220] RelToSqlConverter throws exception for UPDATE with self-referencing column in SET [calcite]

Posted by "dssysolyatin (via GitHub)" <gi...@apache.org>.
dssysolyatin commented on code in PR #4572:
URL: https://github.com/apache/calcite/pull/4572#discussion_r2415025967


##########
core/src/main/java/org/apache/calcite/rel/rel2sql/RelToSqlConverter.java:
##########
@@ -1141,16 +1138,21 @@ public Result visit(TableModify modify) {
       return result(sqlInsert, ImmutableList.of(), modify, null);
     }
     case UPDATE: {
+      final List<String> updateColumnList =
+          requireNonNull(modify.getUpdateColumnList(),
+              () -> "modify.getUpdateColumnList() is null for " + modify);
       final Result input = visitInput(modify, 0);
+      final SqlSelect sourceSelect = input.asSelect();
+      final SqlNodeList expressionList = sourceSelect.getSelectList()

Review Comment:
   Although, It works, but it depends on the TableModify.input being built in a specific way. (Also merge work in the same way).
   
   A better approach might be to pass into `exprList` aliasContext which looks like
   ```
   aliasContext(ImmutableMap("p", modify.getRowType().get), false)
   ```
   and rely on ModifyTable.getExpressionList() instead



-- 
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-7220] RelToSqlConverter throws exception for UPDATE with self-referencing column in SET [calcite]

Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #4572:
URL: https://github.com/apache/calcite/pull/4572#issuecomment-3383184992

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=4572) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [2 New issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=4572&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=4572&issueStatuses=ACCEPTED)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_calcite&pullRequest=4572&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [90.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=4572&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=4572&metric=new_duplicated_lines_density&view=list)  
     
   [See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=4572)
   
   


-- 
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