This is an automated email from the ASF dual-hosted git repository.
mihaibudiu 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 55d2e3b72f [CALCITE-7774] JDBC adapter generates a GROUP BY with a
constant key, which SQL Server rejects
55d2e3b72f is described below
commit 55d2e3b72f6ec828d27f0c4f5792948d924be501
Author: Jerome Haltom <[email protected]>
AuthorDate: Sat Sep 12 09:13:45 2026 -0500
[CALCITE-7774] JDBC adapter generates a GROUP BY with a constant key, which
SQL Server rejects
---
.../java/org/apache/calcite/sql/dialect/MssqlSqlDialect.java | 4 ++++
.../apache/calcite/rel/rel2sql/RelToSqlConverterTest.java | 12 ++++++++++--
2 files changed, 14 insertions(+), 2 deletions(-)
diff --git
a/core/src/main/java/org/apache/calcite/sql/dialect/MssqlSqlDialect.java
b/core/src/main/java/org/apache/calcite/sql/dialect/MssqlSqlDialect.java
index 7a45559284..2cea9608d0 100644
--- a/core/src/main/java/org/apache/calcite/sql/dialect/MssqlSqlDialect.java
+++ b/core/src/main/java/org/apache/calcite/sql/dialect/MssqlSqlDialect.java
@@ -275,6 +275,10 @@ private static SqlNode createDatetimeCastSpec(String
typeAlias, RelDataType type
return false;
}
+ @Override public boolean supportsGroupByLiteral() {
+ return false;
+ }
+
@Override public boolean supportsGroupByWithRollup() {
return true;
}
diff --git
a/core/src/test/java/org/apache/calcite/rel/rel2sql/RelToSqlConverterTest.java
b/core/src/test/java/org/apache/calcite/rel/rel2sql/RelToSqlConverterTest.java
index 8e43c4400d..e854771afc 100644
---
a/core/src/test/java/org/apache/calcite/rel/rel2sql/RelToSqlConverterTest.java
+++
b/core/src/test/java/org/apache/calcite/rel/rel2sql/RelToSqlConverterTest.java
@@ -590,9 +590,13 @@ private static RelNode sqlToRel(String sql, SchemaPlus
defaultSchema,
+ "(SELECT TRUE AS \"$f0\") AS \"t\"\nGROUP BY \"t\".\"$f0\"";
String expectedInformix = "SELECT AVG(employee.salary)\nFROM
foodmart.employee,"
+ "\n(SELECT TRUE AS $f0) AS t\nGROUP BY t.$f0";
+ String expectedMssql = "SELECT AVG([employee].[salary])\n"
+ + "FROM [foodmart].[employee],\n"
+ + "(VALUES (1)) AS [t] ([$f0])\nGROUP BY [t].[$f0]";
sql(query)
.withRedshift().ok(expectedRedshift)
- .withInformix().ok(expectedInformix);
+ .withInformix().ok(expectedInformix)
+ .withMssql().ok(expectedMssql);
}
/** Test case for
@@ -669,9 +673,13 @@ private static RelNode sqlToRel(String sql, SchemaPlus
defaultSchema,
+ "(SELECT DATE '2022-01-01' AS \"$f0\") AS \"t\"\nGROUP BY
\"t\".\"$f0\"";
String expectedInformix = "SELECT AVG(employee.salary)\nFROM
foodmart.employee,"
+ "\n(SELECT DATE '2022-01-01' AS $f0) AS t\nGROUP BY t.$f0";
+ String expectedMssql = "SELECT AVG([employee].[salary])\n"
+ + "FROM [foodmart].[employee],\n"
+ + "(VALUES ('2022-01-01')) AS [t] ([$f0])\nGROUP BY [t].[$f0]";
sql(query)
.withRedshift().ok(expectedRedshift)
- .withInformix().ok(expectedInformix);
+ .withInformix().ok(expectedInformix)
+ .withMssql().ok(expectedMssql);
}
@Test void testSimpleSelectStarFromProductTable() {