From 494a1cfd58678fccda02dccac574acd00a344f55 Mon Sep 17 00:00:00 2001 From: Junjie Chen Date: Thu, 18 Jul 2019 21:11:28 +0800 Subject: [PATCH 1/4] Add some checks for HadoopTable#create --- .../java/org/apache/iceberg/hadoop/HadoopTables.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/org/apache/iceberg/hadoop/HadoopTables.java b/core/src/main/java/org/apache/iceberg/hadoop/HadoopTables.java index 553faef93e94..15b509d56e81 100644 --- a/core/src/main/java/org/apache/iceberg/hadoop/HadoopTables.java +++ b/core/src/main/java/org/apache/iceberg/hadoop/HadoopTables.java @@ -19,6 +19,8 @@ package org.apache.iceberg.hadoop; +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableMap; import java.util.Map; import org.apache.hadoop.conf.Configurable; import org.apache.hadoop.conf.Configuration; @@ -70,18 +72,23 @@ public Table load(String location) { * * @param schema iceberg schema used to create the table * @param spec partition specification + * @param properties properties of the table to be created * @param location a path URI (e.g. hdfs:///warehouse/my_table) * @return newly created table implementation */ @Override public Table create(Schema schema, PartitionSpec spec, Map properties, String location) { + Preconditions.checkNotNull(schema, "A table schema is required"); + Preconditions.checkNotNull(spec, "A partition spec is required"); + TableOperations ops = newTableOps(location); if (ops.current() != null) { throw new AlreadyExistsException("Table already exists at location: " + location); } - TableMetadata metadata = TableMetadata.newTableMetadata(ops, schema, spec, location, properties); + Map tableProps = properties == null ? ImmutableMap.of() : properties; + TableMetadata metadata = TableMetadata.newTableMetadata(ops, schema, spec, location, tableProps); ops.commit(null, metadata); return new BaseTable(ops, location); From b7715b6bd13fe4c09d3a4532b182ca275c61f541 Mon Sep 17 00:00:00 2001 From: Junjie Chen Date: Sat, 20 Jul 2019 08:39:36 +0800 Subject: [PATCH 2/4] Allow null spec when creating table --- .../main/java/org/apache/iceberg/hadoop/HadoopTables.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/core/src/main/java/org/apache/iceberg/hadoop/HadoopTables.java b/core/src/main/java/org/apache/iceberg/hadoop/HadoopTables.java index 15b509d56e81..f270f83b16c9 100644 --- a/core/src/main/java/org/apache/iceberg/hadoop/HadoopTables.java +++ b/core/src/main/java/org/apache/iceberg/hadoop/HadoopTables.java @@ -71,8 +71,8 @@ public Table load(String location) { * location. * * @param schema iceberg schema used to create the table - * @param spec partition specification - * @param properties properties of the table to be created + * @param spec partition specification. It can be null in case of unpartitioned table + * @param properties properties of the table to be created, it can be null * @param location a path URI (e.g. hdfs:///warehouse/my_table) * @return newly created table implementation */ @@ -80,7 +80,6 @@ public Table load(String location) { public Table create(Schema schema, PartitionSpec spec, Map properties, String location) { Preconditions.checkNotNull(schema, "A table schema is required"); - Preconditions.checkNotNull(spec, "A partition spec is required"); TableOperations ops = newTableOps(location); if (ops.current() != null) { @@ -88,6 +87,7 @@ public Table create(Schema schema, PartitionSpec spec, Map prope } Map tableProps = properties == null ? ImmutableMap.of() : properties; + PartitionSpec partitionSpec = spec == null ? PartitionSpec.unpartitioned() : spec; TableMetadata metadata = TableMetadata.newTableMetadata(ops, schema, spec, location, tableProps); ops.commit(null, metadata); From 08b15c85fbbb252e5281348485da2c7969a9d999 Mon Sep 17 00:00:00 2001 From: Junjie Chen Date: Tue, 23 Jul 2019 20:43:53 +0800 Subject: [PATCH 3/4] Add missing code change --- core/src/main/java/org/apache/iceberg/hadoop/HadoopTables.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/main/java/org/apache/iceberg/hadoop/HadoopTables.java b/core/src/main/java/org/apache/iceberg/hadoop/HadoopTables.java index f270f83b16c9..61e5539bfbf3 100644 --- a/core/src/main/java/org/apache/iceberg/hadoop/HadoopTables.java +++ b/core/src/main/java/org/apache/iceberg/hadoop/HadoopTables.java @@ -88,7 +88,7 @@ public Table create(Schema schema, PartitionSpec spec, Map prope Map tableProps = properties == null ? ImmutableMap.of() : properties; PartitionSpec partitionSpec = spec == null ? PartitionSpec.unpartitioned() : spec; - TableMetadata metadata = TableMetadata.newTableMetadata(ops, schema, spec, location, tableProps); + TableMetadata metadata = TableMetadata.newTableMetadata(ops, schema, partitionSpec, location, tableProps); ops.commit(null, metadata); return new BaseTable(ops, location); From d014e32cd2dab6a681715e5d54a883d7c6391f78 Mon Sep 17 00:00:00 2001 From: Junjie Chen Date: Thu, 25 Jul 2019 06:43:25 +0800 Subject: [PATCH 4/4] update doc --- .../src/main/java/org/apache/iceberg/hadoop/HadoopTables.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/org/apache/iceberg/hadoop/HadoopTables.java b/core/src/main/java/org/apache/iceberg/hadoop/HadoopTables.java index 61e5539bfbf3..e0de97dca262 100644 --- a/core/src/main/java/org/apache/iceberg/hadoop/HadoopTables.java +++ b/core/src/main/java/org/apache/iceberg/hadoop/HadoopTables.java @@ -71,8 +71,8 @@ public Table load(String location) { * location. * * @param schema iceberg schema used to create the table - * @param spec partition specification. It can be null in case of unpartitioned table - * @param properties properties of the table to be created, it can be null + * @param spec partitioning spec, if null the table will be unpartitioned + * @param properties a string map of table properties, initialized to empty if null * @param location a path URI (e.g. hdfs:///warehouse/my_table) * @return newly created table implementation */