This is an automated email from the ASF dual-hosted git repository.
zhehu 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 ed66fcd26c [CALCITE-6818] Write LIMIT for fetch operations in Snowflake
ed66fcd26c is described below
commit ed66fcd26c983fe7947ae95d88200cc0cf15e3ab
Author: xuyu <[email protected]>
AuthorDate: Fri Feb 7 17:47:29 2025 +0800
[CALCITE-6818] Write LIMIT for fetch operations in Snowflake
---
.../java/org/apache/calcite/sql/dialect/SnowflakeSqlDialect.java | 7 +++++++
.../java/org/apache/calcite/rel/rel2sql/RelToSqlConverterTest.java | 7 ++++++-
2 files changed, 13 insertions(+), 1 deletion(-)
diff --git
a/core/src/main/java/org/apache/calcite/sql/dialect/SnowflakeSqlDialect.java
b/core/src/main/java/org/apache/calcite/sql/dialect/SnowflakeSqlDialect.java
index 9686a9ec1b..9deb0836ee 100644
--- a/core/src/main/java/org/apache/calcite/sql/dialect/SnowflakeSqlDialect.java
+++ b/core/src/main/java/org/apache/calcite/sql/dialect/SnowflakeSqlDialect.java
@@ -29,6 +29,8 @@
import org.apache.calcite.sql.parser.SqlParserPos;
import org.apache.calcite.sql.type.SqlTypeName;
+import org.checkerframework.checker.nullness.qual.Nullable;
+
/**
* A <code>SqlDialect</code> implementation for the Snowflake database.
*/
@@ -105,6 +107,11 @@ public static SqlNode rewriteMaxMin(SqlNode aggCall,
RelDataType relDataType) {
return aggCall;
}
+ @Override public void unparseOffsetFetch(SqlWriter writer, @Nullable SqlNode
offset,
+ @Nullable SqlNode fetch) {
+ unparseFetchUsingLimit(writer, offset, fetch);
+ }
+
@Override public boolean supportsApproxCountDistinct() {
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 6004fec86a..d744247e4a 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
@@ -3012,13 +3012,18 @@ private SqlDialect nonOrdinalDialect() {
+ "FROM `foodmart`.`product`\n"
+ "LIMIT 100\n"
+ "OFFSET 10";
+ final String expectedSnowflake = "SELECT \"product_id\"\n"
+ + "FROM \"foodmart\".\"product\"\n"
+ + "LIMIT 100\n"
+ + "OFFSET 10";
final String expectedVertica = "SELECT \"product_id\"\n"
+ "FROM \"foodmart\".\"product\"\n"
+ "LIMIT 100\n"
+ "OFFSET 10";
sql(query).withHive().ok(expected)
.withVertica().ok(expectedVertica)
- .withStarRocks().ok(expectedStarRocks);
+ .withStarRocks().ok(expectedStarRocks)
+ .withSnowflake().ok(expectedSnowflake);
}
@Test void testPositionFunctionForHive() {