deniskuzZ commented on code in PR #4453:
URL: https://github.com/apache/hive/pull/4453#discussion_r1245081331
##########
ql/src/java/org/apache/hadoop/hive/ql/parse/LoadSemanticAnalyzer.java:
##########
@@ -291,18 +291,43 @@ private void analyzeLoad(ASTNode ast) throws
SemanticException {
ErrorMsg.INVALID_PATH.getMsg(), fromTree, e.getMessage()), e);
}
+ Map<String, String> tmpPartSpec = null;
+ Table table;
+ try {
+ table =
db.getTable(HiveTableName.withNoDefault(getUnescapedName((ASTNode)
tableTree.getChild(0))));
+ } catch (HiveException e) {
+ throw new SemanticException(
+
ASTErrorUtils.getMsg(ErrorMsg.CANNOT_RETRIEVE_TABLE_METADATA.getMsg(),
tableTree.getChild(0), e.getMessage()),
+ e);
+ }
+
+ if (tableTree.getChildCount() == 2 && table.isNonNative() &&
table.getStorageHandler() != null &&
+ table.getStorageHandler().supportsAppendData(table.getTTable(), true))
{
+ ASTNode partspec = (ASTNode) tableTree.getChild(1);
+ // partSpec is a mapping from partition column name to its value.
+ tmpPartSpec = new HashMap<String, String>(partspec.getChildCount());
+ for (int i = 0; i < partspec.getChildCount(); ++i) {
+ ASTNode partspec_val = (ASTNode) partspec.getChild(i);
+ String val = null;
+ String colName =
unescapeIdentifier(partspec_val.getChild(0).getText().toLowerCase());
+ val = stripQuotes(partspec_val.getChild(1).getText());
+ tmpPartSpec.put(colName, val);
+ tableTree.deleteChild(1);
Review Comment:
should this be outside of for loop? also looks like this snippet is used in
multiple places, could we reuse it
````
if (tableTree.getChildCount() >= 2) {
ASTNode partSpecNode = (ASTNode) tableTree.getChild(1);
inpPartSpec = new HashMap<>(partSpecNode.getChildCount());
for (int i = 0; i < partSpecNode.getChildCount(); ++i) {
ASTNode partSpecValNode = (ASTNode) partSpecNode.getChild(i);
String partVal = null;
String partColName =
unescapeIdentifier(partSpecValNode.getChild(0).getText().toLowerCase());
if (partSpecValNode.getChildCount() >= 2) { // in the form of T
partition (ds="2010-03-03")
// Not stripping quotes here as we need to use it as it is while
framing PARTITION clause
// in INSERT query.
partVal = partSpecValNode.getChild(1).getText();
}
inpPartSpec.put(partColName, partVal);
}
````
--
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]