This is an automated email from the ASF dual-hosted git repository.
amaliujia pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/calcite.git
The following commit(s) were added to refs/heads/master by this push:
new a8be094 [CALCITE-4207] Validation fails for positional aggregate with
current_date in 'case' expression
a8be094 is described below
commit a8be094664eddd14daf5de35bca4de8797a1d4c2
Author: Igor Guzenko <[email protected]>
AuthorDate: Wed Sep 2 09:00:57 2020 +0300
[CALCITE-4207] Validation fails for positional aggregate with current_date
in 'case' expression
---
.../org/apache/calcite/sql/validate/SqlValidatorUtil.java | 2 +-
.../test/java/org/apache/calcite/test/SqlValidatorTest.java | 13 +++++++++++++
.../test/java/org/apache/calcite/test/catalog/Fixture.java | 2 +-
3 files changed, 15 insertions(+), 2 deletions(-)
diff --git
a/core/src/main/java/org/apache/calcite/sql/validate/SqlValidatorUtil.java
b/core/src/main/java/org/apache/calcite/sql/validate/SqlValidatorUtil.java
index 2874a3c..f18c31f 100644
--- a/core/src/main/java/org/apache/calcite/sql/validate/SqlValidatorUtil.java
+++ b/core/src/main/java/org/apache/calcite/sql/validate/SqlValidatorUtil.java
@@ -846,7 +846,7 @@ public class SqlValidatorUtil {
}
}
- final int ref = lookupGroupExpr(groupAnalyzer, groupExpr);
+ final int ref = lookupGroupExpr(groupAnalyzer, expandedGroupExpr);
if (expandedGroupExpr instanceof SqlIdentifier) {
// SQL 2003 does not allow expressions of column references
SqlIdentifier expr = (SqlIdentifier) expandedGroupExpr;
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 0619e34..fc82a77 100644
--- a/core/src/test/java/org/apache/calcite/test/SqlValidatorTest.java
+++ b/core/src/test/java/org/apache/calcite/test/SqlValidatorTest.java
@@ -11684,6 +11684,19 @@ public class SqlValidatorTest extends
SqlValidatorTestCase {
+ "MYFUN\\(<NUMERIC>, <NUMERIC>\\).*");
}
+ @Test void testPositionalAggregateWithExpandedCurrentDateFunction() {
+ SqlConformance defaultPlusOrdinalGroupBy =
+ new SqlDelegatingConformance(SqlConformanceEnum.DEFAULT) {
+ @Override public boolean isGroupByOrdinal() {
+ return true;
+ }
+ };
+ sql("SELECT HIREDATE >= CURRENT_DATE, COUNT(*) "
+ + "FROM EMP GROUP BY 1")
+ .withConformance(defaultPlusOrdinalGroupBy)
+ .ok();
+ }
+
@Test void testValidatorReportsOriginalQueryUsingReader()
throws Exception {
final String sql = "select a from b";
diff --git a/core/src/test/java/org/apache/calcite/test/catalog/Fixture.java
b/core/src/test/java/org/apache/calcite/test/catalog/Fixture.java
index 4382372..92302c2 100644
--- a/core/src/test/java/org/apache/calcite/test/catalog/Fixture.java
+++ b/core/src/test/java/org/apache/calcite/test/catalog/Fixture.java
@@ -35,7 +35,7 @@ final class Fixture extends AbstractFixture {
final RelDataType bigintType = sqlType(SqlTypeName.BIGINT);
final RelDataType decimalType = sqlType(SqlTypeName.DECIMAL);
final RelDataType varcharType = sqlType(SqlTypeName.VARCHAR);
- final RelDataType varcharTypeNull = sqlType(SqlTypeName.VARCHAR);
+ final RelDataType varcharTypeNull = nullable(varcharType);
final RelDataType varchar5Type = sqlType(SqlTypeName.VARCHAR, 5);
final RelDataType varchar10Type = sqlType(SqlTypeName.VARCHAR, 10);
final RelDataType varchar10TypeNull = nullable(varchar10Type);