Interface CompiledPlan

All Superinterfaces:
Executable, Explainable<CompiledPlan>

@Experimental public interface CompiledPlan extends Explainable<CompiledPlan>, Executable
Represents an immutable, fully optimized, and executable entity that has been compiled from a Table & SQL API pipeline definition. It encodes operators, expressions, functions, data types, and table connectors.

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.

See Also:
  • Method Details

    • asJsonString

      String asJsonString()
      Convert the plan to a JSON string representation.
    • writeToFile

      default void writeToFile(String path)
      See Also:
    • writeToFile

      default void writeToFile(String path, boolean ignoreIfExists)
      See Also:
    • writeToFile

      default void writeToFile(Path path)
      See Also:
    • writeToFile

      default void writeToFile(Path path, boolean ignoreIfExists)
      See Also:
    • writeToFile

      default void writeToFile(File file)
      Writes this plan to a file using the JSON representation. This operation will fail if the file already exists, even if the content is different from this plan.
      Parameters:
      file - the target file
      Throws:
      org.apache.flink.table.api.TableException - if the file cannot be written.
    • writeToFile

      void writeToFile(File file, boolean ignoreIfExists)
      Writes this plan to a file using the JSON representation.
      Parameters:
      file - the target file
      ignoreIfExists - 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.
      Throws:
      org.apache.flink.table.api.TableException - if the file cannot be written or if ignoreIfExists is false and a plan already exists.
    • getFlinkVersion

      org.apache.flink.FlinkVersion getFlinkVersion()
      Returns the Flink version used to compile the plan.
    • printJsonString

      default CompiledPlan printJsonString()
      Like asJsonString(), but prints the result to System.out.