rdblue commented on a change in pull request #1495:
URL: https://github.com/apache/iceberg/pull/1495#discussion_r493980323
##########
File path: mr/src/main/java/org/apache/iceberg/mr/hive/HiveIcebergSerDe.java
##########
@@ -27,21 +27,32 @@
import org.apache.hadoop.hive.serde2.SerDeStats;
import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector;
import org.apache.hadoop.io.Writable;
-import org.apache.iceberg.Table;
+import org.apache.iceberg.Schema;
+import org.apache.iceberg.SchemaParser;
+import org.apache.iceberg.exceptions.NoSuchTableException;
import org.apache.iceberg.mr.Catalogs;
+import org.apache.iceberg.mr.InputFormatConfig;
import org.apache.iceberg.mr.hive.serde.objectinspector.IcebergObjectInspector;
import org.apache.iceberg.mr.mapred.Container;
public class HiveIcebergSerDe extends AbstractSerDe {
-
+ private Schema schema;
private ObjectInspector inspector;
@Override
public void initialize(@Nullable Configuration configuration, Properties
serDeProperties) throws SerDeException {
- Table table = Catalogs.loadTable(configuration, serDeProperties);
-
try {
- this.inspector = IcebergObjectInspector.create(table.schema());
+ String schemaString = (String)
serDeProperties.get(InputFormatConfig.TABLE_SCHEMA);
+ if (schemaString != null) {
+ schema = SchemaParser.fromJson(schemaString);
+ } else {
+ try {
+ schema = Catalogs.loadTable(configuration, serDeProperties).schema();
+ } catch (NoSuchTableException nte) {
+ throw new SerDeException("Please provide an existing table or a
valid schema", nte);
+ }
+ }
+ inspector = IcebergObjectInspector.create(schema);
Review comment:
It would be helpful to have some context for this. Why did this change?
Could you add some comments to make it more clear what's happening in the code?
----------------------------------------------------------------
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]