SourabhBadhya commented on code in PR #4672:
URL: https://github.com/apache/hive/pull/4672#discussion_r1338044197


##########
ql/src/java/org/apache/hadoop/hive/ql/ddl/table/misc/truncate/TruncateTableAnalyzer.java:
##########
@@ -338,4 +377,34 @@ private void addStatTask(ASTNode root, Table table, Path 
oldPartitionLocation, P
       moveTask.addDependentTask(statTask);
     }
   }
+
+  public StringBuilder constructDeleteQuery(String qualifiedTableName, Table 
table, Map<String, String> partitionSpec)
+      throws SemanticException {
+    StringBuilder sb = new StringBuilder().append("delete from 
").append(qualifiedTableName)
+            .append(" where ");
+    boolean first = true;
+    for (String key : partitionSpec.keySet()) {
+      ColumnInfo columnInfo = table.getStorageHandler().getColumnType(table, 
key);
+      if (columnInfo.getObjectInspector() instanceof PrimitiveObjectInspector) 
{
+        PrimitiveObjectInspector primitiveObjInspector = 
(PrimitiveObjectInspector) columnInfo.getObjectInspector();
+        String value = partitionSpec.get(key);
+        boolean shouldEncloseQuotes = 
TypeInfoUtils.shouldEncloseQuotes(primitiveObjInspector.getPrimitiveCategory());
+        if (value != null) {
+          sb.append(first ? "" : " and 
").append(HiveUtils.unparseIdentifier(key, conf)).append(" = ");
+          if (shouldEncloseQuotes) {

Review Comment:
   Done.



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