zihaoAK47 commented on code in PR #30670:
URL: https://github.com/apache/shardingsphere/pull/30670#discussion_r1542251723


##########
kernel/sql-federation/optimizer/src/main/java/org/apache/shardingsphere/sqlfederation/optimizer/converter/segment/projection/impl/DataTypeConverter.java:
##########
@@ -45,7 +45,12 @@ public static Optional<SqlNode> convert(final 
DataTypeSegment segment) {
         if (null == segment) {
             return Optional.empty();
         }
-        return Optional.of(new SqlDataTypeSpec(new 
SqlBasicTypeNameSpec(Objects.requireNonNull(SqlTypeName.get(segment.getDataTypeName())),
 segment.getDataLength().getPrecision(), SqlParserPos.ZERO),
-                SqlParserPos.ZERO));
+        return Optional.of(new 
SqlDataTypeSpec(getSqlBasicTypeNameSpec(segment), SqlParserPos.ZERO));
+    }
+    
+    private static SqlBasicTypeNameSpec getSqlBasicTypeNameSpec(final 
DataTypeSegment segment) {

Review Comment:
   Hi mentor, the issue arises from executing the cast function in a federated 
query scenario. I tried to add the following statement to the e2e process:
   "select cast(1 as char)"
   This SQL statement will result in incorrect column types error in the JDBC 
scenario, causing the e2e process to fail.
   
   I tried the following other SQL statements, but the result obtained from 
executing e2e is different from the function executed on MySQL:
   select cast("2024-03-28" as date)
   Expected :2024-03-28
   Actual   :19810



##########
parser/sql/statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/segment/generic/DataTypeLengthSegment.java:
##########
@@ -36,8 +36,9 @@ public final class DataTypeLengthSegment implements 
SQLSegment {
     private int scale;
     
     /**
-     * get secondNumber.
-     * @return Optional.
+     * Get second number.

Review Comment:
   Format method comments :smile: 



-- 
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: notifications-unsubscr...@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to