You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by GitBox <gi...@apache.org> on 2022/12/18 02:08:42 UTC

[GitHub] [calcite] JiajunBernoulli commented on a diff in pull request #2968: [CALCITE-5354] JDBC with UNNEST not working

JiajunBernoulli commented on code in PR #2968:
URL: https://github.com/apache/calcite/pull/2968#discussion_r1051511326


##########
core/src/main/java/org/apache/calcite/sql2rel/SqlToRelConverter.java:
##########
@@ -2442,18 +2472,27 @@ private void convertUnnest(Blackboard bb, SqlCall call, @Nullable List<String> f
     });
     RelNode child =
         (null != bb.root) ? bb.root : LogicalValues.createOneRow(cluster);
+
+    RelNode newChild;
+    final CorrelationUse correlationUse = getCorrelationUse(bb, child);
+    if (correlationUse != null && !(child instanceof Collect)) {
+      newChild = addCorrelation(child, correlationUse, relBuilder);

Review Comment:
   Yes, I made a mistake. Origin plan should be
   ```
   EnumerableCalc(expr#0..25=[{inputs}], proj#0..23=[{exprs}], EXPR$0=[$t25]): rowcount = 100.0, cumulative cost = {780.0 rows, 7501.0 cpu, 0.0 io}, id = 161
     EnumerableCorrelate(correlation=[$cor0], joinType=[inner], requiredColumns=[{24}]): rowcount = 100.0, cumulative cost = {680.0 rows, 2401.0 cpu, 0.0 io}, id = 157
       JdbcToEnumerableConverter: rowcount = 100.0, cumulative cost = {190.0 rows, 2111.0 cpu, 0.0 io}, id = 148
         JdbcProject(store_id=[$0], store_type=[$1], region_id=[$2], store_name=[$3], store_number=[$4], store_street_address=[$5], store_city=[$6], store_state=[$7], store_postal_code=[$8], store_country=[$9], store_manager=[$10], store_phone=[$11], store_fax=[$12], first_opened_date=[$13], last_remodel_date=[$14], store_sqft=[$15], grocery_sqft=[$16], frozen_sqft=[$17], meat_sqft=[$18], coffee_bar=[$19], video_store=[$20], salad_bar=[$21], prepared_food=[$22], florist=[$23], $f24=[ARRAY($0)]): rowcount = 100.0, cumulative cost = {180.0 rows, 2101.0 cpu, 0.0 io}, id = 146
           JdbcTableScan(table=[[foodmart, store]]): rowcount = 100.0, cumulative cost = {100.0 rows, 101.0 cpu, 0.0 io}, id = 1
       EnumerableUncollect: rowcount = 1.0, cumulative cost = {2.9000000000000004 rows, 2.9000000000000004 cpu, 0.0 io}, id = 155
         JdbcToEnumerableConverter: rowcount = 1.0, cumulative cost = {1.9000000000000001 rows, 1.9000000000000001 cpu, 0.0 io}, id = 153
           JdbcProject(EXPR$0=[$cor0.$f24]): rowcount = 1.0, cumulative cost = {1.8 rows, 1.8 cpu, 0.0 io}, id = 151
             JdbcValues(tuples=[[{ 0 }]]): rowcount = 1.0, cumulative cost = {1.0 rows, 1.0 cpu, 0.0 io}, id = 116
   ```
   
   `JdbcToEnumerableConverter` create a new `JdbcImplementor` that extends `RelToSqlConverter`. **Root cause is the new  `RelToSqlConverter` doesn't have  correlation variable.**
   
   In my option, we should FORCE_DECORRELATE in JdbcAdapter so that JdbcToEnumerableConverter can generate SQL independently.
   



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