Skip to content

Commit

Permalink
[CALCITE-6818] Write LIMIT for fetch operations in Snowflake
Browse files Browse the repository at this point in the history
  • Loading branch information
xuyu authored and ILuffZhe committed Feb 10, 2025
1 parent e59ed95 commit ed66fcd
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit ed66fcd

Please sign in to comment.