You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@iceberg.apache.org by GitBox <gi...@apache.org> on 2019/06/20 00:19:33 UTC

[GitHub] [incubator-iceberg] rdblue commented on a change in pull request #228: Use Iceberg tables as sinks in Spark Structured Streaming

rdblue commented on a change in pull request #228: Use Iceberg tables as sinks in Spark Structured Streaming
URL: https://github.com/apache/incubator-iceberg/pull/228#discussion_r295572647
 
 

 ##########
 File path: spark/src/main/java/org/apache/iceberg/spark/source/IcebergSource.java
 ##########
 @@ -65,37 +69,32 @@ public DataSourceReader createReader(DataSourceOptions options) {
   }
 
   @Override
-  public Optional<DataSourceWriter> createWriter(String jobId, StructType dfStruct, SaveMode mode,
-                                                   DataSourceOptions options) {
+  public Optional<DataSourceWriter> createWriter(String jobId, StructType dsStruct, SaveMode mode,
+                                                 DataSourceOptions options) {
     Preconditions.checkArgument(mode == SaveMode.Append, "Save mode %s is not supported", mode);
     Configuration conf = new Configuration(lazyBaseConf());
     Table table = getTableAndResolveHadoopConfiguration(options, conf);
-
-    Schema dfSchema = SparkSchemaUtil.convert(table.schema(), dfStruct);
-    List<String> errors = CheckCompatibility.writeCompatibilityErrors(table.schema(), dfSchema);
-    if (!errors.isEmpty()) {
-      StringBuilder sb = new StringBuilder();
-      sb.append("Cannot write incompatible dataframe to table with schema:\n")
-          .append(table.schema()).append("\nProblems:");
-      for (String error : errors) {
-        sb.append("\n* ").append(error);
-      }
-      throw new IllegalArgumentException(sb.toString());
-    }
-
-    Optional<String> formatOption = options.get("write-format");
-    FileFormat format;
-    if (formatOption.isPresent()) {
-      format = FileFormat.valueOf(formatOption.get().toUpperCase(Locale.ENGLISH));
-    } else {
-      format = FileFormat.valueOf(table.properties()
-          .getOrDefault(DEFAULT_FILE_FORMAT, DEFAULT_FILE_FORMAT_DEFAULT)
-          .toUpperCase(Locale.ENGLISH));
-    }
-
+    validateSchema(table.schema(), dsStruct);
 
 Review comment:
   Nit: it would be more clear that this is validating the write schema's compatibility if the method were named something like "validateWriteSchema", I think.

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org