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 2021/04/27 05:14:42 UTC

[GitHub] [calcite] amandeep-sharma opened a new pull request #2407: [CALCITE-4592] Populate correlation context for Join in RelToSqlConve…

amandeep-sharma opened a new pull request #2407:
URL: https://github.com/apache/calcite/pull/2407


   …rter
   
   Correlation context is populated in RelToSqlConverter for the followings:
   - Project
   - Filter
   - Calc
   - Correlate
   
   But it is not populated for Join. Because of it, using joiner's correlation id causes below exception
   
   `Caused by:
   java.lang.NullPointerException
       at org.apache.calcite.rel.rel2sql.SqlImplementor$Context.toSql(SqlImplementor.java:506)
       at org.apache.calcite.rel.rel2sql.SqlImplementor$Context.toSql(SqlImplementor.java:828)
       at org.apache.calcite.rel.rel2sql.SqlImplementor$Context.toSql(SqlImplementor.java:668)
       at org.apache.calcite.rel.rel2sql.SqlImplementor$Context.toSql(SqlImplementor.java:828)
       at org.apache.calcite.rel.rel2sql.SqlImplementor$Context.toSql(SqlImplementor.java:668)
       at org.apache.calcite.rel.rel2sql.RelToSqlConverter.visit(RelToSqlConverter.java:213)
       ... 65 more`


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [calcite] amandeep-sharma commented on a change in pull request #2407: [CALCITE-4592] Populate correlation context for Join in RelToSqlConve…

Posted by GitBox <gi...@apache.org>.
amandeep-sharma commented on a change in pull request #2407:
URL: https://github.com/apache/calcite/pull/2407#discussion_r623100331



##########
File path: core/src/main/java/org/apache/calcite/rel/rel2sql/RelToSqlConverter.java
##########
@@ -209,6 +209,7 @@ public Result visit(Join e) {
       break;
     }
     final Result leftResult = visitInput(e, 0).resetAlias();
+    parseCorrelTable(e, leftResult);
     final Result rightResult = visitInput(e, 1).resetAlias();

Review comment:
       Added the test 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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [calcite] chunweilei commented on a change in pull request #2407: [CALCITE-4592] Populate correlation context for Join in RelToSqlConve…

Posted by GitBox <gi...@apache.org>.
chunweilei commented on a change in pull request #2407:
URL: https://github.com/apache/calcite/pull/2407#discussion_r621754080



##########
File path: core/src/main/java/org/apache/calcite/rel/rel2sql/RelToSqlConverter.java
##########
@@ -209,6 +209,7 @@ public Result visit(Join e) {
       break;
     }
     final Result leftResult = visitInput(e, 0).resetAlias();
+    parseCorrelTable(e, leftResult);
     final Result rightResult = visitInput(e, 1).resetAlias();

Review comment:
       Could you please add a test 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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [calcite] amandeep-sharma commented on pull request #2407: [CALCITE-4592] Populate correlation context for Join in RelToSqlConve…

Posted by GitBox <gi...@apache.org>.
amandeep-sharma commented on pull request #2407:
URL: https://github.com/apache/calcite/pull/2407#issuecomment-856483105


   > Good day!
   > Found out that this query produces same exception (`java.lang.NullPointerException: variable $cor0 is not found`)
   > query:
   > `SELECT t.id, (select b.id FROM tbl2 AS b WHERE b.id = t.id) FROM tbl1 as t`
   > it parsed/validated successfully, but can't be converted back to sql.
   > Can it be fixed in this pr or it is another issue?
   
   @FDoKE It seems that your use case is correlating the sub-query with `Project`. It is different from the PR use-case which is correlating the sub-query with `Join`.
   Correlating the sub-query is supported only with `Correlate`, `LogicalFilter` and `Join`, as of now. Support for correlating`Project` is doable, but I would prefer to make those changes in a separate PR.


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [calcite] amandeep-sharma edited a comment on pull request #2407: [CALCITE-4592] Populate correlation context for Join in RelToSqlConve…

Posted by GitBox <gi...@apache.org>.
amandeep-sharma edited a comment on pull request #2407:
URL: https://github.com/apache/calcite/pull/2407#issuecomment-856483105


   > Good day!
   > Found out that this query produces same exception (`java.lang.NullPointerException: variable $cor0 is not found`)
   > query:
   > `SELECT t.id, (select b.id FROM tbl2 AS b WHERE b.id = t.id) FROM tbl1 as t`
   > it parsed/validated successfully, but can't be converted back to sql.
   > Can it be fixed in this pr or it is another issue?
   
   @FDoKE It seems that your use case is correlating the sub-query with `Project`. It is different from the PR use-case which is correlating the sub-query with `Join`.
   Correlating the sub-query is supported only with `Correlate` and `LogicalFilter`; `Join` is being added in this PR. Support for correlating`Project` is doable, but I would prefer to make those changes in a separate PR.


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [calcite] FDoKE commented on pull request #2407: [CALCITE-4592] Populate correlation context for Join in RelToSqlConve…

Posted by GitBox <gi...@apache.org>.
FDoKE commented on pull request #2407:
URL: https://github.com/apache/calcite/pull/2407#issuecomment-855658818


   Good day! 
   Found out that this query produces same exception (`java.lang.NullPointerException: variable $cor0 is not found`)
   query:
   `SELECT t.id, (select b.id FROM tbl2 AS b WHERE b.id = t.id) FROM tbl1 as t`
   it parsed/validated successfully, but can't be converted back to sql.
   Can it be fixed in this pr or it is another issue?


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org