snuyanzin commented on code in PR #29070:
URL: https://github.com/apache/flink/pull/29070#discussion_r3925985704


##########
flink-table/flink-table-api-java/src/test/java/org/apache/flink/table/operations/WindowTableFunctionQueryOperationTest.java:
##########
@@ -0,0 +1,153 @@
+/*
+ * 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.operations;
+
+import org.apache.flink.table.api.DataTypes;
+import org.apache.flink.table.api.Schema;
+import org.apache.flink.table.api.ValidationException;
+import org.apache.flink.table.catalog.CatalogTable;
+import org.apache.flink.table.catalog.ContextResolvedTable;
+import org.apache.flink.table.catalog.ObjectIdentifier;
+import org.apache.flink.table.catalog.ResolvedCatalogTable;
+import org.apache.flink.table.catalog.ResolvedSchema;
+import 
org.apache.flink.table.operations.WindowTableFunctionQueryOperation.WindowKind;
+
+import org.junit.jupiter.api.Test;
+
+import java.time.Duration;
+import java.util.Arrays;
+import java.util.Collections;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+
+/** Tests for describing {@link WindowTableFunctionQueryOperation}. */
+class WindowTableFunctionQueryOperationTest {
+
+    private static QueryOperation source() {
+        final ResolvedSchema schema =
+                ResolvedSchema.physical(
+                        Arrays.asList("id", "amount", "ts"),
+                        Arrays.asList(DataTypes.INT(), DataTypes.INT(), 
DataTypes.TIMESTAMP(3)));
+        return new SourceQueryOperation(
+                ContextResolvedTable.temporary(
+                        ObjectIdentifier.of("cat1", "db1", "src"),
+                        new ResolvedCatalogTable(
+                                CatalogTable.newBuilder()
+                                        .schema(Schema.newBuilder().build())
+                                        .build(),
+                                schema)));
+    }
+
+    @Test
+    void testConstructorAppendsWindowColumns() {
+        assertThat(
+                        new WindowTableFunctionQueryOperation(
+                                        WindowKind.TUMBLE,
+                                        "ts",
+                                        
Collections.singletonList(Duration.ofMinutes(10)),
+                                        source())
+                                .getResolvedSchema()
+                                .getColumnNames())
+                .containsExactly("id", "amount", "ts", "window_start", 
"window_end", "window_time");
+    }
+
+    @Test
+    void testWindowColumnsMatchPlannerNullability() {
+        final ResolvedSchema schema =
+                new WindowTableFunctionQueryOperation(
+                                WindowKind.TUMBLE,
+                                "ts",
+                                
Collections.singletonList(Duration.ofMinutes(10)),
+                                source())
+                        .getResolvedSchema();
+
+        
assertThat(schema.getColumn("window_start").orElseThrow(AssertionError::new).getDataType())
+                .isEqualTo(DataTypes.TIMESTAMP(3).notNull());
+        
assertThat(schema.getColumn("window_end").orElseThrow(AssertionError::new).getDataType())
+                .isEqualTo(DataTypes.TIMESTAMP(3).notNull());
+        
assertThat(schema.getColumn("window_time").orElseThrow(AssertionError::new).getDataType())
+                .isEqualTo(DataTypes.TIMESTAMP(3).notNull());
+    }
+
+    @Test
+    void testWrongIntervalCountRejected() {
+        assertThatThrownBy(
+                        () ->
+                                new WindowTableFunctionQueryOperation(
+                                        WindowKind.HOP,
+                                        "ts",
+                                        
Collections.singletonList(Duration.ofMinutes(10)),

Review Comment:
   ```suggestion
                                           CList.of(Duration.ofMinutes(10)),
   ```



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