Skip to content

Commit 8dc7809

Browse files
committed
corrected update statements
1 parent 9878ee1 commit 8dc7809

File tree

4 files changed

+13
-5
lines changed

4 files changed

+13
-5
lines changed

ql/src/java/org/apache/hadoop/hive/ql/parse/RewriteSemanticAnalyzer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ protected void checkValidSetClauseTarget(ASTNode colName, Table targetTable) thr
120120

121121
// Make sure this isn't one of the partitioning columns, that's not supported.
122122
for (FieldSchema fschema : targetTable.getPartCols()) {
123-
if (fschema.getName().equalsIgnoreCase(columnName)) {
123+
if (fschema.getName().equalsIgnoreCase(columnName) && !targetTable.hasNonNativePartitionSupport()) {
124124
throw new SemanticException(ErrorMsg.UPDATE_CANNOT_UPDATE_PART_VALUE.getMsg());
125125
}
126126
}

ql/src/java/org/apache/hadoop/hive/ql/parse/rewrite/MergeRewriter.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,8 +250,10 @@ protected void addValues(Table targetTable, String targetAlias, Map<String, Stri
250250
}
251251
}
252252

253-
targetTable.getPartCols().forEach(fieldSchema -> values.add(
254-
formatter.apply(fieldSchema.getName())));
253+
if (!targetTable.hasNonNativePartitionSupport()) {
254+
targetTable.getPartCols().forEach(fieldSchema -> values.add(
255+
formatter.apply(fieldSchema.getName())));
256+
}
255257
}
256258

257259
protected String getRhsExpValue(String newValue, String alias) {

ql/src/java/org/apache/hadoop/hive/ql/parse/rewrite/SplitUpdateRewriter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ public ParseUtils.ReparseResult rewrite(Context context, UpdateStatement updateB
9898

9999
insertValues.add(sqlGenerator.qualify(identifier));
100100
}
101-
if (updateBlock.getTargetTable().getPartCols() != null) {
101+
if (!updateBlock.getTargetTable().hasNonNativePartitionSupport()) {
102102
updateBlock.getTargetTable().getPartCols().forEach(
103103
fieldSchema -> insertValues.add(sqlGenerator.qualify(HiveUtils.unparseIdentifier(fieldSchema.getName(), conf))));
104104
}

ql/src/java/org/apache/hadoop/hive/ql/parse/rewrite/sql/MultiInsertSqlGenerator.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,9 @@ public void appendPartitionColsOfTarget() {
111111
*/
112112
public void appendPartitionCols(Table table) {
113113
// If the table is partitioned we have to put the partition() clause in
114+
if (table.hasNonNativePartitionSupport()) {
115+
return;
116+
}
114117
List<FieldSchema> partCols = table.getPartCols();
115118
if (partCols == null || partCols.isEmpty()) {
116119
return;
@@ -148,7 +151,10 @@ public void removeLastChar() {
148151
}
149152

150153
public void appendPartColsOfTargetTableWithComma(String alias) {
151-
if (targetTable.getPartCols() == null || targetTable.getPartCols().isEmpty()) {
154+
if (targetTable.hasNonNativePartitionSupport()) {
155+
return;
156+
}
157+
if (targetTable.getPartCols().isEmpty()) {
152158
return;
153159
}
154160
queryStr.append(',');

0 commit comments

Comments
 (0)