This is an automated email from the ASF dual-hosted git repository.
xuzifu666 pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/calcite.git
The following commit(s) were added to refs/heads/main by this push:
new 0e456518c7 [CALCITE-7084] JOINs with USING would fail when validator
identifier expansion is disabled
0e456518c7 is described below
commit 0e456518c73bb2eab48237c9bc40a7b51d9bcad5
Author: Yu Xu <[email protected]>
AuthorDate: Sat Sep 5 20:15:47 2026 +0800
[CALCITE-7084] JOINs with USING would fail when validator identifier
expansion is disabled
---
.../org/apache/calcite/sql/validate/SqlValidatorImpl.java | 9 ++++++++-
.../java/org/apache/calcite/test/SqlValidatorTest.java | 14 ++++++++++++++
2 files changed, 22 insertions(+), 1 deletion(-)
diff --git
a/core/src/main/java/org/apache/calcite/sql/validate/SqlValidatorImpl.java
b/core/src/main/java/org/apache/calcite/sql/validate/SqlValidatorImpl.java
index fdf94b9f4d..f84c3c790b 100644
--- a/core/src/main/java/org/apache/calcite/sql/validate/SqlValidatorImpl.java
+++ b/core/src/main/java/org/apache/calcite/sql/validate/SqlValidatorImpl.java
@@ -4643,11 +4643,18 @@ private static boolean
qualifiedMatchesIdentifier(SqlQualified q1, SqlQualified
private void checkRollUpInSelectList(SqlSelect select) {
SqlValidatorScope scope = getSelectScope(select);
+ final SelectScope selectScope = getRawSelectScopeNonNull(select);
+ final Expander expander = new Expander(this, selectScope);
for (SqlNode item : SqlNonNullableAccessors.getSelectList(select)) {
if (SqlValidatorUtil.isMeasure(item)) {
continue;
}
- checkRollUp(null, select, item, scope);
+ SqlNode expandedItem = expander.expandCommonColumn(select, item,
selectScope);
+ if (expandedItem instanceof SqlCall
+ && ((SqlCall) expandedItem).getOperator() instanceof SqlAsOperator) {
+ expandedItem = ((SqlCall) expandedItem).operand(0);
+ }
+ checkRollUp(null, select, expandedItem, scope);
}
}
diff --git a/core/src/test/java/org/apache/calcite/test/SqlValidatorTest.java
b/core/src/test/java/org/apache/calcite/test/SqlValidatorTest.java
index 7ba6a4d389..19005f352c 100644
--- a/core/src/test/java/org/apache/calcite/test/SqlValidatorTest.java
+++ b/core/src/test/java/org/apache/calcite/test/SqlValidatorTest.java
@@ -6237,6 +6237,20 @@ private ImmutableList<ImmutableBitSet>
cube(ImmutableBitSet... sets) {
.ok()
.withConformance(SqlConformanceEnum.ORACLE_12)
.ok();
+
+ // Unqualified common column in SELECT should succeed even when
+ // identifier expansion is disabled.
+ sql("select deptno from emp join dept using (deptno)")
+ .withValidatorIdentifierExpansion(true)
+ .ok();
+
+ sql("select deptno from emp join dept using (deptno)")
+ .withValidatorIdentifierExpansion(false)
+ .ok();
+
+ sql("select deptno from emp natural join dept")
+ .withValidatorIdentifierExpansion(false)
+ .ok();
}
/** Test case for