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 @@ -212,6 +212,11 @@
final SqlWriter.Frame frame = writer.startFunCall("CEILING");
call.operand(0).unparse(writer, leftPrec, rightPrec);
writer.endFunCall(frame);
} else if (call.getOperator().equals(SqlStdOperatorTable.CONCAT)) {
// MSSQL has no || operator. + concatenates and propagates NULL, as ||

Check warning on line 216 in core/src/main/java/org/apache/calcite/sql/dialect/MssqlSqlDialect.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

This block of commented-out lines of code should be removed.

See more on https://sonarcloud.io/project/issues?id=apache_calcite&issues=AaCWSBDHd3KmLy87CPZL&open=AaCWSBDHd3KmLy87CPZL&pullRequest=5258
// does; the CONCAT function does not, reading a NULL operand as ''.
SqlSyntax.BINARY.unparse(writer, SqlStdOperatorTable.PLUS, call, leftPrec,
rightPrec);
} else {
switch (call.getKind()) {
case FLOOR:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11820,6 +11820,15 @@ private void checkLiteral2(String expression, String expected) {
sql(query).dialect(MssqlSqlDialect.DEFAULT).ok(mssqlExpected);
}

/** Test case for
* <a href="https://issues.apache.org/jira/browse/CALCITE-7777">[CALCITE-7777]
* JDBC adapter generates || for concatenation, which SQL Server rejects</a>. */
@Test void testConcatOperatorEmulationForMSSQL() {
final String query = "select \"brand_name\" || \"product_name\" from \"product\"";
final String mssqlExpected = "SELECT [brand_name] + [product_name]\n"
+ "FROM [foodmart].[product]";
sql(query).withMssql().ok(mssqlExpected);
}

/** Test case for
* <a href="https://issues.apache.org/jira/browse/CALCITE-6655">[CALCITE-6655]
Expand Down
Loading