xiedeyantu commented on code in PR #4828:
URL: https://github.com/apache/calcite/pull/4828#discussion_r2921792133


##########
core/src/test/java/org/apache/calcite/rel/rel2sql/RelToSqlConverterTest.java:
##########
@@ -11887,6 +11887,39 @@ public Sql schema(CalciteAssert.SchemaSpec schemaSpec) 
{
     sql(sql).schema(CalciteAssert.SchemaSpec.JDBC_SCOTT).ok(expected);
   }
 
+  /** Test case for
+   * <a 
href="https://issues.apache.org/jira/browse/CALCITE-7440";>[CALCITE-7440]
+   * RelToSqlConverter throws NPE when correlation scope is missing after
+   * semi-join rewrites.</a>. */
+  @Test void testPostgresqlRoundTripCorrelatedProjectWithSemiJoinRules() {

Review Comment:
   I ran this test on the main branch, and strangely it passed. Could you check 
if your case can reproduce the problem you mentioned?
   ```
     @Test void testPostgresqlRoundTripCorrelatedProjectWithSemiJoinRules() {
       final String query = "WITH product_keys AS (\n"
           + "  SELECT p.\"product_id\",\n"
           + "         (SELECT MAX(p3.\"product_id\")\n"
           + "          FROM \"foodmart\".\"product\" p3\n"
           + "          WHERE p3.\"product_id\" = p.\"product_id\") AS \"mx\"\n"
           + "  FROM \"foodmart\".\"product\" p\n"
           + ")\n"
           + "SELECT DISTINCT pk.\"product_id\"\n"
           + "FROM product_keys pk\n"
           + "LEFT JOIN \"foodmart\".\"product\" p2 USING (\"product_id\")\n"
           + "WHERE pk.\"product_id\" IN (\n"
           + "  SELECT p4.\"product_id\"\n"
           + "  FROM \"foodmart\".\"product\" p4\n"
           + ")";
   
       final RuleSet rules = RuleSets.ofList();
       final String generated = sql(query).withPostgresql().optimize(rules, 
null).exec();
       sql(generated).withPostgresql().exec();
     }
   ```



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to