mihaibudiu commented on code in PR #4445:
URL: https://github.com/apache/calcite/pull/4445#discussion_r2254812571
##########
core/src/main/java/org/apache/calcite/sql/dialect/DorisSqlDialect.java:
##########
@@ -69,4 +73,15 @@ public DorisSqlDialect(Context context) {
break;
}
}
+
+ @Override public @Nullable SqlNode getCastSpec(RelDataType type) {
+ switch (type.getSqlTypeName()) {
+ case UINTEGER:
Review Comment:
there are actually 4 unsigned types
##########
core/src/main/java/org/apache/calcite/sql/dialect/MysqlSqlDialect.java:
##########
@@ -196,6 +196,14 @@ public MysqlSqlDialect(Context context) {
type.getSqlTypeName(),
SqlParserPos.ZERO),
SqlParserPos.ZERO);
+ case UINTEGER:
Review Comment:
this looks suspicious; why would UBIGINT be converted to UNSIGNED? This
suggests information loss. How about the other two unsigned types?
##########
core/src/test/java/org/apache/calcite/rel/rel2sql/RelToSqlConverterTest.java:
##########
@@ -3564,6 +3564,24 @@ private SqlDialect nonOrdinalDialect() {
.withDoris().ok(expectedStarRocks);
}
+ /** Test case for
+ * <a
href="https://issues.apache.org/jira/browse/CALCITE-7069">[CALCITE-7069]
+ * Invalid unparse for INT UNSIGNED and BIGINT UNSIGNED in
MysqlSqlDialect</a>. */
+ @Test void testCastToUnsignedInMySQL() {
+ final String query1 = "select cast(\"product_id\" as bigint unsigned) from
\"product\"";
+ // MySQL does not allow cast to BIGINT UNSIGNED; instead cast to UNSIGNED.
+ final String expectedMysql1 = "SELECT CAST(`product_id` AS UNSIGNED)\n"
+ + "FROM `foodmart`.`product`";
+ final String query2 = "select cast(\"product_id\" as integer unsigned)
from \"product\"";
+ // MySQL does not allow cast to INTEGER UNSIGNED; instead cast to UNSIGNED.
Review Comment:
only if the result is the same. Maybe cast to UNSIGNED actually truncates
the result - then the result is not the same.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]