twalthr commented on a change in pull request #18215:
URL: https://github.com/apache/flink/pull/18215#discussion_r781220838
##########
File path:
flink-table/flink-table-api-java/src/main/java/org/apache/flink/table/api/internal/TableEnvironmentImpl.java
##########
@@ -683,12 +683,6 @@ public String explain(boolean extended) {
@Override
public String explainSql(String statement, ExplainDetail... extraDetails) {
List<Operation> operations = getParser().parse(statement);
-
- if (operations.size() != 1) {
- throw new TableException(
- "Unsupported SQL query! explainSql() only accepts a single
SQL query.");
Review comment:
This is actually still valid. We only support a single operation. And a
statement set is a single operation. Can be postpone the unwrapping of the
`GroupOperation` such that the list still contains of just one entry? Otherwise
we start with multi-statement execution which is future work.
##########
File path:
flink-table/flink-table-planner/src/test/scala/org/apache/flink/table/api/TableEnvironmentTest.scala
##########
@@ -160,13 +178,39 @@ class TableEnvironmentTest {
TableTestUtil.readFromResource("/explain/testStatementSetExecutionExplain.out")
val statementSet = tEnv.createStatementSet()
statementSet.addInsertSql("insert into MySink select last from MyTable")
+ statementSet.addInsertSql("insert into MySink select first from MyTable")
val actual = statementSet.explain(ExplainDetail.JSON_EXECUTION_PLAN)
+
assertThat(TableTestUtil.replaceNodeIdInOperator(TableTestUtil.replaceStreamNodeId(actual)))
+
.isEqualTo(TableTestUtil.replaceNodeIdInOperator(TableTestUtil.replaceStreamNodeId(expected)))
+ }
+
+ @Test
+ def testExecuteStatementSetExecutionExplain(): Unit = {
+ val execEnv = StreamExecutionEnvironment.getExecutionEnvironment
+ execEnv.setParallelism(1)
+ val settings = EnvironmentSettings.newInstance().inStreamingMode().build()
+ val tEnv = StreamTableEnvironment.create(execEnv, settings)
+
+ TestTableSourceSinks.createPersonCsvTemporaryTable(tEnv, "MyTable")
+
+ TestTableSourceSinks.createCsvTemporarySinkTable(
+ tEnv, new TableSchema(Array("first"), Array(STRING)), "MySink", -1)
+
+ val expected =
+
TableTestUtil.readFromResource("/explain/testStatementSetExecutionExplain.out")
+
+ val actual = tEnv.explainSql(
+ "execute statement set begin " +
+ "insert into MySink select last from MyTable; " +
+ "insert into MySink select first from MyTable; end",
+ ExplainDetail.JSON_EXECUTION_PLAN)
+
assertEquals(TableTestUtil.replaceNodeIdInOperator(TableTestUtil.replaceStreamNodeId(expected)),
TableTestUtil.replaceNodeIdInOperator(TableTestUtil.replaceStreamNodeId(actual)))
}
- @Test
+ @Test
Review comment:
nit: invalid indention
##########
File path:
flink-table/flink-table-planner/src/test/resources/org/apache/flink/table/planner/plan/nodes/exec/stream/MatchRecognizeJsonPlanTest_jsonplan/testMatch.out
##########
@@ -427,7 +463,7 @@
"cid" : "BIGINT"
} ]
},
- "description" : "Match(orderBy=[proctime ASC], measures=[FINAL(A\".id) AS
aid, FINAL(l.id) AS bid, FINAL(C.id) AS cid], rowsPerMatch=[ONE ROW PER MATCH],
after=[SKIP TO NEXT ROW], pattern=[((_UTF-16LE'A\"', _UTF-16LE'l'),
_UTF-16LE'C')], define=[{A\"==(LAST(*.$1, 0), _UTF-16LE'a'), l==(LAST(*.$1, 0),
_UTF-16LE'b'), C==(LAST(*.$1, 0), _UTF-16LE'c')}])"
+ "description" : "Match(orderBy=[proctime ASC],
measures=[FINAL(FINAL(A\".id)) AS aid, FINAL(FINAL(l.id)) AS bid,
FINAL(FINAL(C.id)) AS cid], rowsPerMatch=[ONE ROW PER MATCH], after=[SKIP TO
NEXT ROW], pattern=[((_UTF-16LE'A\"', _UTF-16LE'l'), _UTF-16LE'C')],
define=[{A\"==(LAST(*.$1, 0), _UTF-16LE'a'), l==(LAST(*.$1, 0), _UTF-16LE'b'),
C==(LAST(*.$1, 0), _UTF-16LE'c')}])"
Review comment:
Did we got an explanation for this?
##########
File path:
flink-table/flink-table-api-java/src/main/java/org/apache/flink/table/operations/GroupOperation.java
##########
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.table.operations;
+
+import org.apache.flink.util.Preconditions;
+
+import java.util.List;
+import java.util.stream.Collectors;
+
+/** An {@link Operation} to represent a group of operations. */
+public class GroupOperation implements Operation {
Review comment:
Annotate with `@Internal` and mark `final`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]