Skip to content

[FLINK-39726][table] Support USING CONNECTION clause in CREATE TABLE#28222

Open
lihaosky wants to merge 2 commits into
apache:masterfrom
confluentinc:FLINK-39726-create-table-using-connection
Open

[FLINK-39726][table] Support USING CONNECTION clause in CREATE TABLE#28222
lihaosky wants to merge 2 commits into
apache:masterfrom
confluentinc:FLINK-39726-create-table-using-connection

Conversation

@lihaosky
Copy link
Copy Markdown
Contributor

What is the purpose of the change

Adds parser support for an optional USING CONNECTION <identifier> clause in CREATE TABLE and CREATE TABLE ... LIKE statements, per FLIP-529. This lets a table reference a previously registered connection (catalog object) for connector configuration:

CREATE TABLE orders (
    order_id INT,
    customer_id INT,
    amount DECIMAL(10, 2)
) USING CONNECTION mycat.mydb.mysql_prod
WITH (
    'connector' = 'jdbc',
    'tables' = 'orders'
);

The clause is intentionally not allowed with CTAS / RTAS — those raise a parser error.

Brief change log

  • Grammar: added optional [ <USING> <CONNECTION> CompoundIdentifier() ] between PARTITIONED BY and WITH in the SqlCreateTable production.
  • SqlCreateTable / SqlCreateTableLike: new optional connection field, constructor parameter, getConnection() getter, getOperandList() entry, and unparse output.
  • SqlCreateTableAs / SqlReplaceTableAs: explicitly pass null for connection; parser rejects USING CONNECTION combined with AS via a new ParserResource#usingConnectionWithAsUnsupported message.
  • Tests: positive cases for plain CREATE TABLE, CREATE TABLE with partition/distribution, and CREATE TABLE ... LIKE; negative case for CTAS.

Verifying this change

This change is covered by unit tests in FlinkSqlParserImplTest:

  • testCreateTableUsingConnection
  • testCreateTableUsingConnectionWithPartitionAndDistribution
  • testCreateTableLikeUsingConnection
  • testCreateTableAsWithUsingConnectionFails

Does this pull request potentially affect one of the following parts:

  • Dependencies (does it add or upgrade a dependency): (no)
  • The public API, i.e., is any changed class annotated with @Public(Evolving): (no)
  • The serializers: (no)
  • The runtime per-record code paths (performance sensitive): (no)
  • Anything that affects deployment or recovery: JobManager (and its components), Checkpointing, Kubernetes/Yarn, ZooKeeper: (no)
  • The S3 file system connector: (no)

Documentation

  • Does this pull request introduce a new feature? (yes, parser-level syntax addition; planner / runtime wiring will come in follow-up subtasks of FLIP-529)
  • If yes, how is the feature documented? (not documented yet — user-facing docs to follow once the planner/runtime side lands)

Add an optional 'USING CONNECTION <identifier>' clause to the CREATE TABLE
grammar (FLIP-529), parsed between PARTITIONED BY and WITH. The parsed
identifier is carried on SqlCreateTable and SqlCreateTableLike via a new
optional connection field that round-trips through unparse.

The clause is intentionally restricted to plain CREATE TABLE and CREATE
TABLE ... LIKE; using it with CTAS / RTAS raises a parser error
(usingConnectionWithAsUnsupported).
@flinkbot
Copy link
Copy Markdown
Collaborator

flinkbot commented May 21, 2026

CI report:

Bot commands The @flinkbot bot supports the following commands:
  • @flinkbot run azure re-run the last Azure build

…d tests

Move the USING CONNECTION unparse logic to SqlUnparseUtils.unparseUsingConnection
and emit USING / CONNECTION as separate SqlWriter.keyword calls. Add negative
tests covering REPLACE TABLE AS and CREATE OR REPLACE TABLE AS, and tighten the
failure-message regexes to match the exact resource string / line+column.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants