@@ -526,23 +526,21 @@ private void validateTimePartitioningColumn(String columnName, FailureCollector
526526
527527 boolean isTimestamp = logicalType == LogicalType .TIMESTAMP_MICROS || logicalType == LogicalType .TIMESTAMP_MILLIS ;
528528 boolean isDate = logicalType == LogicalType .DATE ;
529- boolean isTimestampOrDate = isTimestamp || isDate ;
530-
531- // If timePartitioningType is HOUR, then logicalType cannot be DATE Only TIMESTAMP_MICROS and TIMESTAMP_MILLIS
532- if ( timePartitioningType == TimePartitioning . Type . HOUR && ! isTimestamp ) {
533- collector . addFailure (
534- String .format ("Partition column '%s' is of invalid type '%s'." ,
529+ boolean isDateTime = logicalType == LogicalType . DATETIME ;
530+ boolean isTimestampOrDateOrDateTime = isTimestamp || isDate || isDateTime ;
531+ boolean isTimestampOrDateTime = isTimestamp || isDateTime ;
532+ // TimePartitioningType HOUR is supported by TIMESTAMP_MICROS, TIMESTAMP_MILLIS, DATETIME
533+ if ( timePartitioningType == TimePartitioning . Type . HOUR && ! isTimestampOrDateTime ) {
534+ collector . addFailure ( String .format ("Partition column '%s' is of invalid type '%s'." ,
535535 columnName , fieldSchema .getDisplayName ()),
536- "Partition column must be a timestamp." ).withConfigProperty (NAME_PARTITION_BY_FIELD )
537- .withOutputSchemaField (columnName ).withInputSchemaField (columnName );
538-
539- // For any other timePartitioningType (DAY, MONTH, YEAR) logicalType can be DATE, TIMESTAMP_MICROS, TIMESTAMP_MILLIS
540- } else if (!isTimestampOrDate ) {
541- collector .addFailure (
542- String .format ("Partition column '%s' is of invalid type '%s'." ,
536+ "Partition column must be of type TIMESTAMP or DATETIME" )
537+ .withConfigProperty (NAME_PARTITION_BY_FIELD ).withOutputSchemaField (columnName ).withInputSchemaField (columnName );
538+ // TimePartitioningType (DAY, MONTH, YEAR) are supported by TIMESTAMP_MICROS, TIMESTAMP_MILLIS, DATE, DATETIME
539+ } else if (!isTimestampOrDateOrDateTime ) {
540+ collector .addFailure (String .format ("Partition column '%s' is of invalid type '%s'." ,
543541 columnName , fieldSchema .getDisplayName ()),
544- "Partition column must be a date or timestamp." ). withConfigProperty ( NAME_PARTITION_BY_FIELD )
545- .withOutputSchemaField (columnName ).withInputSchemaField (columnName );
542+ "Partition column must be of type TIMESTAMP, DATE or DATETIME" )
543+ . withConfigProperty ( NAME_PARTITION_BY_FIELD ) .withOutputSchemaField (columnName ).withInputSchemaField (columnName );
546544 }
547545 }
548546
0 commit comments