AHeise commented on code in PR #30143:
URL: https://github.com/apache/flink/pull/30143#discussion_r4801262808


##########
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/delegation/materializedtable/DefaultMaterializedTableExecutorTest.java:
##########
@@ -700,6 +701,74 @@ void 
materializeIntoKeepsARegularTableWhenFullRefreshHasNoScheduler() throws Exc
         }
     }
 
+    @Nested
+    class ReadAndDerive {

Review Comment:
   No test exercises `toTable()`. Could you add one here that checks its 
resolved schema equals the materialized table's, and that it throws 
`ValidationException` once a temporary table shadows the path?



##########
flink-table/flink-table-api-java/src/main/java/org/apache/flink/table/api/MaterializedTable.java:
##########
@@ -85,6 +85,37 @@ public interface MaterializedTable extends 
Explainable<MaterializedTable> {
      */
     Optional<String> getRefreshHandlerDescription();
 
+    /**
+     * This table's data, for querying it or building downstream tables on it, 
e.g. with {@link
+     * Table#materializeInto(String, MaterializedTableDescriptor)}.
+     *
+     * @return the materialized table as a {@link Table}
+     * @throws ValidationException if no materialized table exists at its path 
anymore, or a
+     *     temporary table or view shadows it.
+     */
+    Table toTable();
+
+    /**
+     * The query that defines this table, for deriving a modified definition, 
e.g. with {@link
+     * Table#materializeInto(String, MaterializedTableDescriptor)}.
+     *
+     * @return the expanded query as a {@link Table}
+     * @throws ValidationException if no materialized table exists at its path 
anymore.
+     */
+    Table toQuery();
+
+    /**
+     * This table's current definition, as a descriptor for re-declaring it, 
e.g. with {@link
+     * Table#materializeInto(String, MaterializedTableDescriptor)}.
+     *
+     * <p>The descriptor declares every column, so re-declaring with a query 
that drops a physical
+     * or persisted metadata column fails.
+     *
+     * @return a descriptor of the current definition
+     * @throws ValidationException if no materialized table exists at its path 
anymore.

Review Comment:
   nit: `toQuery()` and `toDescriptor()` also throw when a temporary table or 
view shadows the path, since `lookUp()` rejects it by kind (`Table '...' is not 
a materialized table, ...`). `toTable()` mentions this, but these two and the 
existing getters don't. Could they say so too?



##########
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/delegation/materializedtable/DefaultMaterializedTableExecutorTest.java:
##########
@@ -700,6 +701,74 @@ void 
materializeIntoKeepsARegularTableWhenFullRefreshHasNoScheduler() throws Exc
         }
     }
 
+    @Nested
+    class ReadAndDerive {
+
+        @Test
+        void 
materializedTableToQueryAndToDescriptorRedeclareADerivedDefinition() throws 
Exception {

Review Comment:
   This round trip starts from a materialized table created through the Table 
API. A SQL-created one, e.g. `CREATE MATERIALIZED TABLE t (k_plus_one AS k + 1, 
PRIMARY KEY (k) NOT ENFORCED, WATERMARK FOR ts AS ...) AS SELECT ...`, stores 
the computed column first. That exercises the declared-only-columns-first 
ordering of `AsQuerySchemaMerger` in a `toDescriptor()` round trip. Worth one 
more case, since the docs describe this for tables created in SQL as well?



-- 
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]

Reply via email to