davidradl commented on code in PR #27929:
URL: https://github.com/apache/flink/pull/27929#discussion_r3093957366
##########
flink-table/flink-table-common/src/main/java/org/apache/flink/table/types/inference/SystemTypeInference.java:
##########
@@ -667,6 +686,48 @@ private static void checkSetSemantics(StaticArgument
staticArg, TableSemantics s
"Table argument '%s' requires a PARTITION BY
clause for parallel processing.",
staticArg.getName()));
}
+
+ checkOrderBy(staticArg, semantics);
}
+
+ private static void checkOrderBy(StaticArgument staticArg,
TableSemantics semantics) {
+ final int[] orderByColumns = semantics.orderByColumns();
+ if (orderByColumns.length == 0) {
+ return;
+ }
+
+ final LogicalType tableType =
semantics.dataType().getLogicalType();
+ final List<String> fieldNames =
LogicalTypeChecks.getFieldNames(tableType);
+ final List<LogicalType> fieldTypes =
LogicalTypeChecks.getFieldTypes(tableType);
+
+ // The first ORDER BY column must be a supported time attribute
+ final int firstOrderByColumn = orderByColumns[0];
+ final LogicalType firstOrderByType =
fieldTypes.get(firstOrderByColumn);
+ if (isUnsupportedOnTimeColumn(firstOrderByType)) {
+ throw new ValidationException(
+ String.format(
+ "Invalid ORDER BY clause for table argument
'%s'. "
+ + "The first ORDER BY column must be a
TIMESTAMP or TIMESTAMP_LTZ column (up to precision 3). "
+ + "However, column '%s' has data type
'%s'.",
+ staticArg.getName(),
+ fieldNames.get(firstOrderByColumn),
+ firstOrderByType.asSummaryString()));
+ }
+
+ // The first ORDER BY column must be ascending
+ final SortDirection[] orderByDirections =
semantics.orderByDirections();
Review Comment:
where do we assert that the first column is a timestamp type?
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]