AHeise commented on code in PR #30232:
URL: https://github.com/apache/flink/pull/30232#discussion_r4770074951
##########
docs/content/docs/sql/materialized-table/table-api.md:
##########
@@ -124,6 +125,16 @@ If the new refresh job starts but the catalog cannot
record it, the job is cance
job restarts from its savepoint. If that cancel fails, the materialized table
is rolled back and
left suspended instead of restarting the old job.
+# Converting a Regular Table
+
+If conversion is enabled, `execute()` converts a regular table at the path
into a materialized
+table, as
+[`CREATE OR ALTER MATERIALIZED TABLE`]({{< ref
"docs/sql/materialized-table/statements"
>}}#converting-a-table-to-a-materialized-table)
+does. Enable
+[table.materialized-table.conversion-from-table.enabled]({{< ref
"docs/dev/table/config"
>}}#table-materialized-table-conversion-from-table-enabled)
+in `config.yaml` or in the `EnvironmentSettings` passed to
`TableEnvironment.create`. Setting it
Review Comment:
Optional: this is right for `TableEnvironment.create`, but
`StreamTableEnvironment.create(env, settings)`, which the ITCase uses, puts the
settings into the session layer only (`StreamTableEnvironmentImpl:116-118`).
Setting the option there has no effect, same as with `TableConfig`. Could you
add that it has to go into the `Configuration` of the
`StreamExecutionEnvironment` in that case? Same in the zh file.
##########
flink-table/flink-table-api-java/src/main/java/org/apache/flink/table/api/MaterializedPipeline.java:
##########
@@ -57,6 +58,8 @@ public interface MaterializedPipeline {
* mode of the existing materialized table.
* @throws ValidationException if the start mode is {@code FROM_TIMESTAMP}
or {@code
* RESUME_OR_FROM_TIMESTAMP} without a timestamp, or has an offset
that is not positive.
+ * @throws ValidationException if a regular table exists at the path and
conversion is not
Review Comment:
Optional: with the Table API check gone, a user who forgot the option now
gets "Regular table does not support create or alter operation.". That names
neither the table nor the option, and `TableConfig.set(...)`, the obvious thing
to try, changes nothing. Could the factory message name the identifier and the
option key, and where to set it? Only the three `hasMessageContaining` asserts
in `SqlNodeToOperationConvertTableToMaterializedTableTest` would need updating.
The message is shared with SQL, so a separate JIRA is fine too.
Two Javadoc nits while here:
- "Returns once the materialized table is created or altered" (line 51)
could also say converted.
- `MaterializedTableDescriptor.Builder#partitionedBy` says partition keys
"are only applied when the materialized table is created". In a conversion,
they must match the regular table's keys in order.
##########
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/runtime/stream/sql/MaterializedTableTableApiITCase.java:
##########
@@ -469,8 +469,9 @@ void testRegularTableAndViewAtThePathAreRejected() throws
Exception {
.containsExactly(
"Could not execute CreateTable in path
`test_catalog`.`test_db`.`existing_view`",
"Table (or view) test_db.existing_view already exists
in Catalog test_catalog.");
- // A view under createOrAlter() is rejected by the factory. The
regular-table case is
- // rejected before planning and covered in
MaterializedPipelineImplTest.
+ // createOrAlter() on a regular table is covered by
DefaultMaterializedTableExecutorTest
Review Comment:
Optional: the deleted
`MaterializedPipelineImplTest#regularTableAtThePathIsRejected` was the only
test of the conversion-disabled case through `materializeInto`.
`SqlNodeToOperationConvertTableToMaterializedTableTest` reaches it through the
SQL converter. Conversion is off in this ITCase and `existing_table` already
exists here, so one more assert covers it:
```java
assertThatThrownBy(
() ->
usersShopsQuery()
.materializeInto("existing_table")
.execute(CreateMode.createOrAlter()))
.isInstanceOf(ValidationException.class)
.extracting(FlinkAssertions::chainOfCauses,
FlinkAssertions.STREAM_THROWABLE)
.extracting(Throwable::getMessage)
.containsExactly("Regular table does not support create or alter
operation.");
```
The closing asserts (still a `TABLE`, no new jobs) then cover it as well,
and this comment can go. FLINK-41399 names the case explicitly ("when the
option is disabled").
--
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]