[
https://issues.apache.org/jira/browse/CALCITE-7085?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17998275#comment-17998275
]
Viggo Chen commented on CALCITE-7085:
-------------------------------------
And according to the [reference of
Oracle|https://docs.oracle.com/javadb/10.8.2.2/ref/rrefsqljusing.html], its
handling of columns in the USING clause is also slightly different from
Calcite's default approach.
{quote}If a column in the USING clause is referenced without being qualified by
a table name, the column reference points to the column in the first (left)
table if the join is an INNER JOIN or a LEFT OUTER JOIN. If it is a RIGHT OUTER
JOIN, unqualified references to a column in the USING clause point to the
column in the second (right) table.
{quote}
> JOIN USING with unqualified common column fails in a conformance where
> allowQualifyingCommonColumn is false (e.g. Oracle, Presto)
> ---------------------------------------------------------------------------------------------------------------------------------
>
> Key: CALCITE-7085
> URL: https://issues.apache.org/jira/browse/CALCITE-7085
> Project: Calcite
> Issue Type: Bug
> Reporter: Viggo Chen
> Priority: Major
>
> SeeĀ SqlToRelConverterTest [test case
> |https://github.com/apache/calcite/commit/7990aa521103f4af1f690dd5152b972f69df0a0b]
> {code:java}
> // FIXME: fails with "Cannot qualify common column 'EMP.DEPTNO'"
> @Test void
> testJoinUsingWithUnqualifiedCommonColumnWhenDisallowsQualifyingCommonColumn()
> {
> final String sql = "SELECT deptno, name\n"
> + "FROM emp JOIN dept using (deptno)";
> sql(sql).withConformance(SqlConformanceEnum.ORACLE_10).ok();
> } {code}
> deptno is expanded to COALESCE(`EMP`.`DEPTNO`, `DEPT`.`DEPTNO`) AS `DEPTNO`
> and fails because ORACLE disallows qualifying common column
--
This message was sent by Atlassian Jira
(v8.20.10#820010)