You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by "bvarghese1 (via GitHub)" <gi...@apache.org> on 2023/11/27 18:55:00 UTC
[PR] [FLINK-33647] Implement restore tests for LookupJoin node [flink]
bvarghese1 opened a new pull request, #23814:
URL: https://github.com/apache/flink/pull/23814
<!--
*Thank you very much for contributing to Apache Flink - we are happy that you want to help us improve Flink. To help the community review your contribution in the best possible way, please go through the checklist below, which will get the contribution into a shape in which it can be best reviewed.*
*Please understand that we do not do this to make contributions to Flink a hassle. In order to uphold a high standard of quality for code contributions, while at the same time managing a large number of contributions, we need contributors to prepare the contributions well, and give reviewers enough contextual information for the review. Please also understand that contributions that do not follow this guide will take longer to review and thus typically be picked up with lower priority by the community.*
## Contribution Checklist
- Make sure that the pull request corresponds to a [JIRA issue](https://issues.apache.org/jira/projects/FLINK/issues). Exceptions are made for typos in JavaDoc or documentation files, which need no JIRA issue.
- Name the pull request in the form "[FLINK-XXXX] [component] Title of the pull request", where *FLINK-XXXX* should be replaced by the actual issue number. Skip *component* if you are unsure about which is the best component.
Typo fixes that have no associated JIRA issue should be named following this pattern: `[hotfix] [docs] Fix typo in event time introduction` or `[hotfix] [javadocs] Expand JavaDoc for PuncuatedWatermarkGenerator`.
- Fill out the template below to describe the changes contributed by the pull request. That will give reviewers the context they need to do the review.
- Make sure that the change passes the automated tests, i.e., `mvn clean verify` passes. You can set up Azure Pipelines CI to do that following [this guide](https://cwiki.apache.org/confluence/display/FLINK/Azure+Pipelines#AzurePipelines-Tutorial:SettingupAzurePipelinesforaforkoftheFlinkrepository).
- Each pull request should address only one issue, not mix up code from multiple issues.
- Each commit in the pull request has a meaningful commit message (including the JIRA id)
- Once all items of the checklist are addressed, remove the above text and this checklist, leaving only the filled out template below.
**(The sections below can be removed for hotfixes of typos)**
-->
## What is the purpose of the change
Implement restore tests for LookupJoin node
## Verifying this change
This change added tests and can be verified as follows:
- Added restore tests for LookupJoin node which verifies the generated compiled plan with the saved compiled plan
## Does this pull request potentially affect one of the following parts:
- Dependencies (does it add or upgrade a dependency): (no)
- The public API, i.e., is any changed class annotated with `@Public(Evolving)`: (no)
- The serializers: (no)
- The runtime per-record code paths (performance sensitive): (no)
- Anything that affects deployment or recovery: JobManager (and its components), Checkpointing, Kubernetes/Yarn, ZooKeeper: (no)
- The S3 file system connector: (no)
## Documentation
- Does this pull request introduce a new feature? (no)
- If yes, how is the feature documented? (not applicable)
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-33647] Implement restore tests for LookupJoin node [flink]
Posted by "flinkbot (via GitHub)" <gi...@apache.org>.
flinkbot commented on PR #23814:
URL: https://github.com/apache/flink/pull/23814#issuecomment-1828441266
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "40058dbde8aa6676a411809110590296bd40a47c",
"status" : "UNKNOWN",
"url" : "TBD",
"triggerID" : "40058dbde8aa6676a411809110590296bd40a47c",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* 40058dbde8aa6676a411809110590296bd40a47c UNKNOWN
<details>
<summary>Bot commands</summary>
The @flinkbot bot supports the following commands:
- `@flinkbot run azure` re-run the last Azure build
</details>
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-33647] Implement restore tests for LookupJoin node [flink]
Posted by "bvarghese1 (via GitHub)" <gi...@apache.org>.
bvarghese1 commented on code in PR #23814:
URL: https://github.com/apache/flink/pull/23814#discussion_r1413356579
##########
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/plan/nodes/exec/stream/LookupJoinJsonPlanTest.java:
##########
@@ -1,273 +0,0 @@
-/*
- * 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.stream;
-
-import org.apache.flink.api.common.typeinfo.Types;
-import org.apache.flink.table.api.TableConfig;
-import org.apache.flink.table.api.TableEnvironment;
-import org.apache.flink.table.api.TableSchema;
-import org.apache.flink.table.api.ValidationException;
-import org.apache.flink.table.api.config.OptimizerConfigOptions;
-import org.apache.flink.table.planner.runtime.utils.InMemoryLookupableTableSource;
-import org.apache.flink.table.planner.utils.StreamTableTestUtil;
-import org.apache.flink.table.planner.utils.TableTestBase;
-import org.apache.flink.types.Row;
-
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-
-import java.util.ArrayList;
-
-import scala.collection.JavaConverters;
-
-import static org.apache.flink.core.testutils.FlinkAssertions.anyCauseMatches;
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
-
-/** Test json serialization/deserialization for LookupJoin. */
-class LookupJoinJsonPlanTest extends TableTestBase {
-
- private StreamTableTestUtil util;
- private TableEnvironment tEnv;
-
- @BeforeEach
- void setup() {
- util = streamTestUtil(TableConfig.getDefault());
- tEnv = util.getTableEnv();
-
- String srcTableA =
- "CREATE TABLE MyTable (\n"
- + " a int,\n"
- + " b varchar,\n"
- + " c bigint,\n"
- + " proctime as PROCTIME(),\n"
- + " rowtime as TO_TIMESTAMP(FROM_UNIXTIME(c)),\n"
- + " watermark for rowtime as rowtime - INTERVAL '1' second \n"
- + ") with (\n"
- + " 'connector' = 'values',\n"
- + " 'bounded' = 'false')";
- String srcTableB =
- "CREATE TABLE LookupTable (\n"
- + " id int,\n"
- + " name varchar,\n"
- + " age int \n"
- + ") with (\n"
- + " 'connector' = 'values',\n"
- + " 'bounded' = 'false')";
- String sinkTable1 =
- "CREATE TABLE Sink1 (\n"
- + " a int,\n"
- + " name varchar,"
- + " age int"
- + ") with (\n"
- + " 'connector' = 'values',\n"
- + " 'sink-insert-only' = 'false')";
- String sinkTable2 =
- "CREATE TABLE MySink1 (\n"
- + " a int,\n"
- + " b varchar,"
- + " c bigint,"
- + " proctime timestamp(3),"
- + " rowtime timestamp(3),"
- + " id int,"
- + " name varchar,"
- + " age int"
- + ") with (\n"
- + " 'connector' = 'values',\n"
- + " 'table-sink-class' = 'DEFAULT')";
- tEnv.executeSql(srcTableA);
- tEnv.executeSql(srcTableB);
- tEnv.executeSql(sinkTable1);
- tEnv.executeSql(sinkTable2);
- }
-
- @Test
- void testJoinTemporalTable() {
- String sinkTableDdl =
- "CREATE TABLE MySink (\n"
- + " a int,\n"
- + " b varchar,"
- + " c bigint,"
- + " proctime timestamp(3),"
- + " rowtime timestamp(3),"
- + " id int,"
- + " name varchar,"
- + " age int"
- + ") with (\n"
- + " 'connector' = 'values',\n"
- + " 'table-sink-class' = 'DEFAULT')";
- tEnv.executeSql(sinkTableDdl);
- util.verifyJsonPlan(
- "INSERT INTO MySink SELECT * FROM MyTable AS T JOIN LookupTable "
- + "FOR SYSTEM_TIME AS OF T.proctime AS D ON T.a = D.id");
- }
-
- @Test
- void testJoinTemporalTableWithProjectionPushDown() {
- String sinkTableDdl =
- "CREATE TABLE MySink (\n"
- + " a int,\n"
- + " b varchar,"
- + " c bigint,"
- + " proctime timestamp(3),"
- + " rowtime timestamp(3),"
- + " id int"
- + ") with (\n"
- + " 'connector' = 'values',\n"
- + " 'table-sink-class' = 'DEFAULT')";
- tEnv.executeSql(sinkTableDdl);
- util.verifyJsonPlan(
- "INSERT INTO MySink \n"
- + "SELECT T.*, D.id \n"
- + "FROM MyTable AS T \n"
- + "JOIN LookupTable FOR SYSTEM_TIME AS OF T.proctime AS D \n"
- + "ON T.a = D.id\n");
- }
-
- @Test
- void testLegacyTableSourceException() {
- TableSchema tableSchema =
- TableSchema.builder()
- .field("id", Types.INT)
- .field("name", Types.STRING)
- .field("age", Types.INT)
- .build();
- InMemoryLookupableTableSource.createTemporaryTable(
- tEnv,
- false,
- JavaConverters.asScalaIteratorConverter(new ArrayList<Row>().iterator())
- .asScala()
- .toList(),
- tableSchema,
- "LookupTable",
- true);
- String sinkTableDdl =
- "CREATE TABLE MySink (\n"
- + " a int,\n"
- + " b varchar,"
- + " c bigint,"
- + " proctime timestamp(3),"
- + " rowtime timestamp(3),"
- + " id int,"
- + " name varchar,"
- + " age int"
- + ") with (\n"
- + " 'connector' = 'values',\n"
- + " 'table-sink-class' = 'DEFAULT')";
- tEnv.executeSql(sinkTableDdl);
- assertThatThrownBy(
- () ->
- util.verifyJsonPlan(
- "INSERT INTO MySink SELECT * FROM MyTable AS T JOIN LookupTable "
- + "FOR SYSTEM_TIME AS OF T.proctime AS D ON T.a = D.id"))
- .satisfies(
- anyCauseMatches(
- ValidationException.class,
- "TemporalTableSourceSpec can not be serialized."));
- }
-
- @Test
- void testAggAndLeftJoinWithTryResolveMode() {
- tEnv.getConfig()
- .set(
- OptimizerConfigOptions.TABLE_OPTIMIZER_NONDETERMINISTIC_UPDATE_STRATEGY,
- OptimizerConfigOptions.NonDeterministicUpdateStrategy.TRY_RESOLVE);
-
- util.verifyJsonPlan(
- "INSERT INTO Sink1 "
- + "SELECT T.a, D.name, D.age "
- + "FROM (SELECT max(a) a, count(c) c, PROCTIME() proctime FROM MyTable GROUP BY b) T "
- + "LEFT JOIN LookupTable "
- + "FOR SYSTEM_TIME AS OF T.proctime AS D ON T.a = D.id");
- }
-
- @Test
- void testJoinTemporalTableWithAsyncHint() {
- // LookupTable has sync func only, just verify the hint has take effect
- util.verifyJsonPlan(
- "INSERT INTO MySink1 SELECT "
- + "/*+ LOOKUP('table'='D', 'async'='true', 'output-mode'='allow_unordered') */ * "
- + "FROM MyTable AS T JOIN LookupTable "
- + "FOR SYSTEM_TIME AS OF T.proctime AS D ON T.a = D.id");
- }
-
- @Test
- void testJoinTemporalTableWithAsyncHint2() {
- // LookupTable has sync func only, just verify the hint has take effect
- util.verifyJsonPlan(
- "INSERT INTO MySink1 SELECT "
- + "/*+ LOOKUP('table'='D', 'async'='true', 'timeout'='600s', 'capacity'='1000') */ * "
- + "FROM MyTable AS T JOIN LookupTable "
- + "FOR SYSTEM_TIME AS OF T.proctime AS D ON T.a = D.id");
- }
-
- @Test
- void testJoinTemporalTableWithRetryHint() {
- util.verifyJsonPlan(
- "INSERT INTO MySink1 SELECT "
- + "/*+ LOOKUP('table'='D', 'retry-predicate'='lookup_miss', 'retry-strategy'='fixed_delay', 'fixed-delay'='10s', 'max-attempts'='3') */ * "
- + "FROM MyTable AS T JOIN LookupTable "
- + "FOR SYSTEM_TIME AS OF T.proctime AS D ON T.a = D.id");
- }
-
- @Test
- void testJoinTemporalTableWithAsyncRetryHint() {
- // LookupTable has sync func only, just verify the hint has take effect
- util.verifyJsonPlan(
- "INSERT INTO MySink1 SELECT "
- + "/*+ LOOKUP('table'='D', 'async'='true', 'retry-predicate'='lookup_miss', 'retry-strategy'='fixed_delay', 'fixed-delay'='10s', 'max-attempts'='3') */ * "
- + "FROM MyTable AS T JOIN LookupTable "
- + "FOR SYSTEM_TIME AS OF T.proctime AS D ON T.a = D.id");
- }
-
- @Test
- void testJoinTemporalTableWithAsyncRetryHint2() {
- // LookupTable has sync func only, just verify the hint has take effect
- util.verifyJsonPlan(
- "INSERT INTO MySink1 SELECT "
- + "/*+ LOOKUP('table'='D', 'async'='true', 'timeout'='600s', 'capacity'='1000', 'retry-predicate'='lookup_miss', 'retry-strategy'='fixed_delay', 'fixed-delay'='10s', 'max-attempts'='3') */ * "
- + "FROM MyTable AS T JOIN LookupTable "
- + "FOR SYSTEM_TIME AS OF T.proctime AS D ON T.a = D.id");
- }
-
- @Test
- void testLeftJoinTemporalTableWithPreFilter() {
- util.verifyJsonPlan(
- "INSERT INTO MySink1 SELECT * "
- + "FROM MyTable AS T LEFT JOIN LookupTable "
- + "FOR SYSTEM_TIME AS OF T.proctime AS D ON T.a = D.id AND T.b > 'abc'");
- }
-
- @Test
- void testLeftJoinTemporalTableWithPostFilter() {
- util.verifyJsonPlan(
- "INSERT INTO MySink1 SELECT * "
- + "FROM MyTable AS T LEFT JOIN LookupTable "
- + "FOR SYSTEM_TIME AS OF T.proctime AS D ON T.a = D.id "
- + "AND CHAR_LENGTH(D.name) > CHAR_LENGTH(T.b)");
- }
-
- @Test
- void testLeftJoinTemporalTableWithMultiJoinConditions() {
Review Comment:
This test only adds extra conditions apart from the join condition which is already covered.
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-33647] Implement restore tests for LookupJoin node [flink]
Posted by "jnh5y (via GitHub)" <gi...@apache.org>.
jnh5y commented on code in PR #23814:
URL: https://github.com/apache/flink/pull/23814#discussion_r1421076042
##########
flink-table/flink-table-planner/src/test/resources/restore-tests/stream-exec-lookup-join_1/lookup-join-filter-pushdown/plan/lookup-join-filter-pushdown.json:
##########
@@ -0,0 +1,264 @@
+{
+ "flinkVersion" : "1.19",
+ "nodes" : [ {
+ "id" : 5,
+ "type" : "stream-exec-table-source-scan_1",
+ "scanTableSource" : {
+ "table" : {
+ "identifier" : "`default_catalog`.`default_database`.`orders_t`",
+ "resolvedTable" : {
+ "schema" : {
+ "columns" : [ {
+ "name" : "order_id",
+ "dataType" : "INT"
+ }, {
+ "name" : "customer_id",
+ "dataType" : "INT"
+ }, {
+ "name" : "total",
+ "dataType" : "DOUBLE"
+ }, {
+ "name" : "order_time",
+ "dataType" : "VARCHAR(2147483647)"
+ }, {
+ "name" : "proc_time",
+ "kind" : "COMPUTED",
+ "expression" : {
+ "rexNode" : {
+ "kind" : "CALL",
+ "internalName" : "$PROCTIME$1",
+ "operands" : [ ],
+ "type" : {
+ "type" : "TIMESTAMP_WITH_LOCAL_TIME_ZONE",
+ "nullable" : false,
+ "precision" : 3,
+ "kind" : "PROCTIME"
+ }
+ },
+ "serializableString" : "PROCTIME()"
+ }
+ } ],
+ "watermarkSpecs" : [ ]
+ },
+ "partitionKeys" : [ ]
+ }
+ },
+ "abilities" : [ {
+ "type" : "ProjectPushDown",
+ "projectedFields" : [ [ 0 ], [ 1 ], [ 2 ] ],
+ "producedType" : "ROW<`order_id` INT, `customer_id` INT, `total` DOUBLE> NOT NULL"
+ }, {
+ "type" : "ReadingMetadata",
+ "metadataKeys" : [ ],
+ "producedType" : "ROW<`order_id` INT, `customer_id` INT, `total` DOUBLE> NOT NULL"
+ } ]
+ },
+ "outputType" : "ROW<`order_id` INT, `customer_id` INT, `total` DOUBLE>",
+ "description" : "TableSourceScan(table=[[default_catalog, default_database, orders_t, project=[order_id, customer_id, total], metadata=[]]], fields=[order_id, customer_id, total])",
+ "inputProperties" : [ ]
+ }, {
+ "id" : 6,
+ "type" : "stream-exec-lookup-join_1",
+ "joinType" : "INNER",
+ "joinCondition" : null,
+ "temporalTable" : {
+ "lookupTableSource" : {
+ "table" : {
+ "identifier" : "`default_catalog`.`default_database`.`customers_t`",
+ "resolvedTable" : {
+ "schema" : {
+ "columns" : [ {
+ "name" : "id",
+ "dataType" : "INT NOT NULL"
+ }, {
+ "name" : "name",
+ "dataType" : "VARCHAR(2147483647)"
+ }, {
+ "name" : "age",
+ "dataType" : "INT"
+ }, {
+ "name" : "city",
+ "dataType" : "VARCHAR(2147483647)"
+ }, {
+ "name" : "state",
+ "dataType" : "VARCHAR(2147483647)"
+ }, {
+ "name" : "zipcode",
+ "dataType" : "INT"
+ } ],
+ "watermarkSpecs" : [ ],
+ "primaryKey" : {
+ "name" : "PK_3386",
Review Comment:
@bvarghese1 The compiled plans need to be recomputed so that they pick up the new identifier scheme!
This will fix the present CI failure.
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-33647] Implement restore tests for LookupJoin node [flink]
Posted by "bvarghese1 (via GitHub)" <gi...@apache.org>.
bvarghese1 commented on code in PR #23814:
URL: https://github.com/apache/flink/pull/23814#discussion_r1413375613
##########
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/plan/nodes/exec/stream/LookupJoinTestPrograms.java:
##########
@@ -0,0 +1,287 @@
+/*
+ * 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.stream;
+
+import org.apache.flink.table.test.program.SinkTestStep;
+import org.apache.flink.table.test.program.SourceTestStep;
+import org.apache.flink.table.test.program.TableTestProgram;
+import org.apache.flink.types.Row;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.stream.Collectors;
+
+/** {@link TableTestProgram} definitions for testing {@link StreamExecGroupWindowAggregate}. */
+public class LookupJoinTestPrograms {
+
+ static final SourceTestStep CUSTOMERS =
+ SourceTestStep.newBuilder("customers_t") // static table
+ .addOption("disable-lookup", "false")
+ .addOption("filterable-fields", "age")
+ .addSchema(
+ "id INT PRIMARY KEY NOT ENFORCED",
+ "name STRING",
+ "age INT",
+ "city STRING",
+ "state STRING",
+ "zipcode INT")
+ .producedBeforeRestore(
+ Row.of(1, "Bob", 28, "Mountain View", "California", 94043),
+ Row.of(2, "Alice", 32, "San Francisco", "California", 95016),
+ Row.of(3, "Claire", 37, "Austin", "Texas", 73301),
+ Row.of(4, "Shannon", 29, "Boise", "Idaho", 83701),
+ Row.of(5, "Jake", 42, "New York City", "New York", 10001))
+ // Note: Before data state is not persisted for static tables during savepoint
+ .producedAfterRestore(
+ Row.of(1, "Bob", 28, "San Jose", "California", 94089),
+ Row.of(6, "Joana", 54, "Atlanta", "Georgia", 30033))
+ .build();
+
+ static final SourceTestStep ORDERS =
+ SourceTestStep.newBuilder("orders_t")
+ .addOption("filterable-fields", "customer_id")
+ .addSchema(
+ "order_id INT",
+ "customer_id INT",
+ "total DOUBLE",
+ "order_time STRING",
+ "proc_time AS PROCTIME()")
+ .producedBeforeRestore(
+ Row.of(1, 3, 44.44, "2020-10-10 00:00:01"),
+ Row.of(2, 5, 100.02, "2020-10-10 00:00:02"),
+ Row.of(4, 2, 92.61, "2020-10-10 00:00:04"),
+ Row.of(3, 1, 23.89, "2020-10-10 00:00:03"),
+ Row.of(6, 4, 7.65, "2020-10-10 00:00:06"),
+ Row.of(5, 2, 12.78, "2020-10-10 00:00:05"))
+ .producedAfterRestore(
+ Row.of(7, 6, 17.58, "2020-10-10 00:00:07"), // new customer
+ Row.of(9, 1, 143.21, "2020-10-10 00:00:08") // updated zip code
+ )
+ .build();
+
+ static final List<String> SINK_SCHEMA =
+ Arrays.asList(
+ "order_id INT",
+ "total DOUBLE",
+ "id INT",
+ "name STRING",
+ "age INT",
+ "city STRING",
+ "state STRING",
+ "zipcode INT");
+
+ static final TableTestProgram LOOKUP_JOIN_PROJECT_PUSHDOWN =
+ TableTestProgram.of(
+ "lookup-join-project-pushdown",
+ "validates lookup join with project pushdown")
+ .setupTableSource(CUSTOMERS)
+ .setupTableSource(ORDERS)
+ .setupTableSink(
+ SinkTestStep.newBuilder("sink_t")
+ .addSchema(
+ SINK_SCHEMA.stream()
+ .filter(field -> !field.equals("age INT"))
+ .collect(Collectors.toList()))
+ .consumedBeforeRestore(
+ "+I[1, 44.44, 3, Claire, Austin, Texas, 73301]",
+ "+I[2, 100.02, 5, Jake, New York City, New York, 10001]",
+ "+I[4, 92.61, 2, Alice, San Francisco, California, 95016]",
+ "+I[3, 23.89, 1, Bob, Mountain View, California, 94043]",
+ "+I[6, 7.65, 4, Shannon, Boise, Idaho, 83701]",
+ "+I[5, 12.78, 2, Alice, San Francisco, California, 95016]")
+ .consumedAfterRestore(
+ "+I[7, 17.58, 6, Joana, Atlanta, Georgia, 30033]",
+ "+I[9, 143.21, 1, Bob, San Jose, California, 94089]")
+ .build())
+ .runSql(
+ "INSERT INTO sink_t SELECT "
+ + "O.order_id, "
+ + "O.total, "
+ + "C.id, "
+ + "C.name, "
+ + "C.city, "
+ + "C.state, "
+ + "C.zipcode "
+ + "FROM orders_t as O "
+ + "JOIN customers_t FOR SYSTEM_TIME AS OF O.proc_time AS C "
+ + "ON O.customer_id = C.id")
+ .build();
+
+ static final TableTestProgram LOOKUP_JOIN_FILTER_PUSHDOWN =
+ TableTestProgram.of(
+ "lookup-join-filter-pushdown",
+ "validates lookup join with filter pushdown")
+ .setupTableSource(CUSTOMERS)
+ .setupTableSource(ORDERS)
+ .setupTableSink(
+ SinkTestStep.newBuilder("sink_t")
+ .addSchema(SINK_SCHEMA)
+ .consumedBeforeRestore(
+ "+I[1, 44.44, 3, Claire, 37, Austin, Texas, 73301]",
+ "+I[2, 100.02, 5, Jake, 42, New York City, New York, 10001]",
+ "+I[4, 92.61, 2, Alice, 32, San Francisco, California, 95016]",
+ "+I[5, 12.78, 2, Alice, 32, San Francisco, California, 95016]")
+ .consumedAfterRestore(
+ "+I[7, 17.58, 6, Joana, 54, Atlanta, Georgia, 30033]")
+ .build())
+ .runSql(
+ "INSERT INTO sink_t SELECT "
+ + "O.order_id, "
+ + "O.total, "
+ + "C.id, "
+ + "C.name, "
+ + "C.age, "
+ + "C.city, "
+ + "C.state, "
+ + "C.zipcode "
+ + "FROM orders_t as O "
+ + "JOIN customers_t FOR SYSTEM_TIME AS OF O.proc_time AS C "
+ + "ON O.customer_id = C.id AND C.age > 30")
+ .build();
+
+ static final TableTestProgram LOOKUP_JOIN_PRE_FILTER =
+ TableTestProgram.of("lookup-join-pre-filter", "validates lookup join with pre filter")
+ .setupTableSource(CUSTOMERS)
+ .setupTableSource(ORDERS)
+ .setupTableSink(
+ SinkTestStep.newBuilder("sink_t")
+ .addSchema(SINK_SCHEMA)
+ .consumedBeforeRestore(
+ "+I[2, 100.02, 5, Jake, 42, New York City, New York, 10001]",
+ "+I[4, 92.61, 2, Alice, 32, San Francisco, California, 95016]",
+ "+I[5, 12.78, 2, Alice, 32, San Francisco, California, 95016]")
+ .consumedAfterRestore(
+ "+I[7, 17.58, 6, Joana, 54, Atlanta, Georgia, 30033]")
+ .build())
+ .runSql(
+ "INSERT INTO sink_t SELECT "
+ + "O.order_id, "
+ + "O.total, "
+ + "C.id, "
+ + "C.name, "
+ + "C.age, "
+ + "C.city, "
+ + "C.state, "
+ + "C.zipcode "
+ + "FROM orders_t as O "
+ + "JOIN customers_t FOR SYSTEM_TIME AS OF O.proc_time AS C "
+ + "ON O.customer_id = C.id AND C.age > 30 AND O.customer_id <> 3")
+ .build();
+
+ static final TableTestProgram LOOKUP_JOIN_LEFT_JOIN =
+ TableTestProgram.of("lookup-join-left-join", "validates lookup join with left join")
+ .setupTableSource(CUSTOMERS)
+ .setupTableSource(ORDERS)
+ .setupTableSink(
+ SinkTestStep.newBuilder("sink_t")
+ .addSchema(SINK_SCHEMA)
+ .consumedBeforeRestore(
+ "+I[1, 44.44, null, null, null, null, null, null]",
+ "+I[2, 100.02, 5, Jake, 42, New York City, New York, 10001]",
+ "+I[4, 92.61, 2, Alice, 32, San Francisco, California, 95016]",
+ "+I[3, 23.89, null, null, null, null, null, null]",
+ "+I[6, 7.65, null, null, null, null, null, null]",
+ "+I[5, 12.78, 2, Alice, 32, San Francisco, California, 95016]")
+ .consumedAfterRestore(
+ "+I[7, 17.58, 6, Joana, 54, Atlanta, Georgia, 30033]",
+ "+I[9, 143.21, null, null, null, null, null, null]")
+ .build())
+ .runSql(
+ "INSERT INTO sink_t SELECT "
+ + "O.order_id, "
+ + "O.total, "
+ + "C.id, "
+ + "C.name, "
+ + "C.age, "
+ + "C.city, "
+ + "C.state, "
+ + "C.zipcode "
+ + "FROM orders_t as O "
+ + "LEFT JOIN customers_t FOR SYSTEM_TIME AS OF O.proc_time AS C "
+ + "ON O.customer_id = C.id AND C.age > 30 AND O.customer_id <> 3")
+ .build();
+
+ static final TableTestProgram LOOKUP_JOIN_ASYNC_HINT =
+ TableTestProgram.of("lookup-join-async-hint", "validates lookup join with async hint")
+ .setupTableSource(CUSTOMERS)
+ .setupTableSource(ORDERS)
+ .setupTableSink(
+ SinkTestStep.newBuilder("sink_t")
+ .addSchema(SINK_SCHEMA)
+ .consumedBeforeRestore(
+ "+I[1, 44.44, 3, Claire, 37, Austin, Texas, 73301]",
+ "+I[2, 100.02, 5, Jake, 42, New York City, New York, 10001]",
+ "+I[4, 92.61, 2, Alice, 32, San Francisco, California, 95016]",
+ "+I[3, 23.89, 1, Bob, 28, Mountain View, California, 94043]",
+ "+I[6, 7.65, 4, Shannon, 29, Boise, Idaho, 83701]",
+ "+I[5, 12.78, 2, Alice, 32, San Francisco, California, 95016]")
+ .consumedAfterRestore(
+ "+I[7, 17.58, 6, Joana, 54, Atlanta, Georgia, 30033]",
+ "+I[9, 143.21, 1, Bob, 28, San Jose, California, 94089]")
+ .build())
+ .runSql(
+ "INSERT INTO sink_t SELECT "
+ + "/*+ LOOKUP('table'='C', 'async'='true', 'output-mode'='allow_unordered') */ "
Review Comment:
Fixed this. Now the updated plan has the async options.
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-33647] Implement restore tests for LookupJoin node [flink]
Posted by "bvarghese1 (via GitHub)" <gi...@apache.org>.
bvarghese1 commented on code in PR #23814:
URL: https://github.com/apache/flink/pull/23814#discussion_r1421106534
##########
flink-table/flink-table-planner/src/test/resources/restore-tests/stream-exec-lookup-join_1/lookup-join-filter-pushdown/plan/lookup-join-filter-pushdown.json:
##########
@@ -0,0 +1,264 @@
+{
+ "flinkVersion" : "1.19",
+ "nodes" : [ {
+ "id" : 5,
+ "type" : "stream-exec-table-source-scan_1",
+ "scanTableSource" : {
+ "table" : {
+ "identifier" : "`default_catalog`.`default_database`.`orders_t`",
+ "resolvedTable" : {
+ "schema" : {
+ "columns" : [ {
+ "name" : "order_id",
+ "dataType" : "INT"
+ }, {
+ "name" : "customer_id",
+ "dataType" : "INT"
+ }, {
+ "name" : "total",
+ "dataType" : "DOUBLE"
+ }, {
+ "name" : "order_time",
+ "dataType" : "VARCHAR(2147483647)"
+ }, {
+ "name" : "proc_time",
+ "kind" : "COMPUTED",
+ "expression" : {
+ "rexNode" : {
+ "kind" : "CALL",
+ "internalName" : "$PROCTIME$1",
+ "operands" : [ ],
+ "type" : {
+ "type" : "TIMESTAMP_WITH_LOCAL_TIME_ZONE",
+ "nullable" : false,
+ "precision" : 3,
+ "kind" : "PROCTIME"
+ }
+ },
+ "serializableString" : "PROCTIME()"
+ }
+ } ],
+ "watermarkSpecs" : [ ]
+ },
+ "partitionKeys" : [ ]
+ }
+ },
+ "abilities" : [ {
+ "type" : "ProjectPushDown",
+ "projectedFields" : [ [ 0 ], [ 1 ], [ 2 ] ],
+ "producedType" : "ROW<`order_id` INT, `customer_id` INT, `total` DOUBLE> NOT NULL"
+ }, {
+ "type" : "ReadingMetadata",
+ "metadataKeys" : [ ],
+ "producedType" : "ROW<`order_id` INT, `customer_id` INT, `total` DOUBLE> NOT NULL"
+ } ]
+ },
+ "outputType" : "ROW<`order_id` INT, `customer_id` INT, `total` DOUBLE>",
+ "description" : "TableSourceScan(table=[[default_catalog, default_database, orders_t, project=[order_id, customer_id, total], metadata=[]]], fields=[order_id, customer_id, total])",
+ "inputProperties" : [ ]
+ }, {
+ "id" : 6,
+ "type" : "stream-exec-lookup-join_1",
+ "joinType" : "INNER",
+ "joinCondition" : null,
+ "temporalTable" : {
+ "lookupTableSource" : {
+ "table" : {
+ "identifier" : "`default_catalog`.`default_database`.`customers_t`",
+ "resolvedTable" : {
+ "schema" : {
+ "columns" : [ {
+ "name" : "id",
+ "dataType" : "INT NOT NULL"
+ }, {
+ "name" : "name",
+ "dataType" : "VARCHAR(2147483647)"
+ }, {
+ "name" : "age",
+ "dataType" : "INT"
+ }, {
+ "name" : "city",
+ "dataType" : "VARCHAR(2147483647)"
+ }, {
+ "name" : "state",
+ "dataType" : "VARCHAR(2147483647)"
+ }, {
+ "name" : "zipcode",
+ "dataType" : "INT"
+ } ],
+ "watermarkSpecs" : [ ],
+ "primaryKey" : {
+ "name" : "PK_3386",
Review Comment:
Fixed. Thanks @jnh5y
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-33647] Implement restore tests for LookupJoin node [flink]
Posted by "bvarghese1 (via GitHub)" <gi...@apache.org>.
bvarghese1 commented on code in PR #23814:
URL: https://github.com/apache/flink/pull/23814#discussion_r1419886852
##########
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/plan/nodes/exec/stream/LookupJoinJsonPlanTest.java:
##########
@@ -1,273 +0,0 @@
-/*
- * 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.stream;
-
-import org.apache.flink.api.common.typeinfo.Types;
-import org.apache.flink.table.api.TableConfig;
-import org.apache.flink.table.api.TableEnvironment;
-import org.apache.flink.table.api.TableSchema;
-import org.apache.flink.table.api.ValidationException;
-import org.apache.flink.table.api.config.OptimizerConfigOptions;
-import org.apache.flink.table.planner.runtime.utils.InMemoryLookupableTableSource;
-import org.apache.flink.table.planner.utils.StreamTableTestUtil;
-import org.apache.flink.table.planner.utils.TableTestBase;
-import org.apache.flink.types.Row;
-
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-
-import java.util.ArrayList;
-
-import scala.collection.JavaConverters;
-
-import static org.apache.flink.core.testutils.FlinkAssertions.anyCauseMatches;
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
-
-/** Test json serialization/deserialization for LookupJoin. */
-class LookupJoinJsonPlanTest extends TableTestBase {
-
- private StreamTableTestUtil util;
- private TableEnvironment tEnv;
-
- @BeforeEach
- void setup() {
- util = streamTestUtil(TableConfig.getDefault());
- tEnv = util.getTableEnv();
-
- String srcTableA =
- "CREATE TABLE MyTable (\n"
- + " a int,\n"
- + " b varchar,\n"
- + " c bigint,\n"
- + " proctime as PROCTIME(),\n"
- + " rowtime as TO_TIMESTAMP(FROM_UNIXTIME(c)),\n"
- + " watermark for rowtime as rowtime - INTERVAL '1' second \n"
- + ") with (\n"
- + " 'connector' = 'values',\n"
- + " 'bounded' = 'false')";
- String srcTableB =
- "CREATE TABLE LookupTable (\n"
- + " id int,\n"
- + " name varchar,\n"
- + " age int \n"
- + ") with (\n"
- + " 'connector' = 'values',\n"
- + " 'bounded' = 'false')";
- String sinkTable1 =
- "CREATE TABLE Sink1 (\n"
- + " a int,\n"
- + " name varchar,"
- + " age int"
- + ") with (\n"
- + " 'connector' = 'values',\n"
- + " 'sink-insert-only' = 'false')";
- String sinkTable2 =
- "CREATE TABLE MySink1 (\n"
- + " a int,\n"
- + " b varchar,"
- + " c bigint,"
- + " proctime timestamp(3),"
- + " rowtime timestamp(3),"
- + " id int,"
- + " name varchar,"
- + " age int"
- + ") with (\n"
- + " 'connector' = 'values',\n"
- + " 'table-sink-class' = 'DEFAULT')";
- tEnv.executeSql(srcTableA);
- tEnv.executeSql(srcTableB);
- tEnv.executeSql(sinkTable1);
- tEnv.executeSql(sinkTable2);
- }
-
- @Test
- void testJoinTemporalTable() {
- String sinkTableDdl =
- "CREATE TABLE MySink (\n"
- + " a int,\n"
- + " b varchar,"
- + " c bigint,"
- + " proctime timestamp(3),"
- + " rowtime timestamp(3),"
- + " id int,"
- + " name varchar,"
- + " age int"
- + ") with (\n"
- + " 'connector' = 'values',\n"
- + " 'table-sink-class' = 'DEFAULT')";
- tEnv.executeSql(sinkTableDdl);
- util.verifyJsonPlan(
- "INSERT INTO MySink SELECT * FROM MyTable AS T JOIN LookupTable "
- + "FOR SYSTEM_TIME AS OF T.proctime AS D ON T.a = D.id");
- }
-
- @Test
- void testJoinTemporalTableWithProjectionPushDown() {
- String sinkTableDdl =
- "CREATE TABLE MySink (\n"
- + " a int,\n"
- + " b varchar,"
- + " c bigint,"
- + " proctime timestamp(3),"
- + " rowtime timestamp(3),"
- + " id int"
- + ") with (\n"
- + " 'connector' = 'values',\n"
- + " 'table-sink-class' = 'DEFAULT')";
- tEnv.executeSql(sinkTableDdl);
- util.verifyJsonPlan(
- "INSERT INTO MySink \n"
- + "SELECT T.*, D.id \n"
- + "FROM MyTable AS T \n"
- + "JOIN LookupTable FOR SYSTEM_TIME AS OF T.proctime AS D \n"
- + "ON T.a = D.id\n");
- }
-
- @Test
- void testLegacyTableSourceException() {
- TableSchema tableSchema =
- TableSchema.builder()
- .field("id", Types.INT)
- .field("name", Types.STRING)
- .field("age", Types.INT)
- .build();
- InMemoryLookupableTableSource.createTemporaryTable(
- tEnv,
- false,
- JavaConverters.asScalaIteratorConverter(new ArrayList<Row>().iterator())
- .asScala()
- .toList(),
- tableSchema,
- "LookupTable",
- true);
- String sinkTableDdl =
- "CREATE TABLE MySink (\n"
- + " a int,\n"
- + " b varchar,"
- + " c bigint,"
- + " proctime timestamp(3),"
- + " rowtime timestamp(3),"
- + " id int,"
- + " name varchar,"
- + " age int"
- + ") with (\n"
- + " 'connector' = 'values',\n"
- + " 'table-sink-class' = 'DEFAULT')";
- tEnv.executeSql(sinkTableDdl);
- assertThatThrownBy(
- () ->
- util.verifyJsonPlan(
- "INSERT INTO MySink SELECT * FROM MyTable AS T JOIN LookupTable "
- + "FOR SYSTEM_TIME AS OF T.proctime AS D ON T.a = D.id"))
- .satisfies(
- anyCauseMatches(
- ValidationException.class,
- "TemporalTableSourceSpec can not be serialized."));
- }
-
- @Test
- void testAggAndLeftJoinWithTryResolveMode() {
- tEnv.getConfig()
- .set(
- OptimizerConfigOptions.TABLE_OPTIMIZER_NONDETERMINISTIC_UPDATE_STRATEGY,
- OptimizerConfigOptions.NonDeterministicUpdateStrategy.TRY_RESOLVE);
-
- util.verifyJsonPlan(
- "INSERT INTO Sink1 "
- + "SELECT T.a, D.name, D.age "
- + "FROM (SELECT max(a) a, count(c) c, PROCTIME() proctime FROM MyTable GROUP BY b) T "
- + "LEFT JOIN LookupTable "
- + "FOR SYSTEM_TIME AS OF T.proctime AS D ON T.a = D.id");
- }
-
- @Test
- void testJoinTemporalTableWithAsyncHint() {
- // LookupTable has sync func only, just verify the hint has take effect
- util.verifyJsonPlan(
- "INSERT INTO MySink1 SELECT "
- + "/*+ LOOKUP('table'='D', 'async'='true', 'output-mode'='allow_unordered') */ * "
- + "FROM MyTable AS T JOIN LookupTable "
- + "FOR SYSTEM_TIME AS OF T.proctime AS D ON T.a = D.id");
- }
-
- @Test
- void testJoinTemporalTableWithAsyncHint2() {
- // LookupTable has sync func only, just verify the hint has take effect
- util.verifyJsonPlan(
- "INSERT INTO MySink1 SELECT "
- + "/*+ LOOKUP('table'='D', 'async'='true', 'timeout'='600s', 'capacity'='1000') */ * "
- + "FROM MyTable AS T JOIN LookupTable "
- + "FOR SYSTEM_TIME AS OF T.proctime AS D ON T.a = D.id");
- }
-
- @Test
- void testJoinTemporalTableWithRetryHint() {
- util.verifyJsonPlan(
- "INSERT INTO MySink1 SELECT "
- + "/*+ LOOKUP('table'='D', 'retry-predicate'='lookup_miss', 'retry-strategy'='fixed_delay', 'fixed-delay'='10s', 'max-attempts'='3') */ * "
- + "FROM MyTable AS T JOIN LookupTable "
- + "FOR SYSTEM_TIME AS OF T.proctime AS D ON T.a = D.id");
- }
-
- @Test
- void testJoinTemporalTableWithAsyncRetryHint() {
- // LookupTable has sync func only, just verify the hint has take effect
- util.verifyJsonPlan(
- "INSERT INTO MySink1 SELECT "
- + "/*+ LOOKUP('table'='D', 'async'='true', 'retry-predicate'='lookup_miss', 'retry-strategy'='fixed_delay', 'fixed-delay'='10s', 'max-attempts'='3') */ * "
- + "FROM MyTable AS T JOIN LookupTable "
- + "FOR SYSTEM_TIME AS OF T.proctime AS D ON T.a = D.id");
- }
-
- @Test
- void testJoinTemporalTableWithAsyncRetryHint2() {
- // LookupTable has sync func only, just verify the hint has take effect
- util.verifyJsonPlan(
- "INSERT INTO MySink1 SELECT "
- + "/*+ LOOKUP('table'='D', 'async'='true', 'timeout'='600s', 'capacity'='1000', 'retry-predicate'='lookup_miss', 'retry-strategy'='fixed_delay', 'fixed-delay'='10s', 'max-attempts'='3') */ * "
- + "FROM MyTable AS T JOIN LookupTable "
- + "FOR SYSTEM_TIME AS OF T.proctime AS D ON T.a = D.id");
- }
-
- @Test
- void testLeftJoinTemporalTableWithPreFilter() {
- util.verifyJsonPlan(
- "INSERT INTO MySink1 SELECT * "
- + "FROM MyTable AS T LEFT JOIN LookupTable "
- + "FOR SYSTEM_TIME AS OF T.proctime AS D ON T.a = D.id AND T.b > 'abc'");
- }
-
- @Test
- void testLeftJoinTemporalTableWithPostFilter() {
- util.verifyJsonPlan(
- "INSERT INTO MySink1 SELECT * "
- + "FROM MyTable AS T LEFT JOIN LookupTable "
- + "FOR SYSTEM_TIME AS OF T.proctime AS D ON T.a = D.id "
- + "AND CHAR_LENGTH(D.name) > CHAR_LENGTH(T.b)");
- }
-
- @Test
- void testLeftJoinTemporalTableWithMultiJoinConditions() {
Review Comment:
Yes the pre-post test covers this.
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-33647] Implement restore tests for LookupJoin node [flink]
Posted by "bvarghese1 (via GitHub)" <gi...@apache.org>.
bvarghese1 commented on code in PR #23814:
URL: https://github.com/apache/flink/pull/23814#discussion_r1413375404
##########
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/plan/nodes/exec/stream/LookupJoinTestPrograms.java:
##########
@@ -0,0 +1,287 @@
+/*
+ * 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.stream;
+
+import org.apache.flink.table.test.program.SinkTestStep;
+import org.apache.flink.table.test.program.SourceTestStep;
+import org.apache.flink.table.test.program.TableTestProgram;
+import org.apache.flink.types.Row;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.stream.Collectors;
+
+/** {@link TableTestProgram} definitions for testing {@link StreamExecGroupWindowAggregate}. */
+public class LookupJoinTestPrograms {
+
+ static final SourceTestStep CUSTOMERS =
+ SourceTestStep.newBuilder("customers_t") // static table
+ .addOption("disable-lookup", "false")
+ .addOption("filterable-fields", "age")
+ .addSchema(
+ "id INT PRIMARY KEY NOT ENFORCED",
+ "name STRING",
+ "age INT",
+ "city STRING",
+ "state STRING",
+ "zipcode INT")
+ .producedBeforeRestore(
+ Row.of(1, "Bob", 28, "Mountain View", "California", 94043),
+ Row.of(2, "Alice", 32, "San Francisco", "California", 95016),
+ Row.of(3, "Claire", 37, "Austin", "Texas", 73301),
+ Row.of(4, "Shannon", 29, "Boise", "Idaho", 83701),
+ Row.of(5, "Jake", 42, "New York City", "New York", 10001))
+ // Note: Before data state is not persisted for static tables during savepoint
+ .producedAfterRestore(
+ Row.of(1, "Bob", 28, "San Jose", "California", 94089),
+ Row.of(6, "Joana", 54, "Atlanta", "Georgia", 30033))
+ .build();
+
+ static final SourceTestStep ORDERS =
+ SourceTestStep.newBuilder("orders_t")
+ .addOption("filterable-fields", "customer_id")
+ .addSchema(
+ "order_id INT",
+ "customer_id INT",
+ "total DOUBLE",
+ "order_time STRING",
+ "proc_time AS PROCTIME()")
+ .producedBeforeRestore(
+ Row.of(1, 3, 44.44, "2020-10-10 00:00:01"),
+ Row.of(2, 5, 100.02, "2020-10-10 00:00:02"),
+ Row.of(4, 2, 92.61, "2020-10-10 00:00:04"),
+ Row.of(3, 1, 23.89, "2020-10-10 00:00:03"),
+ Row.of(6, 4, 7.65, "2020-10-10 00:00:06"),
+ Row.of(5, 2, 12.78, "2020-10-10 00:00:05"))
+ .producedAfterRestore(
+ Row.of(7, 6, 17.58, "2020-10-10 00:00:07"), // new customer
+ Row.of(9, 1, 143.21, "2020-10-10 00:00:08") // updated zip code
+ )
+ .build();
+
+ static final List<String> SINK_SCHEMA =
+ Arrays.asList(
+ "order_id INT",
+ "total DOUBLE",
+ "id INT",
+ "name STRING",
+ "age INT",
+ "city STRING",
+ "state STRING",
+ "zipcode INT");
+
+ static final TableTestProgram LOOKUP_JOIN_PROJECT_PUSHDOWN =
+ TableTestProgram.of(
+ "lookup-join-project-pushdown",
+ "validates lookup join with project pushdown")
+ .setupTableSource(CUSTOMERS)
+ .setupTableSource(ORDERS)
+ .setupTableSink(
+ SinkTestStep.newBuilder("sink_t")
+ .addSchema(
+ SINK_SCHEMA.stream()
+ .filter(field -> !field.equals("age INT"))
+ .collect(Collectors.toList()))
+ .consumedBeforeRestore(
+ "+I[1, 44.44, 3, Claire, Austin, Texas, 73301]",
+ "+I[2, 100.02, 5, Jake, New York City, New York, 10001]",
+ "+I[4, 92.61, 2, Alice, San Francisco, California, 95016]",
+ "+I[3, 23.89, 1, Bob, Mountain View, California, 94043]",
+ "+I[6, 7.65, 4, Shannon, Boise, Idaho, 83701]",
+ "+I[5, 12.78, 2, Alice, San Francisco, California, 95016]")
+ .consumedAfterRestore(
+ "+I[7, 17.58, 6, Joana, Atlanta, Georgia, 30033]",
+ "+I[9, 143.21, 1, Bob, San Jose, California, 94089]")
+ .build())
+ .runSql(
+ "INSERT INTO sink_t SELECT "
+ + "O.order_id, "
+ + "O.total, "
+ + "C.id, "
+ + "C.name, "
+ + "C.city, "
+ + "C.state, "
+ + "C.zipcode "
+ + "FROM orders_t as O "
+ + "JOIN customers_t FOR SYSTEM_TIME AS OF O.proc_time AS C "
+ + "ON O.customer_id = C.id")
+ .build();
+
+ static final TableTestProgram LOOKUP_JOIN_FILTER_PUSHDOWN =
+ TableTestProgram.of(
+ "lookup-join-filter-pushdown",
+ "validates lookup join with filter pushdown")
+ .setupTableSource(CUSTOMERS)
+ .setupTableSource(ORDERS)
+ .setupTableSink(
+ SinkTestStep.newBuilder("sink_t")
+ .addSchema(SINK_SCHEMA)
+ .consumedBeforeRestore(
+ "+I[1, 44.44, 3, Claire, 37, Austin, Texas, 73301]",
+ "+I[2, 100.02, 5, Jake, 42, New York City, New York, 10001]",
+ "+I[4, 92.61, 2, Alice, 32, San Francisco, California, 95016]",
+ "+I[5, 12.78, 2, Alice, 32, San Francisco, California, 95016]")
+ .consumedAfterRestore(
+ "+I[7, 17.58, 6, Joana, 54, Atlanta, Georgia, 30033]")
+ .build())
+ .runSql(
+ "INSERT INTO sink_t SELECT "
+ + "O.order_id, "
+ + "O.total, "
+ + "C.id, "
+ + "C.name, "
+ + "C.age, "
+ + "C.city, "
+ + "C.state, "
+ + "C.zipcode "
+ + "FROM orders_t as O "
+ + "JOIN customers_t FOR SYSTEM_TIME AS OF O.proc_time AS C "
+ + "ON O.customer_id = C.id AND C.age > 30")
+ .build();
+
+ static final TableTestProgram LOOKUP_JOIN_PRE_FILTER =
+ TableTestProgram.of("lookup-join-pre-filter", "validates lookup join with pre filter")
+ .setupTableSource(CUSTOMERS)
+ .setupTableSource(ORDERS)
+ .setupTableSink(
+ SinkTestStep.newBuilder("sink_t")
+ .addSchema(SINK_SCHEMA)
+ .consumedBeforeRestore(
+ "+I[2, 100.02, 5, Jake, 42, New York City, New York, 10001]",
+ "+I[4, 92.61, 2, Alice, 32, San Francisco, California, 95016]",
+ "+I[5, 12.78, 2, Alice, 32, San Francisco, California, 95016]")
+ .consumedAfterRestore(
+ "+I[7, 17.58, 6, Joana, 54, Atlanta, Georgia, 30033]")
+ .build())
+ .runSql(
+ "INSERT INTO sink_t SELECT "
+ + "O.order_id, "
+ + "O.total, "
+ + "C.id, "
+ + "C.name, "
+ + "C.age, "
+ + "C.city, "
+ + "C.state, "
+ + "C.zipcode "
+ + "FROM orders_t as O "
+ + "JOIN customers_t FOR SYSTEM_TIME AS OF O.proc_time AS C "
+ + "ON O.customer_id = C.id AND C.age > 30 AND O.customer_id <> 3")
Review Comment:
Changed as suggested.
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-33647] Implement restore tests for LookupJoin node [flink]
Posted by "dawidwys (via GitHub)" <gi...@apache.org>.
dawidwys merged PR #23814:
URL: https://github.com/apache/flink/pull/23814
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-33647] Implement restore tests for LookupJoin node [flink]
Posted by "bvarghese1 (via GitHub)" <gi...@apache.org>.
bvarghese1 commented on code in PR #23814:
URL: https://github.com/apache/flink/pull/23814#discussion_r1419886732
##########
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/plan/nodes/exec/stream/LookupJoinJsonPlanTest.java:
##########
@@ -1,273 +0,0 @@
-/*
- * 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.stream;
-
-import org.apache.flink.api.common.typeinfo.Types;
-import org.apache.flink.table.api.TableConfig;
-import org.apache.flink.table.api.TableEnvironment;
-import org.apache.flink.table.api.TableSchema;
-import org.apache.flink.table.api.ValidationException;
-import org.apache.flink.table.api.config.OptimizerConfigOptions;
-import org.apache.flink.table.planner.runtime.utils.InMemoryLookupableTableSource;
-import org.apache.flink.table.planner.utils.StreamTableTestUtil;
-import org.apache.flink.table.planner.utils.TableTestBase;
-import org.apache.flink.types.Row;
-
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-
-import java.util.ArrayList;
-
-import scala.collection.JavaConverters;
-
-import static org.apache.flink.core.testutils.FlinkAssertions.anyCauseMatches;
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
-
-/** Test json serialization/deserialization for LookupJoin. */
-class LookupJoinJsonPlanTest extends TableTestBase {
-
- private StreamTableTestUtil util;
- private TableEnvironment tEnv;
-
- @BeforeEach
- void setup() {
- util = streamTestUtil(TableConfig.getDefault());
- tEnv = util.getTableEnv();
-
- String srcTableA =
- "CREATE TABLE MyTable (\n"
- + " a int,\n"
- + " b varchar,\n"
- + " c bigint,\n"
- + " proctime as PROCTIME(),\n"
- + " rowtime as TO_TIMESTAMP(FROM_UNIXTIME(c)),\n"
- + " watermark for rowtime as rowtime - INTERVAL '1' second \n"
- + ") with (\n"
- + " 'connector' = 'values',\n"
- + " 'bounded' = 'false')";
- String srcTableB =
- "CREATE TABLE LookupTable (\n"
- + " id int,\n"
- + " name varchar,\n"
- + " age int \n"
- + ") with (\n"
- + " 'connector' = 'values',\n"
- + " 'bounded' = 'false')";
- String sinkTable1 =
- "CREATE TABLE Sink1 (\n"
- + " a int,\n"
- + " name varchar,"
- + " age int"
- + ") with (\n"
- + " 'connector' = 'values',\n"
- + " 'sink-insert-only' = 'false')";
- String sinkTable2 =
- "CREATE TABLE MySink1 (\n"
- + " a int,\n"
- + " b varchar,"
- + " c bigint,"
- + " proctime timestamp(3),"
- + " rowtime timestamp(3),"
- + " id int,"
- + " name varchar,"
- + " age int"
- + ") with (\n"
- + " 'connector' = 'values',\n"
- + " 'table-sink-class' = 'DEFAULT')";
- tEnv.executeSql(srcTableA);
- tEnv.executeSql(srcTableB);
- tEnv.executeSql(sinkTable1);
- tEnv.executeSql(sinkTable2);
- }
-
- @Test
- void testJoinTemporalTable() {
- String sinkTableDdl =
- "CREATE TABLE MySink (\n"
- + " a int,\n"
- + " b varchar,"
- + " c bigint,"
- + " proctime timestamp(3),"
- + " rowtime timestamp(3),"
- + " id int,"
- + " name varchar,"
- + " age int"
- + ") with (\n"
- + " 'connector' = 'values',\n"
- + " 'table-sink-class' = 'DEFAULT')";
- tEnv.executeSql(sinkTableDdl);
- util.verifyJsonPlan(
- "INSERT INTO MySink SELECT * FROM MyTable AS T JOIN LookupTable "
- + "FOR SYSTEM_TIME AS OF T.proctime AS D ON T.a = D.id");
- }
-
- @Test
- void testJoinTemporalTableWithProjectionPushDown() {
- String sinkTableDdl =
- "CREATE TABLE MySink (\n"
- + " a int,\n"
- + " b varchar,"
- + " c bigint,"
- + " proctime timestamp(3),"
- + " rowtime timestamp(3),"
- + " id int"
- + ") with (\n"
- + " 'connector' = 'values',\n"
- + " 'table-sink-class' = 'DEFAULT')";
- tEnv.executeSql(sinkTableDdl);
- util.verifyJsonPlan(
- "INSERT INTO MySink \n"
- + "SELECT T.*, D.id \n"
- + "FROM MyTable AS T \n"
- + "JOIN LookupTable FOR SYSTEM_TIME AS OF T.proctime AS D \n"
- + "ON T.a = D.id\n");
- }
-
- @Test
- void testLegacyTableSourceException() {
- TableSchema tableSchema =
- TableSchema.builder()
- .field("id", Types.INT)
- .field("name", Types.STRING)
- .field("age", Types.INT)
- .build();
- InMemoryLookupableTableSource.createTemporaryTable(
- tEnv,
- false,
- JavaConverters.asScalaIteratorConverter(new ArrayList<Row>().iterator())
- .asScala()
- .toList(),
- tableSchema,
- "LookupTable",
- true);
- String sinkTableDdl =
- "CREATE TABLE MySink (\n"
- + " a int,\n"
- + " b varchar,"
- + " c bigint,"
- + " proctime timestamp(3),"
- + " rowtime timestamp(3),"
- + " id int,"
- + " name varchar,"
- + " age int"
- + ") with (\n"
- + " 'connector' = 'values',\n"
- + " 'table-sink-class' = 'DEFAULT')";
- tEnv.executeSql(sinkTableDdl);
- assertThatThrownBy(
- () ->
- util.verifyJsonPlan(
- "INSERT INTO MySink SELECT * FROM MyTable AS T JOIN LookupTable "
- + "FOR SYSTEM_TIME AS OF T.proctime AS D ON T.a = D.id"))
- .satisfies(
- anyCauseMatches(
- ValidationException.class,
- "TemporalTableSourceSpec can not be serialized."));
- }
-
- @Test
- void testAggAndLeftJoinWithTryResolveMode() {
- tEnv.getConfig()
- .set(
- OptimizerConfigOptions.TABLE_OPTIMIZER_NONDETERMINISTIC_UPDATE_STRATEGY,
- OptimizerConfigOptions.NonDeterministicUpdateStrategy.TRY_RESOLVE);
-
- util.verifyJsonPlan(
- "INSERT INTO Sink1 "
- + "SELECT T.a, D.name, D.age "
- + "FROM (SELECT max(a) a, count(c) c, PROCTIME() proctime FROM MyTable GROUP BY b) T "
- + "LEFT JOIN LookupTable "
- + "FOR SYSTEM_TIME AS OF T.proctime AS D ON T.a = D.id");
- }
-
- @Test
- void testJoinTemporalTableWithAsyncHint() {
- // LookupTable has sync func only, just verify the hint has take effect
- util.verifyJsonPlan(
- "INSERT INTO MySink1 SELECT "
- + "/*+ LOOKUP('table'='D', 'async'='true', 'output-mode'='allow_unordered') */ * "
- + "FROM MyTable AS T JOIN LookupTable "
- + "FOR SYSTEM_TIME AS OF T.proctime AS D ON T.a = D.id");
- }
-
- @Test
- void testJoinTemporalTableWithAsyncHint2() {
- // LookupTable has sync func only, just verify the hint has take effect
- util.verifyJsonPlan(
- "INSERT INTO MySink1 SELECT "
- + "/*+ LOOKUP('table'='D', 'async'='true', 'timeout'='600s', 'capacity'='1000') */ * "
- + "FROM MyTable AS T JOIN LookupTable "
- + "FOR SYSTEM_TIME AS OF T.proctime AS D ON T.a = D.id");
- }
-
- @Test
- void testJoinTemporalTableWithRetryHint() {
- util.verifyJsonPlan(
- "INSERT INTO MySink1 SELECT "
- + "/*+ LOOKUP('table'='D', 'retry-predicate'='lookup_miss', 'retry-strategy'='fixed_delay', 'fixed-delay'='10s', 'max-attempts'='3') */ * "
- + "FROM MyTable AS T JOIN LookupTable "
- + "FOR SYSTEM_TIME AS OF T.proctime AS D ON T.a = D.id");
- }
-
- @Test
- void testJoinTemporalTableWithAsyncRetryHint() {
- // LookupTable has sync func only, just verify the hint has take effect
- util.verifyJsonPlan(
- "INSERT INTO MySink1 SELECT "
- + "/*+ LOOKUP('table'='D', 'async'='true', 'retry-predicate'='lookup_miss', 'retry-strategy'='fixed_delay', 'fixed-delay'='10s', 'max-attempts'='3') */ * "
- + "FROM MyTable AS T JOIN LookupTable "
- + "FOR SYSTEM_TIME AS OF T.proctime AS D ON T.a = D.id");
- }
-
- @Test
- void testJoinTemporalTableWithAsyncRetryHint2() {
- // LookupTable has sync func only, just verify the hint has take effect
- util.verifyJsonPlan(
- "INSERT INTO MySink1 SELECT "
- + "/*+ LOOKUP('table'='D', 'async'='true', 'timeout'='600s', 'capacity'='1000', 'retry-predicate'='lookup_miss', 'retry-strategy'='fixed_delay', 'fixed-delay'='10s', 'max-attempts'='3') */ * "
- + "FROM MyTable AS T JOIN LookupTable "
- + "FOR SYSTEM_TIME AS OF T.proctime AS D ON T.a = D.id");
- }
-
- @Test
- void testLeftJoinTemporalTableWithPreFilter() {
- util.verifyJsonPlan(
- "INSERT INTO MySink1 SELECT * "
- + "FROM MyTable AS T LEFT JOIN LookupTable "
- + "FOR SYSTEM_TIME AS OF T.proctime AS D ON T.a = D.id AND T.b > 'abc'");
- }
-
- @Test
- void testLeftJoinTemporalTableWithPostFilter() {
Review Comment:
Yes I split the pre-post test into two which covers this explicitly.
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-33647] Implement restore tests for LookupJoin node [flink]
Posted by "jnh5y (via GitHub)" <gi...@apache.org>.
jnh5y commented on code in PR #23814:
URL: https://github.com/apache/flink/pull/23814#discussion_r1421076042
##########
flink-table/flink-table-planner/src/test/resources/restore-tests/stream-exec-lookup-join_1/lookup-join-filter-pushdown/plan/lookup-join-filter-pushdown.json:
##########
@@ -0,0 +1,264 @@
+{
+ "flinkVersion" : "1.19",
+ "nodes" : [ {
+ "id" : 5,
+ "type" : "stream-exec-table-source-scan_1",
+ "scanTableSource" : {
+ "table" : {
+ "identifier" : "`default_catalog`.`default_database`.`orders_t`",
+ "resolvedTable" : {
+ "schema" : {
+ "columns" : [ {
+ "name" : "order_id",
+ "dataType" : "INT"
+ }, {
+ "name" : "customer_id",
+ "dataType" : "INT"
+ }, {
+ "name" : "total",
+ "dataType" : "DOUBLE"
+ }, {
+ "name" : "order_time",
+ "dataType" : "VARCHAR(2147483647)"
+ }, {
+ "name" : "proc_time",
+ "kind" : "COMPUTED",
+ "expression" : {
+ "rexNode" : {
+ "kind" : "CALL",
+ "internalName" : "$PROCTIME$1",
+ "operands" : [ ],
+ "type" : {
+ "type" : "TIMESTAMP_WITH_LOCAL_TIME_ZONE",
+ "nullable" : false,
+ "precision" : 3,
+ "kind" : "PROCTIME"
+ }
+ },
+ "serializableString" : "PROCTIME()"
+ }
+ } ],
+ "watermarkSpecs" : [ ]
+ },
+ "partitionKeys" : [ ]
+ }
+ },
+ "abilities" : [ {
+ "type" : "ProjectPushDown",
+ "projectedFields" : [ [ 0 ], [ 1 ], [ 2 ] ],
+ "producedType" : "ROW<`order_id` INT, `customer_id` INT, `total` DOUBLE> NOT NULL"
+ }, {
+ "type" : "ReadingMetadata",
+ "metadataKeys" : [ ],
+ "producedType" : "ROW<`order_id` INT, `customer_id` INT, `total` DOUBLE> NOT NULL"
+ } ]
+ },
+ "outputType" : "ROW<`order_id` INT, `customer_id` INT, `total` DOUBLE>",
+ "description" : "TableSourceScan(table=[[default_catalog, default_database, orders_t, project=[order_id, customer_id, total], metadata=[]]], fields=[order_id, customer_id, total])",
+ "inputProperties" : [ ]
+ }, {
+ "id" : 6,
+ "type" : "stream-exec-lookup-join_1",
+ "joinType" : "INNER",
+ "joinCondition" : null,
+ "temporalTable" : {
+ "lookupTableSource" : {
+ "table" : {
+ "identifier" : "`default_catalog`.`default_database`.`customers_t`",
+ "resolvedTable" : {
+ "schema" : {
+ "columns" : [ {
+ "name" : "id",
+ "dataType" : "INT NOT NULL"
+ }, {
+ "name" : "name",
+ "dataType" : "VARCHAR(2147483647)"
+ }, {
+ "name" : "age",
+ "dataType" : "INT"
+ }, {
+ "name" : "city",
+ "dataType" : "VARCHAR(2147483647)"
+ }, {
+ "name" : "state",
+ "dataType" : "VARCHAR(2147483647)"
+ }, {
+ "name" : "zipcode",
+ "dataType" : "INT"
+ } ],
+ "watermarkSpecs" : [ ],
+ "primaryKey" : {
+ "name" : "PK_3386",
Review Comment:
@bvarghese1 The compiled plans need to be recomputed so that they pick up the new identifier scheme!
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-33647] Implement restore tests for LookupJoin node [flink]
Posted by "bvarghese1 (via GitHub)" <gi...@apache.org>.
bvarghese1 commented on code in PR #23814:
URL: https://github.com/apache/flink/pull/23814#discussion_r1419461234
##########
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/plan/nodes/exec/stream/LookupJoinTestPrograms.java:
##########
@@ -0,0 +1,287 @@
+/*
+ * 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.stream;
+
+import org.apache.flink.table.test.program.SinkTestStep;
+import org.apache.flink.table.test.program.SourceTestStep;
+import org.apache.flink.table.test.program.TableTestProgram;
+import org.apache.flink.types.Row;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.stream.Collectors;
+
+/** {@link TableTestProgram} definitions for testing {@link StreamExecGroupWindowAggregate}. */
Review Comment:
Fixed
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-33647] Implement restore tests for LookupJoin node [flink]
Posted by "dawidwys (via GitHub)" <gi...@apache.org>.
dawidwys commented on code in PR #23814:
URL: https://github.com/apache/flink/pull/23814#discussion_r1410461388
##########
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/plan/nodes/exec/stream/LookupJoinTestPrograms.java:
##########
@@ -0,0 +1,287 @@
+/*
+ * 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.stream;
+
+import org.apache.flink.table.test.program.SinkTestStep;
+import org.apache.flink.table.test.program.SourceTestStep;
+import org.apache.flink.table.test.program.TableTestProgram;
+import org.apache.flink.types.Row;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.stream.Collectors;
+
+/** {@link TableTestProgram} definitions for testing {@link StreamExecGroupWindowAggregate}. */
+public class LookupJoinTestPrograms {
+
+ static final SourceTestStep CUSTOMERS =
+ SourceTestStep.newBuilder("customers_t") // static table
+ .addOption("disable-lookup", "false")
+ .addOption("filterable-fields", "age")
+ .addSchema(
+ "id INT PRIMARY KEY NOT ENFORCED",
+ "name STRING",
+ "age INT",
+ "city STRING",
+ "state STRING",
+ "zipcode INT")
+ .producedBeforeRestore(
+ Row.of(1, "Bob", 28, "Mountain View", "California", 94043),
+ Row.of(2, "Alice", 32, "San Francisco", "California", 95016),
+ Row.of(3, "Claire", 37, "Austin", "Texas", 73301),
+ Row.of(4, "Shannon", 29, "Boise", "Idaho", 83701),
+ Row.of(5, "Jake", 42, "New York City", "New York", 10001))
+ // Note: Before data state is not persisted for static tables during savepoint
+ .producedAfterRestore(
+ Row.of(1, "Bob", 28, "San Jose", "California", 94089),
+ Row.of(6, "Joana", 54, "Atlanta", "Georgia", 30033))
+ .build();
+
+ static final SourceTestStep ORDERS =
+ SourceTestStep.newBuilder("orders_t")
+ .addOption("filterable-fields", "customer_id")
+ .addSchema(
+ "order_id INT",
+ "customer_id INT",
+ "total DOUBLE",
+ "order_time STRING",
+ "proc_time AS PROCTIME()")
+ .producedBeforeRestore(
+ Row.of(1, 3, 44.44, "2020-10-10 00:00:01"),
+ Row.of(2, 5, 100.02, "2020-10-10 00:00:02"),
+ Row.of(4, 2, 92.61, "2020-10-10 00:00:04"),
+ Row.of(3, 1, 23.89, "2020-10-10 00:00:03"),
+ Row.of(6, 4, 7.65, "2020-10-10 00:00:06"),
+ Row.of(5, 2, 12.78, "2020-10-10 00:00:05"))
+ .producedAfterRestore(
+ Row.of(7, 6, 17.58, "2020-10-10 00:00:07"), // new customer
+ Row.of(9, 1, 143.21, "2020-10-10 00:00:08") // updated zip code
+ )
+ .build();
+
+ static final List<String> SINK_SCHEMA =
+ Arrays.asList(
+ "order_id INT",
+ "total DOUBLE",
+ "id INT",
+ "name STRING",
+ "age INT",
+ "city STRING",
+ "state STRING",
+ "zipcode INT");
+
+ static final TableTestProgram LOOKUP_JOIN_PROJECT_PUSHDOWN =
+ TableTestProgram.of(
+ "lookup-join-project-pushdown",
+ "validates lookup join with project pushdown")
+ .setupTableSource(CUSTOMERS)
+ .setupTableSource(ORDERS)
+ .setupTableSink(
+ SinkTestStep.newBuilder("sink_t")
+ .addSchema(
+ SINK_SCHEMA.stream()
+ .filter(field -> !field.equals("age INT"))
+ .collect(Collectors.toList()))
+ .consumedBeforeRestore(
+ "+I[1, 44.44, 3, Claire, Austin, Texas, 73301]",
+ "+I[2, 100.02, 5, Jake, New York City, New York, 10001]",
+ "+I[4, 92.61, 2, Alice, San Francisco, California, 95016]",
+ "+I[3, 23.89, 1, Bob, Mountain View, California, 94043]",
+ "+I[6, 7.65, 4, Shannon, Boise, Idaho, 83701]",
+ "+I[5, 12.78, 2, Alice, San Francisco, California, 95016]")
+ .consumedAfterRestore(
+ "+I[7, 17.58, 6, Joana, Atlanta, Georgia, 30033]",
+ "+I[9, 143.21, 1, Bob, San Jose, California, 94089]")
+ .build())
+ .runSql(
+ "INSERT INTO sink_t SELECT "
+ + "O.order_id, "
+ + "O.total, "
+ + "C.id, "
+ + "C.name, "
+ + "C.city, "
+ + "C.state, "
+ + "C.zipcode "
+ + "FROM orders_t as O "
+ + "JOIN customers_t FOR SYSTEM_TIME AS OF O.proc_time AS C "
+ + "ON O.customer_id = C.id")
+ .build();
+
+ static final TableTestProgram LOOKUP_JOIN_FILTER_PUSHDOWN =
+ TableTestProgram.of(
+ "lookup-join-filter-pushdown",
+ "validates lookup join with filter pushdown")
+ .setupTableSource(CUSTOMERS)
+ .setupTableSource(ORDERS)
+ .setupTableSink(
+ SinkTestStep.newBuilder("sink_t")
+ .addSchema(SINK_SCHEMA)
+ .consumedBeforeRestore(
+ "+I[1, 44.44, 3, Claire, 37, Austin, Texas, 73301]",
+ "+I[2, 100.02, 5, Jake, 42, New York City, New York, 10001]",
+ "+I[4, 92.61, 2, Alice, 32, San Francisco, California, 95016]",
+ "+I[5, 12.78, 2, Alice, 32, San Francisco, California, 95016]")
+ .consumedAfterRestore(
+ "+I[7, 17.58, 6, Joana, 54, Atlanta, Georgia, 30033]")
+ .build())
+ .runSql(
+ "INSERT INTO sink_t SELECT "
+ + "O.order_id, "
+ + "O.total, "
+ + "C.id, "
+ + "C.name, "
+ + "C.age, "
+ + "C.city, "
+ + "C.state, "
+ + "C.zipcode "
+ + "FROM orders_t as O "
+ + "JOIN customers_t FOR SYSTEM_TIME AS OF O.proc_time AS C "
+ + "ON O.customer_id = C.id AND C.age > 30")
+ .build();
+
+ static final TableTestProgram LOOKUP_JOIN_PRE_FILTER =
+ TableTestProgram.of("lookup-join-pre-filter", "validates lookup join with pre filter")
+ .setupTableSource(CUSTOMERS)
+ .setupTableSource(ORDERS)
+ .setupTableSink(
+ SinkTestStep.newBuilder("sink_t")
+ .addSchema(SINK_SCHEMA)
+ .consumedBeforeRestore(
+ "+I[2, 100.02, 5, Jake, 42, New York City, New York, 10001]",
+ "+I[4, 92.61, 2, Alice, 32, San Francisco, California, 95016]",
+ "+I[5, 12.78, 2, Alice, 32, San Francisco, California, 95016]")
+ .consumedAfterRestore(
+ "+I[7, 17.58, 6, Joana, 54, Atlanta, Georgia, 30033]")
+ .build())
+ .runSql(
+ "INSERT INTO sink_t SELECT "
+ + "O.order_id, "
+ + "O.total, "
+ + "C.id, "
+ + "C.name, "
+ + "C.age, "
+ + "C.city, "
+ + "C.state, "
+ + "C.zipcode "
+ + "FROM orders_t as O "
+ + "JOIN customers_t FOR SYSTEM_TIME AS OF O.proc_time AS C "
+ + "ON O.customer_id = C.id AND C.age > 30 AND O.customer_id <> 3")
+ .build();
+
+ static final TableTestProgram LOOKUP_JOIN_LEFT_JOIN =
+ TableTestProgram.of("lookup-join-left-join", "validates lookup join with left join")
+ .setupTableSource(CUSTOMERS)
+ .setupTableSource(ORDERS)
+ .setupTableSink(
+ SinkTestStep.newBuilder("sink_t")
+ .addSchema(SINK_SCHEMA)
+ .consumedBeforeRestore(
+ "+I[1, 44.44, null, null, null, null, null, null]",
+ "+I[2, 100.02, 5, Jake, 42, New York City, New York, 10001]",
+ "+I[4, 92.61, 2, Alice, 32, San Francisco, California, 95016]",
+ "+I[3, 23.89, null, null, null, null, null, null]",
+ "+I[6, 7.65, null, null, null, null, null, null]",
+ "+I[5, 12.78, 2, Alice, 32, San Francisco, California, 95016]")
+ .consumedAfterRestore(
+ "+I[7, 17.58, 6, Joana, 54, Atlanta, Georgia, 30033]",
+ "+I[9, 143.21, null, null, null, null, null, null]")
+ .build())
+ .runSql(
+ "INSERT INTO sink_t SELECT "
+ + "O.order_id, "
+ + "O.total, "
+ + "C.id, "
+ + "C.name, "
+ + "C.age, "
+ + "C.city, "
+ + "C.state, "
+ + "C.zipcode "
+ + "FROM orders_t as O "
+ + "LEFT JOIN customers_t FOR SYSTEM_TIME AS OF O.proc_time AS C "
+ + "ON O.customer_id = C.id AND C.age > 30 AND O.customer_id <> 3")
+ .build();
+
+ static final TableTestProgram LOOKUP_JOIN_ASYNC_HINT =
+ TableTestProgram.of("lookup-join-async-hint", "validates lookup join with async hint")
+ .setupTableSource(CUSTOMERS)
+ .setupTableSource(ORDERS)
+ .setupTableSink(
+ SinkTestStep.newBuilder("sink_t")
+ .addSchema(SINK_SCHEMA)
+ .consumedBeforeRestore(
+ "+I[1, 44.44, 3, Claire, 37, Austin, Texas, 73301]",
+ "+I[2, 100.02, 5, Jake, 42, New York City, New York, 10001]",
+ "+I[4, 92.61, 2, Alice, 32, San Francisco, California, 95016]",
+ "+I[3, 23.89, 1, Bob, 28, Mountain View, California, 94043]",
+ "+I[6, 7.65, 4, Shannon, 29, Boise, Idaho, 83701]",
+ "+I[5, 12.78, 2, Alice, 32, San Francisco, California, 95016]")
+ .consumedAfterRestore(
+ "+I[7, 17.58, 6, Joana, 54, Atlanta, Georgia, 30033]",
+ "+I[9, 143.21, 1, Bob, 28, San Jose, California, 94089]")
+ .build())
+ .runSql(
+ "INSERT INTO sink_t SELECT "
+ + "/*+ LOOKUP('table'='C', 'async'='true', 'output-mode'='allow_unordered') */ "
Review Comment:
Do you know why is that? It seems weird to me that the tests says it checks the async options, but they're actually not propagated to the CompiledPlan.
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-33647] Implement restore tests for LookupJoin node [flink]
Posted by "bvarghese1 (via GitHub)" <gi...@apache.org>.
bvarghese1 commented on code in PR #23814:
URL: https://github.com/apache/flink/pull/23814#discussion_r1413375281
##########
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/plan/nodes/exec/stream/LookupJoinTestPrograms.java:
##########
@@ -0,0 +1,287 @@
+/*
+ * 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.stream;
+
+import org.apache.flink.table.test.program.SinkTestStep;
+import org.apache.flink.table.test.program.SourceTestStep;
+import org.apache.flink.table.test.program.TableTestProgram;
+import org.apache.flink.types.Row;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.stream.Collectors;
+
+/** {@link TableTestProgram} definitions for testing {@link StreamExecGroupWindowAggregate}. */
+public class LookupJoinTestPrograms {
+
+ static final SourceTestStep CUSTOMERS =
+ SourceTestStep.newBuilder("customers_t") // static table
+ .addOption("disable-lookup", "false")
+ .addOption("filterable-fields", "age")
+ .addSchema(
+ "id INT PRIMARY KEY NOT ENFORCED",
+ "name STRING",
+ "age INT",
+ "city STRING",
+ "state STRING",
+ "zipcode INT")
+ .producedBeforeRestore(
+ Row.of(1, "Bob", 28, "Mountain View", "California", 94043),
+ Row.of(2, "Alice", 32, "San Francisco", "California", 95016),
+ Row.of(3, "Claire", 37, "Austin", "Texas", 73301),
+ Row.of(4, "Shannon", 29, "Boise", "Idaho", 83701),
+ Row.of(5, "Jake", 42, "New York City", "New York", 10001))
+ // Note: Before data state is not persisted for static tables during savepoint
+ .producedAfterRestore(
+ Row.of(1, "Bob", 28, "San Jose", "California", 94089),
+ Row.of(6, "Joana", 54, "Atlanta", "Georgia", 30033))
Review Comment:
I think its fine. I have updated the comment to clarify this.
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-33647] Implement restore tests for LookupJoin node [flink]
Posted by "bvarghese1 (via GitHub)" <gi...@apache.org>.
bvarghese1 commented on code in PR #23814:
URL: https://github.com/apache/flink/pull/23814#discussion_r1419461565
##########
flink-table/flink-table-api-java/src/test/java/org/apache/flink/table/test/program/TableTestStep.java:
##########
@@ -56,7 +56,7 @@ public TableResult apply(TableEnvironment env) {
public TableResult apply(TableEnvironment env, Map<String, String> extraOptions) {
final Map<String, String> allOptions = new HashMap<>(options);
- allOptions.putAll(extraOptions);
Review Comment:
Fixed
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-33647] Implement restore tests for LookupJoin node [flink]
Posted by "bvarghese1 (via GitHub)" <gi...@apache.org>.
bvarghese1 commented on code in PR #23814:
URL: https://github.com/apache/flink/pull/23814#discussion_r1411425256
##########
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/plan/nodes/exec/stream/LookupJoinTestPrograms.java:
##########
@@ -0,0 +1,287 @@
+/*
+ * 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.stream;
+
+import org.apache.flink.table.test.program.SinkTestStep;
+import org.apache.flink.table.test.program.SourceTestStep;
+import org.apache.flink.table.test.program.TableTestProgram;
+import org.apache.flink.types.Row;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.stream.Collectors;
+
+/** {@link TableTestProgram} definitions for testing {@link StreamExecGroupWindowAggregate}. */
+public class LookupJoinTestPrograms {
+
+ static final SourceTestStep CUSTOMERS =
+ SourceTestStep.newBuilder("customers_t") // static table
+ .addOption("disable-lookup", "false")
+ .addOption("filterable-fields", "age")
+ .addSchema(
+ "id INT PRIMARY KEY NOT ENFORCED",
+ "name STRING",
+ "age INT",
+ "city STRING",
+ "state STRING",
+ "zipcode INT")
+ .producedBeforeRestore(
+ Row.of(1, "Bob", 28, "Mountain View", "California", 94043),
+ Row.of(2, "Alice", 32, "San Francisco", "California", 95016),
+ Row.of(3, "Claire", 37, "Austin", "Texas", 73301),
+ Row.of(4, "Shannon", 29, "Boise", "Idaho", 83701),
+ Row.of(5, "Jake", 42, "New York City", "New York", 10001))
+ // Note: Before data state is not persisted for static tables during savepoint
+ .producedAfterRestore(
+ Row.of(1, "Bob", 28, "San Jose", "California", 94089),
+ Row.of(6, "Joana", 54, "Atlanta", "Georgia", 30033))
+ .build();
+
+ static final SourceTestStep ORDERS =
+ SourceTestStep.newBuilder("orders_t")
+ .addOption("filterable-fields", "customer_id")
+ .addSchema(
+ "order_id INT",
+ "customer_id INT",
+ "total DOUBLE",
+ "order_time STRING",
+ "proc_time AS PROCTIME()")
+ .producedBeforeRestore(
+ Row.of(1, 3, 44.44, "2020-10-10 00:00:01"),
+ Row.of(2, 5, 100.02, "2020-10-10 00:00:02"),
+ Row.of(4, 2, 92.61, "2020-10-10 00:00:04"),
+ Row.of(3, 1, 23.89, "2020-10-10 00:00:03"),
+ Row.of(6, 4, 7.65, "2020-10-10 00:00:06"),
+ Row.of(5, 2, 12.78, "2020-10-10 00:00:05"))
+ .producedAfterRestore(
+ Row.of(7, 6, 17.58, "2020-10-10 00:00:07"), // new customer
+ Row.of(9, 1, 143.21, "2020-10-10 00:00:08") // updated zip code
+ )
+ .build();
+
+ static final List<String> SINK_SCHEMA =
+ Arrays.asList(
+ "order_id INT",
+ "total DOUBLE",
+ "id INT",
+ "name STRING",
+ "age INT",
+ "city STRING",
+ "state STRING",
+ "zipcode INT");
+
+ static final TableTestProgram LOOKUP_JOIN_PROJECT_PUSHDOWN =
+ TableTestProgram.of(
+ "lookup-join-project-pushdown",
+ "validates lookup join with project pushdown")
+ .setupTableSource(CUSTOMERS)
+ .setupTableSource(ORDERS)
+ .setupTableSink(
+ SinkTestStep.newBuilder("sink_t")
+ .addSchema(
+ SINK_SCHEMA.stream()
+ .filter(field -> !field.equals("age INT"))
+ .collect(Collectors.toList()))
+ .consumedBeforeRestore(
+ "+I[1, 44.44, 3, Claire, Austin, Texas, 73301]",
+ "+I[2, 100.02, 5, Jake, New York City, New York, 10001]",
+ "+I[4, 92.61, 2, Alice, San Francisco, California, 95016]",
+ "+I[3, 23.89, 1, Bob, Mountain View, California, 94043]",
+ "+I[6, 7.65, 4, Shannon, Boise, Idaho, 83701]",
+ "+I[5, 12.78, 2, Alice, San Francisco, California, 95016]")
+ .consumedAfterRestore(
+ "+I[7, 17.58, 6, Joana, Atlanta, Georgia, 30033]",
+ "+I[9, 143.21, 1, Bob, San Jose, California, 94089]")
+ .build())
+ .runSql(
+ "INSERT INTO sink_t SELECT "
+ + "O.order_id, "
+ + "O.total, "
+ + "C.id, "
+ + "C.name, "
+ + "C.city, "
+ + "C.state, "
+ + "C.zipcode "
+ + "FROM orders_t as O "
+ + "JOIN customers_t FOR SYSTEM_TIME AS OF O.proc_time AS C "
+ + "ON O.customer_id = C.id")
+ .build();
+
+ static final TableTestProgram LOOKUP_JOIN_FILTER_PUSHDOWN =
+ TableTestProgram.of(
+ "lookup-join-filter-pushdown",
+ "validates lookup join with filter pushdown")
+ .setupTableSource(CUSTOMERS)
+ .setupTableSource(ORDERS)
+ .setupTableSink(
+ SinkTestStep.newBuilder("sink_t")
+ .addSchema(SINK_SCHEMA)
+ .consumedBeforeRestore(
+ "+I[1, 44.44, 3, Claire, 37, Austin, Texas, 73301]",
+ "+I[2, 100.02, 5, Jake, 42, New York City, New York, 10001]",
+ "+I[4, 92.61, 2, Alice, 32, San Francisco, California, 95016]",
+ "+I[5, 12.78, 2, Alice, 32, San Francisco, California, 95016]")
+ .consumedAfterRestore(
+ "+I[7, 17.58, 6, Joana, 54, Atlanta, Georgia, 30033]")
+ .build())
+ .runSql(
+ "INSERT INTO sink_t SELECT "
+ + "O.order_id, "
+ + "O.total, "
+ + "C.id, "
+ + "C.name, "
+ + "C.age, "
+ + "C.city, "
+ + "C.state, "
+ + "C.zipcode "
+ + "FROM orders_t as O "
+ + "JOIN customers_t FOR SYSTEM_TIME AS OF O.proc_time AS C "
+ + "ON O.customer_id = C.id AND C.age > 30")
+ .build();
+
+ static final TableTestProgram LOOKUP_JOIN_PRE_FILTER =
+ TableTestProgram.of("lookup-join-pre-filter", "validates lookup join with pre filter")
+ .setupTableSource(CUSTOMERS)
+ .setupTableSource(ORDERS)
+ .setupTableSink(
+ SinkTestStep.newBuilder("sink_t")
+ .addSchema(SINK_SCHEMA)
+ .consumedBeforeRestore(
+ "+I[2, 100.02, 5, Jake, 42, New York City, New York, 10001]",
+ "+I[4, 92.61, 2, Alice, 32, San Francisco, California, 95016]",
+ "+I[5, 12.78, 2, Alice, 32, San Francisco, California, 95016]")
+ .consumedAfterRestore(
+ "+I[7, 17.58, 6, Joana, 54, Atlanta, Georgia, 30033]")
+ .build())
+ .runSql(
+ "INSERT INTO sink_t SELECT "
+ + "O.order_id, "
+ + "O.total, "
+ + "C.id, "
+ + "C.name, "
+ + "C.age, "
+ + "C.city, "
+ + "C.state, "
+ + "C.zipcode "
+ + "FROM orders_t as O "
+ + "JOIN customers_t FOR SYSTEM_TIME AS OF O.proc_time AS C "
+ + "ON O.customer_id = C.id AND C.age > 30 AND O.customer_id <> 3")
+ .build();
+
+ static final TableTestProgram LOOKUP_JOIN_LEFT_JOIN =
+ TableTestProgram.of("lookup-join-left-join", "validates lookup join with left join")
+ .setupTableSource(CUSTOMERS)
+ .setupTableSource(ORDERS)
+ .setupTableSink(
+ SinkTestStep.newBuilder("sink_t")
+ .addSchema(SINK_SCHEMA)
+ .consumedBeforeRestore(
+ "+I[1, 44.44, null, null, null, null, null, null]",
+ "+I[2, 100.02, 5, Jake, 42, New York City, New York, 10001]",
+ "+I[4, 92.61, 2, Alice, 32, San Francisco, California, 95016]",
+ "+I[3, 23.89, null, null, null, null, null, null]",
+ "+I[6, 7.65, null, null, null, null, null, null]",
+ "+I[5, 12.78, 2, Alice, 32, San Francisco, California, 95016]")
+ .consumedAfterRestore(
+ "+I[7, 17.58, 6, Joana, 54, Atlanta, Georgia, 30033]",
+ "+I[9, 143.21, null, null, null, null, null, null]")
+ .build())
+ .runSql(
+ "INSERT INTO sink_t SELECT "
+ + "O.order_id, "
+ + "O.total, "
+ + "C.id, "
+ + "C.name, "
+ + "C.age, "
+ + "C.city, "
+ + "C.state, "
+ + "C.zipcode "
+ + "FROM orders_t as O "
+ + "LEFT JOIN customers_t FOR SYSTEM_TIME AS OF O.proc_time AS C "
+ + "ON O.customer_id = C.id AND C.age > 30 AND O.customer_id <> 3")
+ .build();
+
+ static final TableTestProgram LOOKUP_JOIN_ASYNC_HINT =
+ TableTestProgram.of("lookup-join-async-hint", "validates lookup join with async hint")
+ .setupTableSource(CUSTOMERS)
+ .setupTableSource(ORDERS)
+ .setupTableSink(
+ SinkTestStep.newBuilder("sink_t")
+ .addSchema(SINK_SCHEMA)
+ .consumedBeforeRestore(
+ "+I[1, 44.44, 3, Claire, 37, Austin, Texas, 73301]",
+ "+I[2, 100.02, 5, Jake, 42, New York City, New York, 10001]",
+ "+I[4, 92.61, 2, Alice, 32, San Francisco, California, 95016]",
+ "+I[3, 23.89, 1, Bob, 28, Mountain View, California, 94043]",
+ "+I[6, 7.65, 4, Shannon, 29, Boise, Idaho, 83701]",
+ "+I[5, 12.78, 2, Alice, 32, San Francisco, California, 95016]")
+ .consumedAfterRestore(
+ "+I[7, 17.58, 6, Joana, 54, Atlanta, Georgia, 30033]",
+ "+I[9, 143.21, 1, Bob, 28, San Jose, California, 94089]")
+ .build())
+ .runSql(
+ "INSERT INTO sink_t SELECT "
+ + "/*+ LOOKUP('table'='C', 'async'='true', 'output-mode'='allow_unordered') */ "
Review Comment:
Yes, I have been debugging this. There is an config option to set ASYNC data. Will try that.
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-33647] Implement restore tests for LookupJoin node [flink]
Posted by "dawidwys (via GitHub)" <gi...@apache.org>.
dawidwys commented on code in PR #23814:
URL: https://github.com/apache/flink/pull/23814#discussion_r1409505697
##########
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/plan/nodes/exec/stream/LookupJoinTestPrograms.java:
##########
@@ -0,0 +1,287 @@
+/*
+ * 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.stream;
+
+import org.apache.flink.table.test.program.SinkTestStep;
+import org.apache.flink.table.test.program.SourceTestStep;
+import org.apache.flink.table.test.program.TableTestProgram;
+import org.apache.flink.types.Row;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.stream.Collectors;
+
+/** {@link TableTestProgram} definitions for testing {@link StreamExecGroupWindowAggregate}. */
Review Comment:
Please update the javadoc.
##########
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/plan/nodes/exec/stream/LookupJoinTestPrograms.java:
##########
@@ -0,0 +1,287 @@
+/*
+ * 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.stream;
+
+import org.apache.flink.table.test.program.SinkTestStep;
+import org.apache.flink.table.test.program.SourceTestStep;
+import org.apache.flink.table.test.program.TableTestProgram;
+import org.apache.flink.types.Row;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.stream.Collectors;
+
+/** {@link TableTestProgram} definitions for testing {@link StreamExecGroupWindowAggregate}. */
+public class LookupJoinTestPrograms {
+
+ static final SourceTestStep CUSTOMERS =
+ SourceTestStep.newBuilder("customers_t") // static table
+ .addOption("disable-lookup", "false")
+ .addOption("filterable-fields", "age")
+ .addSchema(
+ "id INT PRIMARY KEY NOT ENFORCED",
+ "name STRING",
+ "age INT",
+ "city STRING",
+ "state STRING",
+ "zipcode INT")
+ .producedBeforeRestore(
+ Row.of(1, "Bob", 28, "Mountain View", "California", 94043),
+ Row.of(2, "Alice", 32, "San Francisco", "California", 95016),
+ Row.of(3, "Claire", 37, "Austin", "Texas", 73301),
+ Row.of(4, "Shannon", 29, "Boise", "Idaho", 83701),
+ Row.of(5, "Jake", 42, "New York City", "New York", 10001))
+ // Note: Before data state is not persisted for static tables during savepoint
+ .producedAfterRestore(
+ Row.of(1, "Bob", 28, "San Jose", "California", 94089),
+ Row.of(6, "Joana", 54, "Atlanta", "Georgia", 30033))
Review Comment:
Does it make sense to have different data before and after the restore? I am fine if you think it is.
I'd rephrase the `Note` though, as I think in the current shape it's a bit confusing. Lookup tables do not act as regular tables and they do not consume any of the data. Therefore there is nothing to "persist". Lookup tables work in a way that a value is looked up in the external system each time a record is received on the other side of the join.
`produced***` might be confusing in that context, but adding new methods for that single use case might be an overkill.
##########
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/plan/nodes/exec/stream/LookupJoinJsonPlanTest.java:
##########
@@ -1,273 +0,0 @@
-/*
- * 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.stream;
-
-import org.apache.flink.api.common.typeinfo.Types;
-import org.apache.flink.table.api.TableConfig;
-import org.apache.flink.table.api.TableEnvironment;
-import org.apache.flink.table.api.TableSchema;
-import org.apache.flink.table.api.ValidationException;
-import org.apache.flink.table.api.config.OptimizerConfigOptions;
-import org.apache.flink.table.planner.runtime.utils.InMemoryLookupableTableSource;
-import org.apache.flink.table.planner.utils.StreamTableTestUtil;
-import org.apache.flink.table.planner.utils.TableTestBase;
-import org.apache.flink.types.Row;
-
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-
-import java.util.ArrayList;
-
-import scala.collection.JavaConverters;
-
-import static org.apache.flink.core.testutils.FlinkAssertions.anyCauseMatches;
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
-
-/** Test json serialization/deserialization for LookupJoin. */
-class LookupJoinJsonPlanTest extends TableTestBase {
-
- private StreamTableTestUtil util;
- private TableEnvironment tEnv;
-
- @BeforeEach
- void setup() {
- util = streamTestUtil(TableConfig.getDefault());
- tEnv = util.getTableEnv();
-
- String srcTableA =
- "CREATE TABLE MyTable (\n"
- + " a int,\n"
- + " b varchar,\n"
- + " c bigint,\n"
- + " proctime as PROCTIME(),\n"
- + " rowtime as TO_TIMESTAMP(FROM_UNIXTIME(c)),\n"
- + " watermark for rowtime as rowtime - INTERVAL '1' second \n"
- + ") with (\n"
- + " 'connector' = 'values',\n"
- + " 'bounded' = 'false')";
- String srcTableB =
- "CREATE TABLE LookupTable (\n"
- + " id int,\n"
- + " name varchar,\n"
- + " age int \n"
- + ") with (\n"
- + " 'connector' = 'values',\n"
- + " 'bounded' = 'false')";
- String sinkTable1 =
- "CREATE TABLE Sink1 (\n"
- + " a int,\n"
- + " name varchar,"
- + " age int"
- + ") with (\n"
- + " 'connector' = 'values',\n"
- + " 'sink-insert-only' = 'false')";
- String sinkTable2 =
- "CREATE TABLE MySink1 (\n"
- + " a int,\n"
- + " b varchar,"
- + " c bigint,"
- + " proctime timestamp(3),"
- + " rowtime timestamp(3),"
- + " id int,"
- + " name varchar,"
- + " age int"
- + ") with (\n"
- + " 'connector' = 'values',\n"
- + " 'table-sink-class' = 'DEFAULT')";
- tEnv.executeSql(srcTableA);
- tEnv.executeSql(srcTableB);
- tEnv.executeSql(sinkTable1);
- tEnv.executeSql(sinkTable2);
- }
-
- @Test
- void testJoinTemporalTable() {
- String sinkTableDdl =
- "CREATE TABLE MySink (\n"
- + " a int,\n"
- + " b varchar,"
- + " c bigint,"
- + " proctime timestamp(3),"
- + " rowtime timestamp(3),"
- + " id int,"
- + " name varchar,"
- + " age int"
- + ") with (\n"
- + " 'connector' = 'values',\n"
- + " 'table-sink-class' = 'DEFAULT')";
- tEnv.executeSql(sinkTableDdl);
- util.verifyJsonPlan(
- "INSERT INTO MySink SELECT * FROM MyTable AS T JOIN LookupTable "
- + "FOR SYSTEM_TIME AS OF T.proctime AS D ON T.a = D.id");
- }
-
- @Test
- void testJoinTemporalTableWithProjectionPushDown() {
- String sinkTableDdl =
- "CREATE TABLE MySink (\n"
- + " a int,\n"
- + " b varchar,"
- + " c bigint,"
- + " proctime timestamp(3),"
- + " rowtime timestamp(3),"
- + " id int"
- + ") with (\n"
- + " 'connector' = 'values',\n"
- + " 'table-sink-class' = 'DEFAULT')";
- tEnv.executeSql(sinkTableDdl);
- util.verifyJsonPlan(
- "INSERT INTO MySink \n"
- + "SELECT T.*, D.id \n"
- + "FROM MyTable AS T \n"
- + "JOIN LookupTable FOR SYSTEM_TIME AS OF T.proctime AS D \n"
- + "ON T.a = D.id\n");
- }
-
- @Test
- void testLegacyTableSourceException() {
- TableSchema tableSchema =
- TableSchema.builder()
- .field("id", Types.INT)
- .field("name", Types.STRING)
- .field("age", Types.INT)
- .build();
- InMemoryLookupableTableSource.createTemporaryTable(
- tEnv,
- false,
- JavaConverters.asScalaIteratorConverter(new ArrayList<Row>().iterator())
- .asScala()
- .toList(),
- tableSchema,
- "LookupTable",
- true);
- String sinkTableDdl =
- "CREATE TABLE MySink (\n"
- + " a int,\n"
- + " b varchar,"
- + " c bigint,"
- + " proctime timestamp(3),"
- + " rowtime timestamp(3),"
- + " id int,"
- + " name varchar,"
- + " age int"
- + ") with (\n"
- + " 'connector' = 'values',\n"
- + " 'table-sink-class' = 'DEFAULT')";
- tEnv.executeSql(sinkTableDdl);
- assertThatThrownBy(
- () ->
- util.verifyJsonPlan(
- "INSERT INTO MySink SELECT * FROM MyTable AS T JOIN LookupTable "
- + "FOR SYSTEM_TIME AS OF T.proctime AS D ON T.a = D.id"))
- .satisfies(
- anyCauseMatches(
- ValidationException.class,
- "TemporalTableSourceSpec can not be serialized."));
- }
-
- @Test
- void testAggAndLeftJoinWithTryResolveMode() {
- tEnv.getConfig()
- .set(
- OptimizerConfigOptions.TABLE_OPTIMIZER_NONDETERMINISTIC_UPDATE_STRATEGY,
- OptimizerConfigOptions.NonDeterministicUpdateStrategy.TRY_RESOLVE);
-
- util.verifyJsonPlan(
- "INSERT INTO Sink1 "
- + "SELECT T.a, D.name, D.age "
- + "FROM (SELECT max(a) a, count(c) c, PROCTIME() proctime FROM MyTable GROUP BY b) T "
- + "LEFT JOIN LookupTable "
- + "FOR SYSTEM_TIME AS OF T.proctime AS D ON T.a = D.id");
- }
-
- @Test
- void testJoinTemporalTableWithAsyncHint() {
- // LookupTable has sync func only, just verify the hint has take effect
- util.verifyJsonPlan(
- "INSERT INTO MySink1 SELECT "
- + "/*+ LOOKUP('table'='D', 'async'='true', 'output-mode'='allow_unordered') */ * "
- + "FROM MyTable AS T JOIN LookupTable "
- + "FOR SYSTEM_TIME AS OF T.proctime AS D ON T.a = D.id");
- }
-
- @Test
- void testJoinTemporalTableWithAsyncHint2() {
- // LookupTable has sync func only, just verify the hint has take effect
- util.verifyJsonPlan(
- "INSERT INTO MySink1 SELECT "
- + "/*+ LOOKUP('table'='D', 'async'='true', 'timeout'='600s', 'capacity'='1000') */ * "
- + "FROM MyTable AS T JOIN LookupTable "
- + "FOR SYSTEM_TIME AS OF T.proctime AS D ON T.a = D.id");
- }
-
- @Test
- void testJoinTemporalTableWithRetryHint() {
- util.verifyJsonPlan(
- "INSERT INTO MySink1 SELECT "
- + "/*+ LOOKUP('table'='D', 'retry-predicate'='lookup_miss', 'retry-strategy'='fixed_delay', 'fixed-delay'='10s', 'max-attempts'='3') */ * "
- + "FROM MyTable AS T JOIN LookupTable "
- + "FOR SYSTEM_TIME AS OF T.proctime AS D ON T.a = D.id");
- }
-
- @Test
- void testJoinTemporalTableWithAsyncRetryHint() {
- // LookupTable has sync func only, just verify the hint has take effect
- util.verifyJsonPlan(
- "INSERT INTO MySink1 SELECT "
- + "/*+ LOOKUP('table'='D', 'async'='true', 'retry-predicate'='lookup_miss', 'retry-strategy'='fixed_delay', 'fixed-delay'='10s', 'max-attempts'='3') */ * "
- + "FROM MyTable AS T JOIN LookupTable "
- + "FOR SYSTEM_TIME AS OF T.proctime AS D ON T.a = D.id");
- }
-
- @Test
- void testJoinTemporalTableWithAsyncRetryHint2() {
- // LookupTable has sync func only, just verify the hint has take effect
- util.verifyJsonPlan(
- "INSERT INTO MySink1 SELECT "
- + "/*+ LOOKUP('table'='D', 'async'='true', 'timeout'='600s', 'capacity'='1000', 'retry-predicate'='lookup_miss', 'retry-strategy'='fixed_delay', 'fixed-delay'='10s', 'max-attempts'='3') */ * "
- + "FROM MyTable AS T JOIN LookupTable "
- + "FOR SYSTEM_TIME AS OF T.proctime AS D ON T.a = D.id");
- }
-
- @Test
- void testLeftJoinTemporalTableWithPreFilter() {
- util.verifyJsonPlan(
- "INSERT INTO MySink1 SELECT * "
- + "FROM MyTable AS T LEFT JOIN LookupTable "
- + "FOR SYSTEM_TIME AS OF T.proctime AS D ON T.a = D.id AND T.b > 'abc'");
- }
-
- @Test
- void testLeftJoinTemporalTableWithPostFilter() {
- util.verifyJsonPlan(
- "INSERT INTO MySink1 SELECT * "
- + "FROM MyTable AS T LEFT JOIN LookupTable "
- + "FOR SYSTEM_TIME AS OF T.proctime AS D ON T.a = D.id "
- + "AND CHAR_LENGTH(D.name) > CHAR_LENGTH(T.b)");
- }
-
- @Test
- void testLeftJoinTemporalTableWithMultiJoinConditions() {
Review Comment:
Is this covered?
##########
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/plan/nodes/exec/stream/LookupJoinTestPrograms.java:
##########
@@ -0,0 +1,287 @@
+/*
+ * 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.stream;
+
+import org.apache.flink.table.test.program.SinkTestStep;
+import org.apache.flink.table.test.program.SourceTestStep;
+import org.apache.flink.table.test.program.TableTestProgram;
+import org.apache.flink.types.Row;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.stream.Collectors;
+
+/** {@link TableTestProgram} definitions for testing {@link StreamExecGroupWindowAggregate}. */
+public class LookupJoinTestPrograms {
+
+ static final SourceTestStep CUSTOMERS =
+ SourceTestStep.newBuilder("customers_t") // static table
+ .addOption("disable-lookup", "false")
+ .addOption("filterable-fields", "age")
+ .addSchema(
+ "id INT PRIMARY KEY NOT ENFORCED",
+ "name STRING",
+ "age INT",
+ "city STRING",
+ "state STRING",
+ "zipcode INT")
+ .producedBeforeRestore(
+ Row.of(1, "Bob", 28, "Mountain View", "California", 94043),
+ Row.of(2, "Alice", 32, "San Francisco", "California", 95016),
+ Row.of(3, "Claire", 37, "Austin", "Texas", 73301),
+ Row.of(4, "Shannon", 29, "Boise", "Idaho", 83701),
+ Row.of(5, "Jake", 42, "New York City", "New York", 10001))
+ // Note: Before data state is not persisted for static tables during savepoint
+ .producedAfterRestore(
+ Row.of(1, "Bob", 28, "San Jose", "California", 94089),
+ Row.of(6, "Joana", 54, "Atlanta", "Georgia", 30033))
+ .build();
+
+ static final SourceTestStep ORDERS =
+ SourceTestStep.newBuilder("orders_t")
+ .addOption("filterable-fields", "customer_id")
+ .addSchema(
+ "order_id INT",
+ "customer_id INT",
+ "total DOUBLE",
+ "order_time STRING",
+ "proc_time AS PROCTIME()")
+ .producedBeforeRestore(
+ Row.of(1, 3, 44.44, "2020-10-10 00:00:01"),
+ Row.of(2, 5, 100.02, "2020-10-10 00:00:02"),
+ Row.of(4, 2, 92.61, "2020-10-10 00:00:04"),
+ Row.of(3, 1, 23.89, "2020-10-10 00:00:03"),
+ Row.of(6, 4, 7.65, "2020-10-10 00:00:06"),
+ Row.of(5, 2, 12.78, "2020-10-10 00:00:05"))
+ .producedAfterRestore(
+ Row.of(7, 6, 17.58, "2020-10-10 00:00:07"), // new customer
+ Row.of(9, 1, 143.21, "2020-10-10 00:00:08") // updated zip code
+ )
+ .build();
+
+ static final List<String> SINK_SCHEMA =
+ Arrays.asList(
+ "order_id INT",
+ "total DOUBLE",
+ "id INT",
+ "name STRING",
+ "age INT",
+ "city STRING",
+ "state STRING",
+ "zipcode INT");
+
+ static final TableTestProgram LOOKUP_JOIN_PROJECT_PUSHDOWN =
+ TableTestProgram.of(
+ "lookup-join-project-pushdown",
+ "validates lookup join with project pushdown")
+ .setupTableSource(CUSTOMERS)
+ .setupTableSource(ORDERS)
+ .setupTableSink(
+ SinkTestStep.newBuilder("sink_t")
+ .addSchema(
+ SINK_SCHEMA.stream()
+ .filter(field -> !field.equals("age INT"))
+ .collect(Collectors.toList()))
+ .consumedBeforeRestore(
+ "+I[1, 44.44, 3, Claire, Austin, Texas, 73301]",
+ "+I[2, 100.02, 5, Jake, New York City, New York, 10001]",
+ "+I[4, 92.61, 2, Alice, San Francisco, California, 95016]",
+ "+I[3, 23.89, 1, Bob, Mountain View, California, 94043]",
+ "+I[6, 7.65, 4, Shannon, Boise, Idaho, 83701]",
+ "+I[5, 12.78, 2, Alice, San Francisco, California, 95016]")
+ .consumedAfterRestore(
+ "+I[7, 17.58, 6, Joana, Atlanta, Georgia, 30033]",
+ "+I[9, 143.21, 1, Bob, San Jose, California, 94089]")
+ .build())
+ .runSql(
+ "INSERT INTO sink_t SELECT "
+ + "O.order_id, "
+ + "O.total, "
+ + "C.id, "
+ + "C.name, "
+ + "C.city, "
+ + "C.state, "
+ + "C.zipcode "
+ + "FROM orders_t as O "
+ + "JOIN customers_t FOR SYSTEM_TIME AS OF O.proc_time AS C "
+ + "ON O.customer_id = C.id")
+ .build();
+
+ static final TableTestProgram LOOKUP_JOIN_FILTER_PUSHDOWN =
+ TableTestProgram.of(
+ "lookup-join-filter-pushdown",
+ "validates lookup join with filter pushdown")
+ .setupTableSource(CUSTOMERS)
+ .setupTableSource(ORDERS)
+ .setupTableSink(
+ SinkTestStep.newBuilder("sink_t")
+ .addSchema(SINK_SCHEMA)
+ .consumedBeforeRestore(
+ "+I[1, 44.44, 3, Claire, 37, Austin, Texas, 73301]",
+ "+I[2, 100.02, 5, Jake, 42, New York City, New York, 10001]",
+ "+I[4, 92.61, 2, Alice, 32, San Francisco, California, 95016]",
+ "+I[5, 12.78, 2, Alice, 32, San Francisco, California, 95016]")
+ .consumedAfterRestore(
+ "+I[7, 17.58, 6, Joana, 54, Atlanta, Georgia, 30033]")
+ .build())
+ .runSql(
+ "INSERT INTO sink_t SELECT "
+ + "O.order_id, "
+ + "O.total, "
+ + "C.id, "
+ + "C.name, "
+ + "C.age, "
+ + "C.city, "
+ + "C.state, "
+ + "C.zipcode "
+ + "FROM orders_t as O "
+ + "JOIN customers_t FOR SYSTEM_TIME AS OF O.proc_time AS C "
+ + "ON O.customer_id = C.id AND C.age > 30")
+ .build();
+
+ static final TableTestProgram LOOKUP_JOIN_PRE_FILTER =
+ TableTestProgram.of("lookup-join-pre-filter", "validates lookup join with pre filter")
+ .setupTableSource(CUSTOMERS)
+ .setupTableSource(ORDERS)
+ .setupTableSink(
+ SinkTestStep.newBuilder("sink_t")
+ .addSchema(SINK_SCHEMA)
+ .consumedBeforeRestore(
+ "+I[2, 100.02, 5, Jake, 42, New York City, New York, 10001]",
+ "+I[4, 92.61, 2, Alice, 32, San Francisco, California, 95016]",
+ "+I[5, 12.78, 2, Alice, 32, San Francisco, California, 95016]")
+ .consumedAfterRestore(
+ "+I[7, 17.58, 6, Joana, 54, Atlanta, Georgia, 30033]")
+ .build())
+ .runSql(
+ "INSERT INTO sink_t SELECT "
+ + "O.order_id, "
+ + "O.total, "
+ + "C.id, "
+ + "C.name, "
+ + "C.age, "
+ + "C.city, "
+ + "C.state, "
+ + "C.zipcode "
+ + "FROM orders_t as O "
+ + "JOIN customers_t FOR SYSTEM_TIME AS OF O.proc_time AS C "
+ + "ON O.customer_id = C.id AND C.age > 30 AND O.customer_id <> 3")
+ .build();
+
+ static final TableTestProgram LOOKUP_JOIN_LEFT_JOIN =
+ TableTestProgram.of("lookup-join-left-join", "validates lookup join with left join")
+ .setupTableSource(CUSTOMERS)
+ .setupTableSource(ORDERS)
+ .setupTableSink(
+ SinkTestStep.newBuilder("sink_t")
+ .addSchema(SINK_SCHEMA)
+ .consumedBeforeRestore(
+ "+I[1, 44.44, null, null, null, null, null, null]",
+ "+I[2, 100.02, 5, Jake, 42, New York City, New York, 10001]",
+ "+I[4, 92.61, 2, Alice, 32, San Francisco, California, 95016]",
+ "+I[3, 23.89, null, null, null, null, null, null]",
+ "+I[6, 7.65, null, null, null, null, null, null]",
+ "+I[5, 12.78, 2, Alice, 32, San Francisco, California, 95016]")
+ .consumedAfterRestore(
+ "+I[7, 17.58, 6, Joana, 54, Atlanta, Georgia, 30033]",
+ "+I[9, 143.21, null, null, null, null, null, null]")
+ .build())
+ .runSql(
+ "INSERT INTO sink_t SELECT "
+ + "O.order_id, "
+ + "O.total, "
+ + "C.id, "
+ + "C.name, "
+ + "C.age, "
+ + "C.city, "
+ + "C.state, "
+ + "C.zipcode "
+ + "FROM orders_t as O "
+ + "LEFT JOIN customers_t FOR SYSTEM_TIME AS OF O.proc_time AS C "
+ + "ON O.customer_id = C.id AND C.age > 30 AND O.customer_id <> 3")
+ .build();
+
+ static final TableTestProgram LOOKUP_JOIN_ASYNC_HINT =
+ TableTestProgram.of("lookup-join-async-hint", "validates lookup join with async hint")
+ .setupTableSource(CUSTOMERS)
+ .setupTableSource(ORDERS)
+ .setupTableSink(
+ SinkTestStep.newBuilder("sink_t")
+ .addSchema(SINK_SCHEMA)
+ .consumedBeforeRestore(
+ "+I[1, 44.44, 3, Claire, 37, Austin, Texas, 73301]",
+ "+I[2, 100.02, 5, Jake, 42, New York City, New York, 10001]",
+ "+I[4, 92.61, 2, Alice, 32, San Francisco, California, 95016]",
+ "+I[3, 23.89, 1, Bob, 28, Mountain View, California, 94043]",
+ "+I[6, 7.65, 4, Shannon, 29, Boise, Idaho, 83701]",
+ "+I[5, 12.78, 2, Alice, 32, San Francisco, California, 95016]")
+ .consumedAfterRestore(
+ "+I[7, 17.58, 6, Joana, 54, Atlanta, Georgia, 30033]",
+ "+I[9, 143.21, 1, Bob, 28, San Jose, California, 94089]")
+ .build())
+ .runSql(
+ "INSERT INTO sink_t SELECT "
+ + "/*+ LOOKUP('table'='C', 'async'='true', 'output-mode'='allow_unordered') */ "
Review Comment:
Do you know if those options are stored in the CompiledPlan? I looked shortly into the `StreamExecLookupJoin` and I believe e.g. `async` should be serialized in `asyncOptions`, but I can't find such a field in any of the plans (even the old ones).
##########
flink-table/flink-table-api-java/src/test/java/org/apache/flink/table/test/program/TableTestStep.java:
##########
@@ -56,7 +56,7 @@ public TableResult apply(TableEnvironment env) {
public TableResult apply(TableEnvironment env, Map<String, String> extraOptions) {
final Map<String, String> allOptions = new HashMap<>(options);
- allOptions.putAll(extraOptions);
Review Comment:
`extraOptions` should take precedence. The idea was that test base can enforce certain properties. Why do we need to change that?
##########
flink-table/flink-table-api-java/src/test/java/org/apache/flink/table/test/program/TableTestStep.java:
##########
@@ -56,7 +56,7 @@ public TableResult apply(TableEnvironment env) {
public TableResult apply(TableEnvironment env, Map<String, String> extraOptions) {
final Map<String, String> allOptions = new HashMap<>(options);
- allOptions.putAll(extraOptions);
Review Comment:
I believe that's to overwrite`disable-lookup`? I think we can remove it from `RestoreTestBase`. It might've been unnecessary there.
##########
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/plan/nodes/exec/stream/LookupJoinJsonPlanTest.java:
##########
@@ -1,273 +0,0 @@
-/*
- * 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.stream;
-
-import org.apache.flink.api.common.typeinfo.Types;
-import org.apache.flink.table.api.TableConfig;
-import org.apache.flink.table.api.TableEnvironment;
-import org.apache.flink.table.api.TableSchema;
-import org.apache.flink.table.api.ValidationException;
-import org.apache.flink.table.api.config.OptimizerConfigOptions;
-import org.apache.flink.table.planner.runtime.utils.InMemoryLookupableTableSource;
-import org.apache.flink.table.planner.utils.StreamTableTestUtil;
-import org.apache.flink.table.planner.utils.TableTestBase;
-import org.apache.flink.types.Row;
-
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-
-import java.util.ArrayList;
-
-import scala.collection.JavaConverters;
-
-import static org.apache.flink.core.testutils.FlinkAssertions.anyCauseMatches;
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
-
-/** Test json serialization/deserialization for LookupJoin. */
-class LookupJoinJsonPlanTest extends TableTestBase {
-
- private StreamTableTestUtil util;
- private TableEnvironment tEnv;
-
- @BeforeEach
- void setup() {
- util = streamTestUtil(TableConfig.getDefault());
- tEnv = util.getTableEnv();
-
- String srcTableA =
- "CREATE TABLE MyTable (\n"
- + " a int,\n"
- + " b varchar,\n"
- + " c bigint,\n"
- + " proctime as PROCTIME(),\n"
- + " rowtime as TO_TIMESTAMP(FROM_UNIXTIME(c)),\n"
- + " watermark for rowtime as rowtime - INTERVAL '1' second \n"
- + ") with (\n"
- + " 'connector' = 'values',\n"
- + " 'bounded' = 'false')";
- String srcTableB =
- "CREATE TABLE LookupTable (\n"
- + " id int,\n"
- + " name varchar,\n"
- + " age int \n"
- + ") with (\n"
- + " 'connector' = 'values',\n"
- + " 'bounded' = 'false')";
- String sinkTable1 =
- "CREATE TABLE Sink1 (\n"
- + " a int,\n"
- + " name varchar,"
- + " age int"
- + ") with (\n"
- + " 'connector' = 'values',\n"
- + " 'sink-insert-only' = 'false')";
- String sinkTable2 =
- "CREATE TABLE MySink1 (\n"
- + " a int,\n"
- + " b varchar,"
- + " c bigint,"
- + " proctime timestamp(3),"
- + " rowtime timestamp(3),"
- + " id int,"
- + " name varchar,"
- + " age int"
- + ") with (\n"
- + " 'connector' = 'values',\n"
- + " 'table-sink-class' = 'DEFAULT')";
- tEnv.executeSql(srcTableA);
- tEnv.executeSql(srcTableB);
- tEnv.executeSql(sinkTable1);
- tEnv.executeSql(sinkTable2);
- }
-
- @Test
- void testJoinTemporalTable() {
- String sinkTableDdl =
- "CREATE TABLE MySink (\n"
- + " a int,\n"
- + " b varchar,"
- + " c bigint,"
- + " proctime timestamp(3),"
- + " rowtime timestamp(3),"
- + " id int,"
- + " name varchar,"
- + " age int"
- + ") with (\n"
- + " 'connector' = 'values',\n"
- + " 'table-sink-class' = 'DEFAULT')";
- tEnv.executeSql(sinkTableDdl);
- util.verifyJsonPlan(
- "INSERT INTO MySink SELECT * FROM MyTable AS T JOIN LookupTable "
- + "FOR SYSTEM_TIME AS OF T.proctime AS D ON T.a = D.id");
- }
-
- @Test
- void testJoinTemporalTableWithProjectionPushDown() {
- String sinkTableDdl =
- "CREATE TABLE MySink (\n"
- + " a int,\n"
- + " b varchar,"
- + " c bigint,"
- + " proctime timestamp(3),"
- + " rowtime timestamp(3),"
- + " id int"
- + ") with (\n"
- + " 'connector' = 'values',\n"
- + " 'table-sink-class' = 'DEFAULT')";
- tEnv.executeSql(sinkTableDdl);
- util.verifyJsonPlan(
- "INSERT INTO MySink \n"
- + "SELECT T.*, D.id \n"
- + "FROM MyTable AS T \n"
- + "JOIN LookupTable FOR SYSTEM_TIME AS OF T.proctime AS D \n"
- + "ON T.a = D.id\n");
- }
-
- @Test
- void testLegacyTableSourceException() {
- TableSchema tableSchema =
- TableSchema.builder()
- .field("id", Types.INT)
- .field("name", Types.STRING)
- .field("age", Types.INT)
- .build();
- InMemoryLookupableTableSource.createTemporaryTable(
- tEnv,
- false,
- JavaConverters.asScalaIteratorConverter(new ArrayList<Row>().iterator())
- .asScala()
- .toList(),
- tableSchema,
- "LookupTable",
- true);
- String sinkTableDdl =
- "CREATE TABLE MySink (\n"
- + " a int,\n"
- + " b varchar,"
- + " c bigint,"
- + " proctime timestamp(3),"
- + " rowtime timestamp(3),"
- + " id int,"
- + " name varchar,"
- + " age int"
- + ") with (\n"
- + " 'connector' = 'values',\n"
- + " 'table-sink-class' = 'DEFAULT')";
- tEnv.executeSql(sinkTableDdl);
- assertThatThrownBy(
- () ->
- util.verifyJsonPlan(
- "INSERT INTO MySink SELECT * FROM MyTable AS T JOIN LookupTable "
- + "FOR SYSTEM_TIME AS OF T.proctime AS D ON T.a = D.id"))
- .satisfies(
- anyCauseMatches(
- ValidationException.class,
- "TemporalTableSourceSpec can not be serialized."));
- }
-
- @Test
- void testAggAndLeftJoinWithTryResolveMode() {
- tEnv.getConfig()
- .set(
- OptimizerConfigOptions.TABLE_OPTIMIZER_NONDETERMINISTIC_UPDATE_STRATEGY,
- OptimizerConfigOptions.NonDeterministicUpdateStrategy.TRY_RESOLVE);
-
- util.verifyJsonPlan(
- "INSERT INTO Sink1 "
- + "SELECT T.a, D.name, D.age "
- + "FROM (SELECT max(a) a, count(c) c, PROCTIME() proctime FROM MyTable GROUP BY b) T "
- + "LEFT JOIN LookupTable "
- + "FOR SYSTEM_TIME AS OF T.proctime AS D ON T.a = D.id");
- }
-
- @Test
- void testJoinTemporalTableWithAsyncHint() {
- // LookupTable has sync func only, just verify the hint has take effect
- util.verifyJsonPlan(
- "INSERT INTO MySink1 SELECT "
- + "/*+ LOOKUP('table'='D', 'async'='true', 'output-mode'='allow_unordered') */ * "
- + "FROM MyTable AS T JOIN LookupTable "
- + "FOR SYSTEM_TIME AS OF T.proctime AS D ON T.a = D.id");
- }
-
- @Test
- void testJoinTemporalTableWithAsyncHint2() {
- // LookupTable has sync func only, just verify the hint has take effect
- util.verifyJsonPlan(
- "INSERT INTO MySink1 SELECT "
- + "/*+ LOOKUP('table'='D', 'async'='true', 'timeout'='600s', 'capacity'='1000') */ * "
- + "FROM MyTable AS T JOIN LookupTable "
- + "FOR SYSTEM_TIME AS OF T.proctime AS D ON T.a = D.id");
- }
-
- @Test
- void testJoinTemporalTableWithRetryHint() {
- util.verifyJsonPlan(
- "INSERT INTO MySink1 SELECT "
- + "/*+ LOOKUP('table'='D', 'retry-predicate'='lookup_miss', 'retry-strategy'='fixed_delay', 'fixed-delay'='10s', 'max-attempts'='3') */ * "
- + "FROM MyTable AS T JOIN LookupTable "
- + "FOR SYSTEM_TIME AS OF T.proctime AS D ON T.a = D.id");
- }
-
- @Test
- void testJoinTemporalTableWithAsyncRetryHint() {
- // LookupTable has sync func only, just verify the hint has take effect
- util.verifyJsonPlan(
- "INSERT INTO MySink1 SELECT "
- + "/*+ LOOKUP('table'='D', 'async'='true', 'retry-predicate'='lookup_miss', 'retry-strategy'='fixed_delay', 'fixed-delay'='10s', 'max-attempts'='3') */ * "
- + "FROM MyTable AS T JOIN LookupTable "
- + "FOR SYSTEM_TIME AS OF T.proctime AS D ON T.a = D.id");
- }
-
- @Test
- void testJoinTemporalTableWithAsyncRetryHint2() {
- // LookupTable has sync func only, just verify the hint has take effect
- util.verifyJsonPlan(
- "INSERT INTO MySink1 SELECT "
- + "/*+ LOOKUP('table'='D', 'async'='true', 'timeout'='600s', 'capacity'='1000', 'retry-predicate'='lookup_miss', 'retry-strategy'='fixed_delay', 'fixed-delay'='10s', 'max-attempts'='3') */ * "
- + "FROM MyTable AS T JOIN LookupTable "
- + "FOR SYSTEM_TIME AS OF T.proctime AS D ON T.a = D.id");
- }
-
- @Test
- void testLeftJoinTemporalTableWithPreFilter() {
- util.verifyJsonPlan(
- "INSERT INTO MySink1 SELECT * "
- + "FROM MyTable AS T LEFT JOIN LookupTable "
- + "FOR SYSTEM_TIME AS OF T.proctime AS D ON T.a = D.id AND T.b > 'abc'");
- }
-
- @Test
- void testLeftJoinTemporalTableWithPostFilter() {
Review Comment:
Is this covered?
##########
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/plan/nodes/exec/stream/LookupJoinTestPrograms.java:
##########
@@ -0,0 +1,287 @@
+/*
+ * 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.stream;
+
+import org.apache.flink.table.test.program.SinkTestStep;
+import org.apache.flink.table.test.program.SourceTestStep;
+import org.apache.flink.table.test.program.TableTestProgram;
+import org.apache.flink.types.Row;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.stream.Collectors;
+
+/** {@link TableTestProgram} definitions for testing {@link StreamExecGroupWindowAggregate}. */
+public class LookupJoinTestPrograms {
+
+ static final SourceTestStep CUSTOMERS =
+ SourceTestStep.newBuilder("customers_t") // static table
+ .addOption("disable-lookup", "false")
+ .addOption("filterable-fields", "age")
+ .addSchema(
+ "id INT PRIMARY KEY NOT ENFORCED",
+ "name STRING",
+ "age INT",
+ "city STRING",
+ "state STRING",
+ "zipcode INT")
+ .producedBeforeRestore(
+ Row.of(1, "Bob", 28, "Mountain View", "California", 94043),
+ Row.of(2, "Alice", 32, "San Francisco", "California", 95016),
+ Row.of(3, "Claire", 37, "Austin", "Texas", 73301),
+ Row.of(4, "Shannon", 29, "Boise", "Idaho", 83701),
+ Row.of(5, "Jake", 42, "New York City", "New York", 10001))
+ // Note: Before data state is not persisted for static tables during savepoint
+ .producedAfterRestore(
+ Row.of(1, "Bob", 28, "San Jose", "California", 94089),
+ Row.of(6, "Joana", 54, "Atlanta", "Georgia", 30033))
+ .build();
+
+ static final SourceTestStep ORDERS =
+ SourceTestStep.newBuilder("orders_t")
+ .addOption("filterable-fields", "customer_id")
+ .addSchema(
+ "order_id INT",
+ "customer_id INT",
+ "total DOUBLE",
+ "order_time STRING",
+ "proc_time AS PROCTIME()")
+ .producedBeforeRestore(
+ Row.of(1, 3, 44.44, "2020-10-10 00:00:01"),
+ Row.of(2, 5, 100.02, "2020-10-10 00:00:02"),
+ Row.of(4, 2, 92.61, "2020-10-10 00:00:04"),
+ Row.of(3, 1, 23.89, "2020-10-10 00:00:03"),
+ Row.of(6, 4, 7.65, "2020-10-10 00:00:06"),
+ Row.of(5, 2, 12.78, "2020-10-10 00:00:05"))
+ .producedAfterRestore(
+ Row.of(7, 6, 17.58, "2020-10-10 00:00:07"), // new customer
+ Row.of(9, 1, 143.21, "2020-10-10 00:00:08") // updated zip code
+ )
+ .build();
+
+ static final List<String> SINK_SCHEMA =
+ Arrays.asList(
+ "order_id INT",
+ "total DOUBLE",
+ "id INT",
+ "name STRING",
+ "age INT",
+ "city STRING",
+ "state STRING",
+ "zipcode INT");
+
+ static final TableTestProgram LOOKUP_JOIN_PROJECT_PUSHDOWN =
+ TableTestProgram.of(
+ "lookup-join-project-pushdown",
+ "validates lookup join with project pushdown")
+ .setupTableSource(CUSTOMERS)
+ .setupTableSource(ORDERS)
+ .setupTableSink(
+ SinkTestStep.newBuilder("sink_t")
+ .addSchema(
+ SINK_SCHEMA.stream()
+ .filter(field -> !field.equals("age INT"))
+ .collect(Collectors.toList()))
+ .consumedBeforeRestore(
+ "+I[1, 44.44, 3, Claire, Austin, Texas, 73301]",
+ "+I[2, 100.02, 5, Jake, New York City, New York, 10001]",
+ "+I[4, 92.61, 2, Alice, San Francisco, California, 95016]",
+ "+I[3, 23.89, 1, Bob, Mountain View, California, 94043]",
+ "+I[6, 7.65, 4, Shannon, Boise, Idaho, 83701]",
+ "+I[5, 12.78, 2, Alice, San Francisco, California, 95016]")
+ .consumedAfterRestore(
+ "+I[7, 17.58, 6, Joana, Atlanta, Georgia, 30033]",
+ "+I[9, 143.21, 1, Bob, San Jose, California, 94089]")
+ .build())
+ .runSql(
+ "INSERT INTO sink_t SELECT "
+ + "O.order_id, "
+ + "O.total, "
+ + "C.id, "
+ + "C.name, "
+ + "C.city, "
+ + "C.state, "
+ + "C.zipcode "
+ + "FROM orders_t as O "
+ + "JOIN customers_t FOR SYSTEM_TIME AS OF O.proc_time AS C "
+ + "ON O.customer_id = C.id")
+ .build();
+
+ static final TableTestProgram LOOKUP_JOIN_FILTER_PUSHDOWN =
+ TableTestProgram.of(
+ "lookup-join-filter-pushdown",
+ "validates lookup join with filter pushdown")
+ .setupTableSource(CUSTOMERS)
+ .setupTableSource(ORDERS)
+ .setupTableSink(
+ SinkTestStep.newBuilder("sink_t")
+ .addSchema(SINK_SCHEMA)
+ .consumedBeforeRestore(
+ "+I[1, 44.44, 3, Claire, 37, Austin, Texas, 73301]",
+ "+I[2, 100.02, 5, Jake, 42, New York City, New York, 10001]",
+ "+I[4, 92.61, 2, Alice, 32, San Francisco, California, 95016]",
+ "+I[5, 12.78, 2, Alice, 32, San Francisco, California, 95016]")
+ .consumedAfterRestore(
+ "+I[7, 17.58, 6, Joana, 54, Atlanta, Georgia, 30033]")
+ .build())
+ .runSql(
+ "INSERT INTO sink_t SELECT "
+ + "O.order_id, "
+ + "O.total, "
+ + "C.id, "
+ + "C.name, "
+ + "C.age, "
+ + "C.city, "
+ + "C.state, "
+ + "C.zipcode "
+ + "FROM orders_t as O "
+ + "JOIN customers_t FOR SYSTEM_TIME AS OF O.proc_time AS C "
+ + "ON O.customer_id = C.id AND C.age > 30")
+ .build();
+
+ static final TableTestProgram LOOKUP_JOIN_PRE_FILTER =
+ TableTestProgram.of("lookup-join-pre-filter", "validates lookup join with pre filter")
+ .setupTableSource(CUSTOMERS)
+ .setupTableSource(ORDERS)
+ .setupTableSink(
+ SinkTestStep.newBuilder("sink_t")
+ .addSchema(SINK_SCHEMA)
+ .consumedBeforeRestore(
+ "+I[2, 100.02, 5, Jake, 42, New York City, New York, 10001]",
+ "+I[4, 92.61, 2, Alice, 32, San Francisco, California, 95016]",
+ "+I[5, 12.78, 2, Alice, 32, San Francisco, California, 95016]")
+ .consumedAfterRestore(
+ "+I[7, 17.58, 6, Joana, 54, Atlanta, Georgia, 30033]")
+ .build())
+ .runSql(
+ "INSERT INTO sink_t SELECT "
+ + "O.order_id, "
+ + "O.total, "
+ + "C.id, "
+ + "C.name, "
+ + "C.age, "
+ + "C.city, "
+ + "C.state, "
+ + "C.zipcode "
+ + "FROM orders_t as O "
+ + "JOIN customers_t FOR SYSTEM_TIME AS OF O.proc_time AS C "
+ + "ON O.customer_id = C.id AND C.age > 30 AND O.customer_id <> 3")
Review Comment:
Can we use a field which won't cause the filter to be pushed down to the `Orders` source? A suggestion to make the test case more different from the `LOOKUP_JOIN_FILTER_PUSHDOWN`
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-33647] Implement restore tests for LookupJoin node [flink]
Posted by "bvarghese1 (via GitHub)" <gi...@apache.org>.
bvarghese1 commented on code in PR #23814:
URL: https://github.com/apache/flink/pull/23814#discussion_r1409648619
##########
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/plan/nodes/exec/stream/LookupJoinTestPrograms.java:
##########
@@ -0,0 +1,287 @@
+/*
+ * 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.stream;
+
+import org.apache.flink.table.test.program.SinkTestStep;
+import org.apache.flink.table.test.program.SourceTestStep;
+import org.apache.flink.table.test.program.TableTestProgram;
+import org.apache.flink.types.Row;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.stream.Collectors;
+
+/** {@link TableTestProgram} definitions for testing {@link StreamExecGroupWindowAggregate}. */
+public class LookupJoinTestPrograms {
+
+ static final SourceTestStep CUSTOMERS =
+ SourceTestStep.newBuilder("customers_t") // static table
+ .addOption("disable-lookup", "false")
+ .addOption("filterable-fields", "age")
+ .addSchema(
+ "id INT PRIMARY KEY NOT ENFORCED",
+ "name STRING",
+ "age INT",
+ "city STRING",
+ "state STRING",
+ "zipcode INT")
+ .producedBeforeRestore(
+ Row.of(1, "Bob", 28, "Mountain View", "California", 94043),
+ Row.of(2, "Alice", 32, "San Francisco", "California", 95016),
+ Row.of(3, "Claire", 37, "Austin", "Texas", 73301),
+ Row.of(4, "Shannon", 29, "Boise", "Idaho", 83701),
+ Row.of(5, "Jake", 42, "New York City", "New York", 10001))
+ // Note: Before data state is not persisted for static tables during savepoint
+ .producedAfterRestore(
+ Row.of(1, "Bob", 28, "San Jose", "California", 94089),
+ Row.of(6, "Joana", 54, "Atlanta", "Georgia", 30033))
+ .build();
+
+ static final SourceTestStep ORDERS =
+ SourceTestStep.newBuilder("orders_t")
+ .addOption("filterable-fields", "customer_id")
+ .addSchema(
+ "order_id INT",
+ "customer_id INT",
+ "total DOUBLE",
+ "order_time STRING",
+ "proc_time AS PROCTIME()")
+ .producedBeforeRestore(
+ Row.of(1, 3, 44.44, "2020-10-10 00:00:01"),
+ Row.of(2, 5, 100.02, "2020-10-10 00:00:02"),
+ Row.of(4, 2, 92.61, "2020-10-10 00:00:04"),
+ Row.of(3, 1, 23.89, "2020-10-10 00:00:03"),
+ Row.of(6, 4, 7.65, "2020-10-10 00:00:06"),
+ Row.of(5, 2, 12.78, "2020-10-10 00:00:05"))
+ .producedAfterRestore(
+ Row.of(7, 6, 17.58, "2020-10-10 00:00:07"), // new customer
+ Row.of(9, 1, 143.21, "2020-10-10 00:00:08") // updated zip code
+ )
+ .build();
+
+ static final List<String> SINK_SCHEMA =
+ Arrays.asList(
+ "order_id INT",
+ "total DOUBLE",
+ "id INT",
+ "name STRING",
+ "age INT",
+ "city STRING",
+ "state STRING",
+ "zipcode INT");
+
+ static final TableTestProgram LOOKUP_JOIN_PROJECT_PUSHDOWN =
+ TableTestProgram.of(
+ "lookup-join-project-pushdown",
+ "validates lookup join with project pushdown")
+ .setupTableSource(CUSTOMERS)
+ .setupTableSource(ORDERS)
+ .setupTableSink(
+ SinkTestStep.newBuilder("sink_t")
+ .addSchema(
+ SINK_SCHEMA.stream()
+ .filter(field -> !field.equals("age INT"))
+ .collect(Collectors.toList()))
+ .consumedBeforeRestore(
+ "+I[1, 44.44, 3, Claire, Austin, Texas, 73301]",
+ "+I[2, 100.02, 5, Jake, New York City, New York, 10001]",
+ "+I[4, 92.61, 2, Alice, San Francisco, California, 95016]",
+ "+I[3, 23.89, 1, Bob, Mountain View, California, 94043]",
+ "+I[6, 7.65, 4, Shannon, Boise, Idaho, 83701]",
+ "+I[5, 12.78, 2, Alice, San Francisco, California, 95016]")
+ .consumedAfterRestore(
+ "+I[7, 17.58, 6, Joana, Atlanta, Georgia, 30033]",
+ "+I[9, 143.21, 1, Bob, San Jose, California, 94089]")
+ .build())
+ .runSql(
+ "INSERT INTO sink_t SELECT "
+ + "O.order_id, "
+ + "O.total, "
+ + "C.id, "
+ + "C.name, "
+ + "C.city, "
+ + "C.state, "
+ + "C.zipcode "
+ + "FROM orders_t as O "
+ + "JOIN customers_t FOR SYSTEM_TIME AS OF O.proc_time AS C "
+ + "ON O.customer_id = C.id")
+ .build();
+
+ static final TableTestProgram LOOKUP_JOIN_FILTER_PUSHDOWN =
+ TableTestProgram.of(
+ "lookup-join-filter-pushdown",
+ "validates lookup join with filter pushdown")
+ .setupTableSource(CUSTOMERS)
+ .setupTableSource(ORDERS)
+ .setupTableSink(
+ SinkTestStep.newBuilder("sink_t")
+ .addSchema(SINK_SCHEMA)
+ .consumedBeforeRestore(
+ "+I[1, 44.44, 3, Claire, 37, Austin, Texas, 73301]",
+ "+I[2, 100.02, 5, Jake, 42, New York City, New York, 10001]",
+ "+I[4, 92.61, 2, Alice, 32, San Francisco, California, 95016]",
+ "+I[5, 12.78, 2, Alice, 32, San Francisco, California, 95016]")
+ .consumedAfterRestore(
+ "+I[7, 17.58, 6, Joana, 54, Atlanta, Georgia, 30033]")
+ .build())
+ .runSql(
+ "INSERT INTO sink_t SELECT "
+ + "O.order_id, "
+ + "O.total, "
+ + "C.id, "
+ + "C.name, "
+ + "C.age, "
+ + "C.city, "
+ + "C.state, "
+ + "C.zipcode "
+ + "FROM orders_t as O "
+ + "JOIN customers_t FOR SYSTEM_TIME AS OF O.proc_time AS C "
+ + "ON O.customer_id = C.id AND C.age > 30")
+ .build();
+
+ static final TableTestProgram LOOKUP_JOIN_PRE_FILTER =
+ TableTestProgram.of("lookup-join-pre-filter", "validates lookup join with pre filter")
+ .setupTableSource(CUSTOMERS)
+ .setupTableSource(ORDERS)
+ .setupTableSink(
+ SinkTestStep.newBuilder("sink_t")
+ .addSchema(SINK_SCHEMA)
+ .consumedBeforeRestore(
+ "+I[2, 100.02, 5, Jake, 42, New York City, New York, 10001]",
+ "+I[4, 92.61, 2, Alice, 32, San Francisco, California, 95016]",
+ "+I[5, 12.78, 2, Alice, 32, San Francisco, California, 95016]")
+ .consumedAfterRestore(
+ "+I[7, 17.58, 6, Joana, 54, Atlanta, Georgia, 30033]")
+ .build())
+ .runSql(
+ "INSERT INTO sink_t SELECT "
+ + "O.order_id, "
+ + "O.total, "
+ + "C.id, "
+ + "C.name, "
+ + "C.age, "
+ + "C.city, "
+ + "C.state, "
+ + "C.zipcode "
+ + "FROM orders_t as O "
+ + "JOIN customers_t FOR SYSTEM_TIME AS OF O.proc_time AS C "
+ + "ON O.customer_id = C.id AND C.age > 30 AND O.customer_id <> 3")
+ .build();
+
+ static final TableTestProgram LOOKUP_JOIN_LEFT_JOIN =
+ TableTestProgram.of("lookup-join-left-join", "validates lookup join with left join")
+ .setupTableSource(CUSTOMERS)
+ .setupTableSource(ORDERS)
+ .setupTableSink(
+ SinkTestStep.newBuilder("sink_t")
+ .addSchema(SINK_SCHEMA)
+ .consumedBeforeRestore(
+ "+I[1, 44.44, null, null, null, null, null, null]",
+ "+I[2, 100.02, 5, Jake, 42, New York City, New York, 10001]",
+ "+I[4, 92.61, 2, Alice, 32, San Francisco, California, 95016]",
+ "+I[3, 23.89, null, null, null, null, null, null]",
+ "+I[6, 7.65, null, null, null, null, null, null]",
+ "+I[5, 12.78, 2, Alice, 32, San Francisco, California, 95016]")
+ .consumedAfterRestore(
+ "+I[7, 17.58, 6, Joana, 54, Atlanta, Georgia, 30033]",
+ "+I[9, 143.21, null, null, null, null, null, null]")
+ .build())
+ .runSql(
+ "INSERT INTO sink_t SELECT "
+ + "O.order_id, "
+ + "O.total, "
+ + "C.id, "
+ + "C.name, "
+ + "C.age, "
+ + "C.city, "
+ + "C.state, "
+ + "C.zipcode "
+ + "FROM orders_t as O "
+ + "LEFT JOIN customers_t FOR SYSTEM_TIME AS OF O.proc_time AS C "
+ + "ON O.customer_id = C.id AND C.age > 30 AND O.customer_id <> 3")
+ .build();
+
+ static final TableTestProgram LOOKUP_JOIN_ASYNC_HINT =
+ TableTestProgram.of("lookup-join-async-hint", "validates lookup join with async hint")
+ .setupTableSource(CUSTOMERS)
+ .setupTableSource(ORDERS)
+ .setupTableSink(
+ SinkTestStep.newBuilder("sink_t")
+ .addSchema(SINK_SCHEMA)
+ .consumedBeforeRestore(
+ "+I[1, 44.44, 3, Claire, 37, Austin, Texas, 73301]",
+ "+I[2, 100.02, 5, Jake, 42, New York City, New York, 10001]",
+ "+I[4, 92.61, 2, Alice, 32, San Francisco, California, 95016]",
+ "+I[3, 23.89, 1, Bob, 28, Mountain View, California, 94043]",
+ "+I[6, 7.65, 4, Shannon, 29, Boise, Idaho, 83701]",
+ "+I[5, 12.78, 2, Alice, 32, San Francisco, California, 95016]")
+ .consumedAfterRestore(
+ "+I[7, 17.58, 6, Joana, 54, Atlanta, Georgia, 30033]",
+ "+I[9, 143.21, 1, Bob, 28, San Jose, California, 94089]")
+ .build())
+ .runSql(
+ "INSERT INTO sink_t SELECT "
+ + "/*+ LOOKUP('table'='C', 'async'='true', 'output-mode'='allow_unordered') */ "
Review Comment:
I compared the old plan and the new plan and both take the sync path and hence we don't get the async options.
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-33647] Implement restore tests for LookupJoin node [flink]
Posted by "bvarghese1 (via GitHub)" <gi...@apache.org>.
bvarghese1 commented on code in PR #23814:
URL: https://github.com/apache/flink/pull/23814#discussion_r1409647014
##########
flink-table/flink-table-api-java/src/test/java/org/apache/flink/table/test/program/TableTestStep.java:
##########
@@ -56,7 +56,7 @@ public TableResult apply(TableEnvironment env) {
public TableResult apply(TableEnvironment env, Map<String, String> extraOptions) {
final Map<String, String> allOptions = new HashMap<>(options);
- allOptions.putAll(extraOptions);
Review Comment:
Alright. Will do that
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org