Please keep the discussion on the mailing list rather than commenting on the wiki (wiki discussions get unwieldy fast).

Motivation

This FLIP is another step in the story of bringing Table API and FlinkSQL closer to each other.

It continues the activities started with FLIP-489.

It adds create methods with missing signature to TableEnvironment (alter functionality will be added in follow up FLIP(s)).

There are already existing createTemporaryTable and createTemporaryView however still missing createTable (with ignoreIfExists) and createView

Public Interfaces

  • TableEnvironment

Proposed Changes

TableEnvironment


/**
 * Registers a {@link Table} API object as a view similar to SQL views.
 *
 * @param path The path under which the view will be registered. See also the {@link
 *     TableEnvironment} class description for the format of the path.
 * @param view The view to register.
 */
void createView(String path, Table view);

/**
 * Registers a {@link Table} API object as a view similar to SQL views.
 *
 * @param path The path under which the view will be registered. See also the {@link
 *     TableEnvironment} class description for the format of the path.
 * @param view The view to register.
 * @param ignoreIfExists If a view or a table exists and the given flag is set, no operation is executed.
 * An exception is thrown otherwise.
 */
boolean createView(String path, Table view, boolean ignoreIfExists);

/**
 * Registers the given {@link TableDescriptor} as a catalog table.
 *
 * <p>The {@link TableDescriptor descriptor} is converted into a {@link CatalogTable} and stored
 * in the catalog.
 *
 *
 * <p>Examples:
 *
 * <pre>{@code
 * tEnv.createTable("MyTable", TableDescriptor.forConnector("datagen")
 * .schema(Schema.newBuilder()
 * .column("f0", DataTypes.STRING())
 * .build())
 * .option(DataGenOptions.ROWS_PER_SECOND, 10)
 * .option("fields.f0.kind", "random")
 * .build(), ignoreIfExists);
 * }</pre>
 *
 * @param path The path under which the table will be registered. See also the {@link
 * TableEnvironment} class description for the format of the path.
 * @param descriptor Template for creating a {@link CatalogTable} instance.
 * @param ignoreIfExists If a view or a table exists and the given flag is set, no operation is executed.
 * An exception is thrown otherwise.
 */

boolean createTable(String path, TableDescriptor descriptor, boolean ignoreIfExists);

Compatibility, Deprecation, and Migration Plan

  • No migration required.

Test Plan

  • Unit tests/ ITtests

Rejected Alternatives

None.