This is an automated email from the ASF dual-hosted git repository.

blue pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-iceberg.git


The following commit(s) were added to refs/heads/master by this push:
     new e2bdf33  Add argument validation to HadoopTables#create (#298)
e2bdf33 is described below

commit e2bdf33c947a5982a99dad4736105a4298345544
Author: Chen, Junjie <[email protected]>
AuthorDate: Fri Jul 26 05:25:52 2019 +0800

    Add argument validation to HadoopTables#create (#298)
---
 .../src/main/java/org/apache/iceberg/hadoop/HadoopTables.java | 11 +++++++++--
 1 file changed, 9 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 553faef..e0de97d 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;
@@ -69,19 +71,24 @@ public class HadoopTables implements Tables, Configurable {
    * location.
    *
    * @param schema iceberg schema used to create the table
-   * @param spec partition specification
+   * @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
    */
   @Override
   public Table create(Schema schema, PartitionSpec spec, Map<String, String> 
properties,
                       String location) {
+    Preconditions.checkNotNull(schema, "A table schema 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<String, String> tableProps = properties == null ? ImmutableMap.of() : 
properties;
+    PartitionSpec partitionSpec = spec == null ? PartitionSpec.unpartitioned() 
: spec;
+    TableMetadata metadata = TableMetadata.newTableMetadata(ops, schema, 
partitionSpec, location, tableProps);
     ops.commit(null, metadata);
 
     return new BaseTable(ops, location);

Reply via email to