AHeise commented on code in PR #30239:
URL: https://github.com/apache/flink/pull/30239#discussion_r4783871599
##########
flink-table/flink-table-api-java/src/main/java/org/apache/flink/table/api/MaterializedTableEvolution.java:
##########
@@ -94,6 +150,17 @@ public interface MaterializedTableEvolution extends
Explainable<MaterializedTabl
*
* @return A new handle on the altered table.
* @throws ValidationException if the table does not exist or is not a
materialized table
+ * @throws ValidationException if a schema change names a column,
watermark, primary key or
+ * constraint that the schema left by the earlier changes does not
define, or adds one that
+ * it already defines
+ * @throws ValidationException if a schema change changes the kind of a
column
+ * @throws ValidationException if a dropped column is produced by the
query, unless it is a
Review Comment:
Optional: this `@throws` reads as if a persisted column that the query
doesn't produce could be dropped. With the default executor it can't: if the
new query omits it, `AlterMaterializedTableChangeOperation#validateChanges`
rejects the `DropColumn` with "Dropping of persisted column `%s` is not
supported.", and only at `execute()`. That rule fits there, since the executor
is pluggable through `MaterializedTableExecutorFactory`, so I'd keep it out of
`MaterializedTableEvolutionImpl` and only make the Javadoc say that the
executor may reject dropping a persisted column.
##########
docs/content/docs/sql/materialized-table/table-api.md:
##########
@@ -158,6 +158,31 @@ as one `CREATE OR ALTER MATERIALIZED TABLE`, with the
effects described in
distribution and the start mode. An alter that changes nothing leaves the
materialized table and
its refresh job untouched. In `explain()`, options that the alter resets still
apply to the sink.
+`addSchema`, `modifySchema`, `dropColumns`, `dropWatermark`, `dropPrimaryKey`
and `dropConstraint`
+change the schema like
+[`ALTER MATERIALIZED TABLE ... ADD`]({{< ref
"docs/sql/materialized-table/statements" >}}#add),
+[`MODIFY`]({{< ref "docs/sql/materialized-table/statements" >}}#modify) and
+[`DROP`]({{< ref "docs/sql/materialized-table/statements" >}}#drop):
+
+```java
+tEnv.fromMaterializedTable("orders_curated")
+ .alter()
+ .addSchema(Schema.newBuilder()
+ .columnByExpression("order_hour", "HOUR(`order_time`)")
+ .build())
+ .modifySchema(Schema.newBuilder()
+ .watermark("order_time",
$("order_time").minus(lit(10).seconds()))
+ .build())
+ .execute();
+```
+
+Unlike the SQL clauses, they also accept physical and persisted metadata
columns, and they combine
Review Comment:
Optional: this holds for ADD, but SQL `MODIFY` already accepts physical
columns (e.g. `MODIFY (c BIGINT AFTER b, ...)` in
`SqlMaterializedTableNodeToOperationConverterTest`). Maybe: "Unlike `ALTER
MATERIALIZED TABLE ... ADD`, `addSchema` also accepts physical and persisted
metadata columns, which the new query must produce." Same in the zh file.
--
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]