pvary commented on a change in pull request #1612:
URL: https://github.com/apache/iceberg/pull/1612#discussion_r530200490
##########
File path: mr/src/main/java/org/apache/iceberg/mr/hive/HiveIcebergSerDe.java
##########
@@ -56,10 +61,28 @@ public void initialize(@Nullable Configuration
configuration, Properties serDePr
} else if (serDeProperties.get(InputFormatConfig.TABLE_SCHEMA) != null) {
tableSchema = SchemaParser.fromJson((String)
serDeProperties.get(InputFormatConfig.TABLE_SCHEMA));
} else {
- try {
- tableSchema = Catalogs.loadTable(configuration,
serDeProperties).schema();
- } catch (NoSuchTableException nte) {
- throw new SerDeException("Please provide an existing table or a valid
schema", nte);
+ if (Catalogs.hiveCatalog(configuration)) {
+ tableSchema = hiveSchema(serDeProperties);
+ if (tableSchema == null) {
+ throw new SerDeException("Please provide a valid schema");
+ } else {
+ LOG.info("Using hive schema {}", SchemaParser.toJson(tableSchema));
+ }
+ } else {
+ try {
+ // always prefer the original table schema if there is one
+ tableSchema = Catalogs.loadTable(configuration,
serDeProperties).schema();
+ LOG.info("Using schema from existing table {}",
SchemaParser.toJson(tableSchema));
+ } catch (Exception e) {
+ // If we can not load the table try the provided hive schema
+ tableSchema = hiveSchema(serDeProperties);
+ if (tableSchema == null) {
+ throw new SerDeException("Please provide an existing table or a
valid schema", e);
+ } else {
+ LOG.info("Using schema from column specification {} since table
load is failed",
+ SchemaParser.toJson(tableSchema), e);
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.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]