Skip to content

Commit d69a13f

Browse files
Merge pull request #1399 from cloudsufi/cherry-pick-05b4423040c03237da1afa4c54d31f5aef60b505
[🍒][PLUGIN-788] Fixed Partition Field Validation
2 parents 2ca341b + 0235061 commit d69a13f

1 file changed

Lines changed: 12 additions & 5 deletions

File tree

src/main/java/io/cdap/plugin/gcp/bigquery/sink/BigQuerySinkConfig.java

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,10 @@ private void validatePartitionProperties(@Nullable Schema schema, FailureCollect
390390
String tableName = getTable();
391391
String serviceAccount = getServiceAccount();
392392

393+
if (shouldCreatePartitionedTable()) {
394+
validateColumnForPartition(partitionByField, schema, collector);
395+
}
396+
393397
if (project == null || dataset == null || tableName == null || serviceAccount == null) {
394398
return;
395399
}
@@ -415,11 +419,6 @@ private void validatePartitionProperties(@Nullable Schema schema, FailureCollect
415419
} else if (rangePartitioning != null) {
416420
validateRangePartitionTableWithInputConfiguration(table, rangePartitioning, collector);
417421
}
418-
validateColumnForPartition(partitionByField, schema, collector);
419-
return;
420-
}
421-
if (shouldCreatePartitionedTable()) {
422-
validateColumnForPartition(partitionByField, schema, collector);
423422
}
424423
}
425424

@@ -540,6 +539,14 @@ private void validateIntegerPartitioningRange(Long rangeStart, Long rangeEnd, Lo
540539
.withConfigProperty(NAME_RANGE_END);
541540
}
542541

542+
if (!containsMacro(NAME_RANGE_START) && !containsMacro(NAME_RANGE_END) && rangeStart != null && rangeEnd != null) {
543+
if (rangeEnd <= rangeStart) {
544+
collector.addFailure("Range End is less than or equal to Range Start.",
545+
"Range End must be greater than Range Start.")
546+
.withConfigProperty(NAME_RANGE_END);
547+
}
548+
}
549+
543550
if (!containsMacro(NAME_RANGE_INTERVAL)) {
544551
if (rangeInterval == null) {
545552
collector.addFailure(

0 commit comments

Comments
 (0)