Skip to content

Commit d476a99

Browse files
authored
HIVE-28934: PlanUtils.configureJobPropertiesForStorageHandler should use hive session configuration. (#5788)
1 parent ffefb7d commit d476a99

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

iceberg/iceberg-handler/src/main/java/org/apache/iceberg/mr/hive/HiveIcebergStorageHandler.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@
9292
import org.apache.hadoop.hive.ql.io.sarg.ConvertAstToSearchArg;
9393
import org.apache.hadoop.hive.ql.io.sarg.SearchArgument;
9494
import org.apache.hadoop.hive.ql.metadata.DummyPartition;
95+
import org.apache.hadoop.hive.ql.metadata.Hive;
9596
import org.apache.hadoop.hive.ql.metadata.HiveException;
9697
import org.apache.hadoop.hive.ql.metadata.HiveStorageHandler;
9798
import org.apache.hadoop.hive.ql.metadata.HiveStoragePredicateHandler;
@@ -1804,13 +1805,19 @@ private String collectColumnAndReplaceDummyValues(ExprNodeDesc node, String foun
18041805
* </ul>
18051806
* @param tableProps table properties, must be not null
18061807
*/
1807-
private void fallbackToNonVectorizedModeBasedOnProperties(Properties tableProps) {
1808+
private static void fallbackToNonVectorizedModeBasedOnProperties(Properties tableProps) {
18081809
Schema tableSchema = SchemaParser.fromJson(tableProps.getProperty(InputFormatConfig.TABLE_SCHEMA));
1810+
String tableMeta = tableProps.getProperty(IcebergAcidUtil.META_TABLE_PROPERTY);
1811+
boolean isMetaTable = tableMeta != null && IcebergMetadataTables.isValidMetaTable(tableMeta);
18091812
if (FileFormat.AVRO.name().equalsIgnoreCase(tableProps.getProperty(TableProperties.DEFAULT_FILE_FORMAT)) ||
1810-
isValidMetadataTable(tableProps.getProperty(IcebergAcidUtil.META_TABLE_PROPERTY)) ||
1813+
isMetaTable ||
18111814
hasOrcTimeInSchema(tableProps, tableSchema) ||
18121815
!hasParquetNestedTypeWithinListOrMap(tableProps, tableSchema)) {
1813-
conf.setBoolean(ConfVars.HIVE_VECTORIZATION_ENABLED.varname, false);
1816+
try {
1817+
Hive.get(false).getConf().setBoolVar(ConfVars.HIVE_VECTORIZATION_ENABLED, false);
1818+
} catch (HiveException e) {
1819+
throw new RuntimeException(e);
1820+
}
18141821
}
18151822
}
18161823

ql/src/java/org/apache/hadoop/hive/ql/plan/PlanUtils.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
import static org.apache.commons.lang3.StringUtils.isNotBlank;
2222
import static org.apache.hadoop.hive.metastore.api.hive_metastoreConstants.META_TABLE_LOCATION;
23+
import static org.apache.hadoop.hive.metastore.api.hive_metastoreConstants.META_TABLE_STORAGE;
2324
import static org.apache.hadoop.hive.metastore.api.hive_metastoreConstants.TABLE_IS_CTAS;
2425
import static org.apache.hive.common.util.HiveStringUtils.quoteComments;
2526

@@ -57,7 +58,6 @@
5758
import org.apache.hadoop.hive.ql.io.IgnoreKeyTextOutputFormat;
5859
import org.apache.hadoop.hive.ql.io.RCFileInputFormat;
5960
import org.apache.hadoop.hive.ql.io.RCFileOutputFormat;
60-
import org.apache.hadoop.hive.ql.metadata.Hive;
6161
import org.apache.hadoop.hive.ql.metadata.HiveException;
6262
import org.apache.hadoop.hive.ql.metadata.HiveStorageHandler;
6363
import org.apache.hadoop.hive.ql.metadata.HiveUtils;
@@ -932,11 +932,9 @@ private static void configureJobPropertiesForStorageHandler(boolean input,
932932
}
933933

934934
try {
935-
HiveStorageHandler storageHandler =
936-
HiveUtils.getStorageHandler(
937-
Hive.get().getConf(),
938-
tableDesc.getProperties().getProperty(
939-
org.apache.hadoop.hive.metastore.api.hive_metastoreConstants.META_TABLE_STORAGE));
935+
HiveConf hiveConf = SessionState.getSessionConf();
936+
String className = tableDesc.getProperties().getProperty(META_TABLE_STORAGE);
937+
HiveStorageHandler storageHandler = HiveUtils.getStorageHandler(hiveConf, className);
940938
if (storageHandler != null) {
941939
Map<String, String> jobProperties = new LinkedHashMap<String, String>();
942940
Map<String, String> jobSecrets = new LinkedHashMap<String, String>();

0 commit comments

Comments
 (0)