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


##########
flink-table/flink-table-api-java/src/main/java/org/apache/flink/table/api/internal/materializedtable/MaterializedTableImpl.java:
##########
@@ -92,6 +96,34 @@ public Optional<String> getRefreshHandlerDescription() {
         return lookUp().getRefreshHandlerDescription();
     }
 
+    @Override
+    public void suspend() {
+        tableEnvironment.executeInternal(new 
AlterMaterializedTableSuspendOperation(identifier));
+    }
+
+    @Override
+    public void resume() {
+        resume(Map.of());
+    }
+
+    @Override
+    public void resume(Map<String, String> dynamicOptions) {
+        Preconditions.checkNotNull(dynamicOptions, "Dynamic options must not 
be null.");
+        tableEnvironment.executeInternal(
+                new AlterMaterializedTableResumeOperation(identifier, 
Map.copyOf(dynamicOptions)));
+    }
+
+    @Override
+    public boolean drop() {
+        return drop(true);
+    }
+
+    @Override
+    public boolean drop(boolean ignoreIfNotExists) {

Review Comment:
   Optional: nothing exercises the handle's `drop()` yet. Cheap spot: in 
`testDropMaterializedTableInContinuousMode`, keep the handle `execute()` 
returns and swap `tEnv.dropMaterializedTable(...)` for 
`assertThat(mt.drop()).isTrue()`; after the cancel wait add 
`assertThat(mt.drop()).isFalse()` and 
`assertThatThrownBy(mt::suspend).isInstanceOf(ValidationException.class)`. That 
pins the FLIP's "once dropped, `drop(true)` returns false and every other call 
fails with a ValidationException".



##########
flink-table/flink-table-api-java/src/main/java/org/apache/flink/table/api/MaterializedTable.java:
##########
@@ -83,4 +84,57 @@ public interface MaterializedTable {
      * @throws ValidationException if no materialized table exists at its path 
anymore.
      */
     Optional<String> getRefreshHandlerDescription();
+
+    /**
+     * Suspends this materialized table.
+     *
+     * <p>Fails if no materialized table exists at {@link #getIdentifier()}, 
if a temporary table or
+     * view shadows it, if it is still initializing or already suspended, or 
if its refresh job
+     * cannot be stopped.
+     */
+    void suspend();

Review Comment:
   Nit: the FLIP Javadoc names the SQL equivalent ("Equivalent to `ALTER 
MATERIALIZED TABLE ... SUSPEND`" / "`... RESUME [WITH (...)]`"), and for 
`resume` says it returns once the job is submitted "and the table is recorded 
as ACTIVATED". Both hold today and would save readers a trip to the docs.



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