Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,11 @@ public MssqlSqlDialect(Context context) {
throw new IllegalArgumentException("MSSQL SUBSTRING requires FROM and FOR arguments");
}
SqlUtil.unparseFunctionSyntax(MSSQL_SUBSTRING, writer, call, false);
} else if (call.getOperator().equals(SqlStdOperatorTable.CEIL)) {
// CEILING is supported but not CEIL in MS SQL
final SqlWriter.Frame frame = writer.startFunCall("CEILING");
call.operand(0).unparse(writer, leftPrec, rightPrec);
writer.endFunCall(frame);
} else {
switch (call.getKind()) {
case FLOOR:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8696,6 +8696,18 @@ private void checkLiteral2(String expression, String expected) {
sql(query).withPostgresql().ok(expectedQuery);
}

/** Test case for
* <a href="https://issues.apache.org/jira/browse/CALCITE-6633">[CALCITE-6633]
* MSSQL Dialect does not generate CEILING function</a>.
*/
@Test void testMSSQLCeiling() {
final String query = "select 1.24, FLOOR(1.24), CEILING(1.24)";
final String mssqlExpected = "SELECT 1.24, FLOOR(1.24), CEILING(1.24)\n"
+ "FROM (VALUES (0)) AS [t] ([ZERO])";
sql(query)
.dialect(MssqlSqlDialect.DEFAULT).ok(mssqlExpected);
}

/** Fluid interface to run tests. */
static class Sql {
private final CalciteAssert.SchemaSpec schemaSpec;
Expand Down