lirui-apache commented on a change in pull request #11935:
URL: https://github.com/apache/flink/pull/11935#discussion_r422600078



##########
File path: 
flink-table/flink-sql-parser-hive/src/main/java/org/apache/flink/sql/parser/hive/ddl/HiveDDLUtils.java
##########
@@ -91,4 +154,149 @@ public static SqlTableOption toTableOption(String key, 
SqlNode value, SqlParserP
        public static SqlTableOption toTableOption(String key, String value, 
SqlParserPos pos) {
                return new SqlTableOption(SqlLiteral.createCharString(key, 
pos), SqlLiteral.createCharString(value, pos), pos);
        }
+
+       public static void convertDataTypes(SqlNodeList columns) {
+               if (columns != null) {
+                       for (SqlNode node : columns) {
+                               convertDataTypes((SqlTableColumn) node);
+                       }
+               }
+       }
+
+       // data types may need to be converted to comply with HiveQL, e.g. 
TIMESTAMP and BINARY
+       public static void convertDataTypes(SqlTableColumn column) {
+               column.setType(convertDataTypes(column.getType()));
+       }
+
+       private static SqlDataTypeSpec convertDataTypes(SqlDataTypeSpec 
typeSpec) {
+               SqlTypeNameSpec nameSpec = typeSpec.getTypeNameSpec();
+               SqlTypeNameSpec convertedNameSpec = convertDataTypes(nameSpec);
+               if (nameSpec != convertedNameSpec) {
+                       typeSpec = new SqlDataTypeSpec(convertedNameSpec, 
typeSpec.getTimeZone(), typeSpec.getNullable(),
+                                       typeSpec.getParserPosition());
+               }
+               return typeSpec;
+       }
+
+       private static SqlTypeNameSpec convertDataTypes(SqlTypeNameSpec 
nameSpec) {
+               if (nameSpec instanceof SqlBasicTypeNameSpec) {
+                       SqlBasicTypeNameSpec basicNameSpec = 
(SqlBasicTypeNameSpec) nameSpec;
+                       if 
(basicNameSpec.getTypeName().getSimple().equalsIgnoreCase(SqlTypeName.TIMESTAMP.name()))
 {
+                               if (basicNameSpec.getPrecision() < 0) {

Review comment:
       But I can't get `SqlTypeName` from a `SqlBasicTypeNameSpec`




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to