fhueske commented on code in PR #29003:
URL: https://github.com/apache/flink/pull/29003#discussion_r3829370607


##########
flink-table/flink-table-planner/src/main/scala/org/apache/flink/table/planner/plan/utils/SortUtil.scala:
##########
@@ -74,6 +74,20 @@ object SortUtil {
     rowType.getFieldList.get(idx)
   }
 
+  /** Error message when the primary streaming sort key is not a time 
attribute. */
+  def sortKeyNotTimeAttributeMessage(column: String, tpe: LogicalType): String 
=
+    s"Streaming ORDER BY requires the primary sort key to be a time attribute 
in ascending " +
+      s"order, but '$column' is ${tpe.asSummaryString}. A time attribute is an 
event-time column " +
+      s"(a TIMESTAMP with a WATERMARK) or a processing-time column. Otherwise 
use LIMIT for " +
+      s"Top-N, sort within a window, or run in batch mode."
+
+  /**
+   * Error message when the primary streaming sort key is a time attribute but 
sorted descending.
+   */
+  def sortKeyTimeAttributeMustBeAscendingMessage(column: String): String =
+    s"Streaming ORDER BY on time attribute '$column' must be sorted in 
ascending order; DESC is " +

Review Comment:
   ```suggestion
       s"Streaming ORDER BY on time attribute '$column' must be sorted in 
ascending order; descending order is " +
   ```
   Spell out descending as ascending is spelled out as well?



##########
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/plan/stream/sql/SortValidationTest.java:
##########
@@ -0,0 +1,102 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.table.planner.plan.stream.sql;
+
+import org.apache.flink.table.api.TableException;
+import org.apache.flink.table.planner.utils.JavaStreamTableTestUtil;
+import org.apache.flink.table.planner.utils.TableTestBase;
+
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.Arguments;
+import org.junit.jupiter.params.provider.MethodSource;
+
+import java.util.stream.Stream;
+
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+
+/**
+ * Plan-time validation tests for streaming sort. A non-time-attribute sort is 
unsupported and must
+ * be rejected during optimization (so it surfaces at {@code COMPILE PLAN} / 
planning time), not
+ * deferred to execution-plan translation. Valid temporal sorts are covered by 
{@code SortTest}.
+ */
+class SortValidationTest extends TableTestBase {

Review Comment:
   add a test asserting that the plan check are only done if the 
`TABLE_EXEC_NON_TEMPORAL_SORT_ENABLED` flag isn't set?



-- 
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]

Reply via email to