zzwqqq commented on code in PR #4748:
URL: https://github.com/apache/calcite/pull/4748#discussion_r2697627245
##########
core/src/test/java/org/apache/calcite/rel/rel2sql/RelToSqlConverterTest.java:
##########
@@ -6426,6 +6426,25 @@ private void checkLiteral2(String expression, String
expected) {
sql(query).withConfig(c -> c.withExpand(false)).ok(expected);
}
+ /** Test case of
+ * <a
href="https://issues.apache.org/jira/browse/CALCITE-7378">[CALCITE-7378]
+ * Potential incorrect column attribution in RelToSqlConverter due to
implicit
+ * table alias handling</a>. */
+ @Test void testSubQueryWithSelfJoin() {
+ String query = "select \"product_name\" from \"product\" t1 "
+ + "where \"product_id\" not in (select \"product_id\" "
+ + "from \"product\" t2 "
+ + "where t2.\"product_id\" = t1.\"product_id\" "
+ + "and t1.\"product_id\" = 2 and t2.\"product_id\" = 1)";
+ String expected = "SELECT \"product_name\"\n"
Review Comment:
But when i try to add a case like
```sql
select "product_name" from "product" sales_fact_1997
where "product_id" not in (
select "product_id" from "foodmart"."sales_fact_1997" sales_fact_1997_2
where "product_id" = "sales_fact_1997"."product_id" and "product_id" = 2
and "sales_fact_1997"."product_id" = 1)
```
some error occurs in validator
```
Table 'sales_fact_1997' not found; did you mean 'SALES_FACT_1997'?
```
maybe that is another issue in parser or validator
--
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]