Timm0 commented on code in PR #29973:
URL: https://github.com/apache/flink/pull/29973#discussion_r4598779010
##########
flink-table/flink-table-api-java/src/test/java/org/apache/flink/table/api/internal/materializedtable/MaterializedPipelineImplTest.java:
##########
@@ -86,22 +87,31 @@ void regularTableAtThePathIsRejected() throws Exception {
assertThat(getPermanentTableKind()).contains(TableKind.TABLE);
}
- @Test
- void temporaryTableAtThePathIsRejected() throws Exception {
+ @ParameterizedTest(name = "{0}")
+ @MethodSource("createModesWithVerbs")
+ void temporaryTableAtThePathIsRejected(CreateMode mode, String verb)
throws Exception {
tEnv.createTemporaryTable("mt", TABLE_DESCRIPTOR);
final MaterializedPipeline pipeline =
tEnv.from("source").materializeInto("mt");
- assertThatThrownBy(pipeline::execute)
+ assertThatThrownBy(() -> pipeline.execute(mode))
.isInstanceOf(ValidationException.class)
.hasMessage(
- "Cannot create or alter materialized table
default_catalog.default_database.mt,"
+ "Cannot "
+ + verb
+ + " materialized table
default_catalog.default_database.mt,"
+ " because a temporary table or view with the
same identifier"
+ " exists and would shadow it. Drop the
temporary object first.");
assertThat(tEnv.listTemporaryTables()).containsExactly("mt");
assertThat(getPermanentTableKind()).isEmpty();
}
+ private static Stream<Arguments> createModesWithVerbs() {
+ return Stream.of(
+ Arguments.of(CreateMode.createOrAlter(), "create or alter"),
+ Arguments.of(CreateMode.failIfExists(), "create"));
Review Comment:
I added a test to` MaterializedTableTableApiITCase`. It covers a regular
table and a view under `failIfExists()`, and a view under `createOrAlter()`.
These cases are in the ITCase because the rejection happens after the stored
query is planned, and `MaterializedPipelineImplTest`'s mock environment has no
SQL parser. The regular table under `createOrAlter()` is rejected before
planning, so it kept it in `MaterializedPipelineImplTest`.
##########
docs/content.zh/docs/sql/materialized-table/table-api.md:
##########
@@ -49,6 +49,11 @@ current catalog and database. The freshness is optional and
defaults to
The refresh mode is derived from the freshness (see [Refresh Mode]({{< ref
"docs/sql/materialized-table/overview" >}}#refresh-mode)).
Full refresh mode needs a workflow scheduler and cannot be used from a plain
`TableEnvironment`.
+`execute()` creates the materialized table, or redeploys it if it already
exists (see
+[Redeploying](#redeploying)). To refuse an existing object at the path, for
example on a first
+deployment, call `execute(CreateMode.failIfExists())` instead. It fails if a
table or view,
+temporary or not, already exists at the path, and leaves that object unchanged.
Review Comment:
Done
--
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]