@@ -333,14 +333,14 @@ private Schema getTableSchema(
333333 return BigQueryUtil .getTableSchema (bqSchema , collector );
334334 }
335335
336- protected void validateInsertSchema (Table table , Schema tableSchema , FailureCollector collector ) {
336+ protected void validateInsertSchema (Table table , @ Nullable Schema tableSchema , FailureCollector collector ) {
337337 com .google .cloud .bigquery .Schema bqSchema = table .getDefinition ().getSchema ();
338338 if (bqSchema == null || bqSchema .getFields ().isEmpty ()) {
339339 // Table is created without schema, so no further validation is required.
340340 return ;
341341 }
342342
343- if (getConfig ().isTruncateTableSet ()) {
343+ if (getConfig ().isTruncateTableSet () || tableSchema == null ) {
344344 //no validation required for schema if truncate table is set.
345345 // BQ will overwrite the schema for normal tables when write disposition is WRITE_TRUNCATE
346346 //note - If write to single partition is supported in future, schema validation will be necessary
@@ -389,10 +389,10 @@ protected void validateInsertSchema(Table table, Schema tableSchema, FailureColl
389389 protected void validateSchema (
390390 String tableName ,
391391 com .google .cloud .bigquery .Schema bqSchema ,
392- Schema tableSchema ,
392+ @ Nullable Schema tableSchema ,
393393 boolean allowSchemaRelaxation ,
394394 FailureCollector collector ) {
395- if (bqSchema == null || bqSchema .getFields ().isEmpty ()) {
395+ if (bqSchema == null || bqSchema .getFields ().isEmpty () || tableSchema == null ) {
396396 // Table is created without schema, so no further validation is required.
397397 return ;
398398 }
0 commit comments