@Experimental public interface CompiledPlan extends Explainable<CompiledPlan>, Executable
Every new Flink version might introduce improved optimizer rules, more efficient operators, and other changes that impact the behavior of previously defined pipelines. In order to ensure backwards compatibility and enable stateful streaming job upgrades, compiled plans can be persisted and reloaded across Flink versions. See the website documentation for more information about provided guarantees during stateful pipeline upgrades.
A plan can be compiled from a SQL query using TableEnvironment.compilePlanSql(String)
.
It can be persisted using writeToFile(Path, boolean)
or by manually extracting the JSON
representation with asJsonString()
. A plan can be loaded back from a file or a string
using TableEnvironment.loadPlan(PlanReference)
. Instances can be executed using Executable.execute()
.
Depending on the configuration, permanent catalog metadata (such as information about tables and functions) will be persisted in the plan as well. Anonymous/inline objects will be persisted (including schema and options) if possible or fail the compilation otherwise. For temporary objects, only the identifier is part of the plan and the object needs to be present in the session context during a restore.
Note: Plan restores assume a stable session context. Configuration, loaded modules and catalogs, and temporary objects must not change. Schema evolution and changes of function signatures are not supported.
Modifier and Type | Method and Description |
---|---|
String |
asJsonString()
Convert the plan to a JSON string representation.
|
FlinkVersion |
getFlinkVersion()
Returns the Flink version used to compile the plan.
|
default CompiledPlan |
printJsonString()
Like
asJsonString() , but prints the result to System.out . |
default void |
writeToFile(File file)
Writes this plan to a file using the JSON representation.
|
void |
writeToFile(File file,
boolean ignoreIfExists)
Writes this plan to a file using the JSON representation.
|
default void |
writeToFile(Path path) |
default void |
writeToFile(Path path,
boolean ignoreIfExists) |
default void |
writeToFile(String path) |
default void |
writeToFile(String path,
boolean ignoreIfExists) |
explain, explain, printExplain
execute
String asJsonString()
default void writeToFile(String path)
writeToFile(File)
default void writeToFile(String path, boolean ignoreIfExists)
writeToFile(File, boolean)
default void writeToFile(Path path)
writeToFile(File)
default void writeToFile(Path path, boolean ignoreIfExists)
writeToFile(File, boolean)
default void writeToFile(File file)
file
- the target fileTableException
- if the file cannot be written.void writeToFile(File file, boolean ignoreIfExists)
file
- the target fileignoreIfExists
- If a plan exists in the given file and this flag is set, no operation
is executed and the plan is not overwritten. An exception is thrown otherwise. If this
flag is not set and TableConfigOptions.PLAN_FORCE_RECOMPILE
is set, the plan file
will be overwritten.TableException
- if the file cannot be written or if ignoreIfExists
is false
and a plan already exists.FlinkVersion getFlinkVersion()
default CompiledPlan printJsonString()
asJsonString()
, but prints the result to System.out
.Copyright © 2014–2024 The Apache Software Foundation. All rights reserved.