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



##########
File path: 
flink-table/flink-sql-parser-hive/src/main/java/org/apache/flink/sql/parser/hive/ddl/HiveDDLUtils.java
##########
@@ -317,4 +321,54 @@ public static SqlTableColumn 
deepCopyTableColumn(SqlTableColumn column) {
                                column.getParserPosition()
                );
        }
+
+       // the input of sql-client will escape '\', unescape it so that users 
can write hive dialect
+       public static void unescapeProperties(SqlNodeList properties) {
+               if (properties != null) {
+                       for (int i = 0; i < properties.size(); i++) {
+                               SqlNode node = properties.get(i);
+                               // for properties
+                               if (node instanceof SqlTableOption) {
+                                       node = 
unescapeTableOption((SqlTableOption) node);
+                                       properties.set(i, node);
+                               }
+                       }
+               }
+       }
+
+       public static SqlTableOption unescapeTableOption(SqlTableOption option) 
{
+               String key = 
StringEscapeUtils.unescapeJava(option.getKeyString());
+               String val = 
StringEscapeUtils.unescapeJava(option.getValueString());
+               SqlNode keyNode = SqlLiteral.createCharString(key, 
option.getKey().getParserPosition());
+               SqlNode valNode = SqlLiteral.createCharString(val, 
option.getValue().getParserPosition());
+               return new SqlTableOption(keyNode, valNode, 
option.getParserPosition());
+       }
+
+       public static SqlCharStringLiteral unescapeLiteral(SqlCharStringLiteral 
literal) {
+               if (literal != null) {
+                       String unescaped = 
StringEscapeUtils.unescapeJava(literal.getNlsString().getValue());
+                       return SqlLiteral.createCharString(unescaped, 
literal.getParserPosition());
+               }
+               return null;
+       }
+
+       public static void unescapePartitionSpec(SqlNodeList partSpec) {
+               if (partSpec != null) {
+                       for (int i = 0; i < partSpec.size(); i++) {

Review comment:
       I have changed to use SqlShuttle




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