snuyanzin commented on code in PR #27302:
URL: https://github.com/apache/flink/pull/27302#discussion_r2585065887
##########
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/operations/SqlMaterializedTableNodeToOperationConverterTest.java:
##########
@@ -861,97 +701,274 @@ void
testCreateOrAlterMaterializedTableForExistingTable() throws TableNotExistEx
"f",
DataTypes.VARCHAR(Integer.MAX_VALUE))));
}
- private static Collection<Arguments>
testDataForCreateMaterializedTableFailedCase() {
- final Collection<Arguments> list = new ArrayList<>();
- list.addAll(create());
- list.addAll(alter());
+ private static Collection<TestSpec>
testDataForCreateMaterializedTableFailedCase() {
+ final Collection<TestSpec> list = new ArrayList<>();
+ list.addAll(createWithInvalidSchema());
+ list.addAll(createWithInvalidFreshness());
+ list.addAll(createWithInvalidPartitions());
+ list.addAll(alterWithInvalidSchema());
+ list.addAll(alterQuery());
return list;
}
- private static Collection<Arguments> alter() {
+ private static Collection<TestSpec> alterQuery() {
return List.of(
- Arguments.of(
+ TestSpec.of(
"ALTER MATERIALIZED TABLE base_mtbl AS SELECT a, b
FROM t3",
"Failed to modify query because drop column is
unsupported. When modifying "
+ "a query, you can only append new columns at
the end of original "
+ "schema. The original schema has 4 columns,
but the newly derived "
+ "schema from the query has 2 columns."),
- Arguments.of(
+ TestSpec.of(
"ALTER MATERIALIZED TABLE base_mtbl AS SELECT a, b, d,
c FROM t3",
"When modifying the query of a materialized table,
currently only support "
+ "appending columns at the end of original
schema, dropping, "
+ "renaming, and reordering columns are not
supported.\n"
+ "Column mismatch at position 2: Original
column is [`c` INT], "
+ "but new column is [`d` STRING]."),
- Arguments.of(
+ TestSpec.of(
"ALTER MATERIALIZED TABLE base_mtbl AS SELECT a, b, c,
CAST(d AS INT) AS d FROM t3",
"When modifying the query of a materialized table,
currently only support "
+ "appending columns at the end of original
schema, dropping, "
+ "renaming, and reordering columns are not
supported.\n"
+ "Column mismatch at position 3: Original
column is [`d` STRING], "
+ "but new column is [`d` INT]."),
- Arguments.of(
+ TestSpec.of(
"ALTER MATERIALIZED TABLE base_mtbl AS SELECT a, b, c,
CAST('d' AS STRING) AS d FROM t3",
"When modifying the query of a materialized table,
currently only support "
+ "appending columns at the end of original
schema, dropping, "
+ "renaming, and reordering columns are not
supported.\n"
+ "Column mismatch at position 3: Original
column is [`d` STRING], "
+ "but new column is [`d` STRING NOT NULL]."),
- Arguments.of(
+ TestSpec.of(
"ALTER MATERIALIZED TABLE t1 AS SELECT * FROM t1",
- "Only materialized tables support modifying the
definition query."));
+ "ALTER MATERIALIZED TABLE for a table is not
allowed"));
}
- private static Collection<Arguments> create() {
+ private static List<TestSpec> alterWithInvalidSchema() {
return List.of(
- Arguments.of(
+ TestSpec.of(
+ "ALTER MATERIALIZED TABLE base_mtbl ADD WATERMARK for
invalid_column as invalid_column",
+ "Failed to execute ALTER MATERIALIZED TABLE
statement.\n"
+ + "Invalid column name 'invalid_column' for
rowtime attribute in watermark declaration. "
+ + "Available columns are: [a, b, c, d]"),
+ TestSpec.of(
+ "ALTER MATERIALIZED TABLE base_mtbl_with_watermark ADD
WATERMARK for t as current_timestamp - INTERVAL '2' SECOND",
+ "Failed to execute ALTER MATERIALIZED TABLE
statement.\n"
+ + "The base materialized table has already
defined the watermark strategy "
+ + "`t` AS CURRENT_TIMESTAMP - INTERVAL '5'
SECOND. You might want to drop it before adding a new one."),
+ TestSpec.of(
+ "ALTER MATERIALIZED TABLE base_mtbl ADD
`physical_not_used_in_query` BIGINT NOT NULL",
+ "Invalid as physical column
'physical_not_used_in_query' is defined in the DDL, but is not used in a query
column."),
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]