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:
    TableConfigOptions.PLAN_COMPILE_CATALOG_OBJECTS, TableConfigOptions.PLAN_RESTORE_CATALOG_OBJECTS, PlanReference
    • Method Detail

      • asJsonString

        String asJsonString()
        Convert the plan to a JSON string representation.
      • 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:
        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:
        TableException - if the file cannot be written or if ignoreIfExists is false and a plan already exists.
      • getFlinkVersion

        FlinkVersion getFlinkVersion()
        Returns the Flink version used to compile the plan.