Copilot commented on code in PR #6658:
URL: https://github.com/apache/hive/pull/6658#discussion_r3763990285


##########
ql/src/java/org/apache/hadoop/hive/ql/ddl/table/partition/add/AlterViewAddPartitionAnalyzer.java:
##########
@@ -97,4 +105,12 @@ protected void postProcess(TableName tableName, Table 
table, AlterTableAddPartit
       inputs.addAll(driver.getPlan().getInputs());
     }
   }
+
+  private static String formatPartitionLiteral(FieldSchema partCol, String 
partSpecValue) {
+    TypeInfo typeInfo = 
TypeInfoFactory.getPrimitiveTypeInfo(partCol.getType());
+    ObjectInspector partColOI = 
TypeInfoUtils.getStandardJavaObjectInspectorFromTypeInfo(typeInfo);
+    Object converted = ObjectInspectorConverters.getConverter(
+        PrimitiveObjectInspectorFactory.javaStringObjectInspector, 
partColOI).convert(partSpecValue);
+    return new ExprNodeConstantDesc(typeInfo, converted).getExprString();
+  }

Review Comment:
   formatPartitionLiteral() relies on ExprNodeConstantDesc#getExprString() to 
render string/char/varchar literals, but that method does not escape embedded 
quotes/backslashes (it just wraps the raw value in single quotes). Since 
partition spec values are normalized to their Java string form during part-spec 
validation, a value containing a single quote (e.g. O'Reilly) would produce 
invalid SQL in VIEW_VALIDATE_QUERY and fail compilation.
   
   Consider special-casing string-like partition columns to keep the old 
escaping behavior (HiveUtils.escapeString) and only use ExprNodeConstantDesc 
for non-string primitives.



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to