twalthr commented on code in PR #29987: URL: https://github.com/apache/flink/pull/29987#discussion_r4600547736
########## flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/plan/nodes/exec/InputPropertyTest.java: ########## @@ -0,0 +1,189 @@ +/* + * 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.nodes.exec; + +import org.apache.flink.table.annotation.ArgumentHint; +import org.apache.flink.table.annotation.ArgumentTrait; +import org.apache.flink.table.api.EnvironmentSettings; +import org.apache.flink.table.api.Schema; +import org.apache.flink.table.api.TableDescriptor; +import org.apache.flink.table.api.TableEnvironment; +import org.apache.flink.table.functions.ProcessTableFunction; +import org.apache.flink.table.planner.utils.JsonTestUtils; +import org.apache.flink.types.Row; + +import org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.JsonNode; + +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; + +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Stream; + +import static org.assertj.core.api.Assertions.assertThat; + +/** + * Tests that physical nodes declare the input distribution requested by their physical rule in + * their {@link InputProperty}s. Covers nodes that request a distribution only conditionally. + */ +class InputPropertyTest { + + private static final String SINGLETON = "SINGLETON"; + private static final String UNKNOWN = "UNKNOWN"; + + static Stream<Arguments> testCases() { + return Stream.of( + // window table functions request a distribution only for session windows + Arguments.of( + "SELECT * FROM SESSION(TABLE T, DESCRIPTOR(ts), INTERVAL '1' MINUTE)", + "stream-exec-window-table-function", + List.of(SINGLETON)), + Arguments.of( + "SELECT * FROM SESSION(TABLE T PARTITION BY k, DESCRIPTOR(ts), " + + "INTERVAL '1' MINUTE)", + "stream-exec-window-table-function", + List.of("HASH[1]")), + Arguments.of( + "SELECT * FROM TUMBLE(TABLE T, DESCRIPTOR(ts), INTERVAL '1' MINUTE)", + "stream-exec-window-table-function", + List.of(UNKNOWN)), + // lookup joins request a distribution only for the hash shuffle of the LOOKUP hint + Arguments.of( + "SELECT /*+ LOOKUP('table'='D', 'shuffle'='true') */ T.i FROM T " + + "JOIN D FOR SYSTEM_TIME AS OF T.proc ON T.k = D.k", + "stream-exec-lookup-join", + List.of("HASH[1]")), + Arguments.of( + "SELECT T.i FROM T JOIN D FOR SYSTEM_TIME AS OF T.proc ON T.k = D.k", + "stream-exec-lookup-join", + List.of(UNKNOWN)), + // PTFs request a distribution for table arguments with set semantics + Arguments.of( + "SELECT * FROM SetSemanticFunction(input => TABLE U)", + "stream-exec-process-table-function", + List.of(SINGLETON)), + Arguments.of( + "SELECT * FROM SetSemanticFunction(input => TABLE U PARTITION BY k)", + "stream-exec-process-table-function", + List.of("HASH[0]")), + // nodes that always request a distribution + Arguments.of( Review Comment: Good point, added. There is now one case per stream node type that always declares a distribution, with a SINGLETON and a HASH variant where the rule distinguishes them: group, window and group window aggregates, over, rank, deduplicate, sort limit, limit, temporal sort, interval, temporal and window joins, window rank and deduplicate, match, and changelog normalize. Nodes that need a non-default configuration (global/incremental aggregates with mini-batch, non-temporal sort, Python) are left out; they call the same fromInput. -- 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]
