Skip to content

Conversation

@snuyanzin
Copy link
Contributor

@snuyanzin snuyanzin commented Nov 10, 2025

What is the purpose of the change

This PR is starting PR for FLIP-550. Adds support for schema definition while CREATE MATERIALIZED TABLE.
Also revisits a bit hierarchy of classes for materialized table converters in a way similar to tables.

After that it will allow to have syntax in way

CREATE MATERIALIZED TABLE [catalog_name.][db_name.]table_name
[( { <schema_definition> | <column_list> } )]
...
AS <select_statement>
<schema_definition>:
  [ <column_definition>[, ...n] ],
  [ <watermark_definition> ],
  [ <table_constraint>[, ...n] ]
  
<column_list>:
  col_name1 [, column_name2, ...]

Brief change log

parser and materialized table converters

Verifying this change

A number of tests added for parser, converters

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)
  • If yes, how is the feature documented? (docs / JavaDocs)

@flinkbot
Copy link
Collaborator

flinkbot commented Nov 10, 2025

CI report:

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


public boolean isSchemaWithColumnsIdentifiersOnly() {
// CREATE MATERIALIZED TABLE supports passing only column identifiers in the column list. If
// the first column in the list is an identifier, then we assume the rest of the
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As this as called from validate, would it make sense to validate that all the columns are identifiers rather than assume?

Copy link
Contributor Author

@snuyanzin snuyanzin Nov 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there is no need for that since it is not a validation.
The validation, that if first is identifier then others are as well, happens on parse level
I submitted a test for that
https://github.com/snuyanzin/flink/blob/9963205624c657c6943fc5e726d4b1c151dfd941/flink-table/flink-sql-parser/src/test/java/org/apache/flink/sql/parser/MaterializedTableStatementParserTest.java#L51-L57


if (tableConstraint != null) {
writer.newlineAndIndent();
if (!columnList.isEmpty() || !tableConstraints.isEmpty() || watermark != null) {
Copy link
Contributor

@davidradl davidradl Nov 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am curious - can we have a watermark when there are no columns? I am not sure what a no column materialized table means - is this allowed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we still can have something like

CREATE MATERIALIZED TABLE users_shops (watermark for ts as ts - interval '2' SECOND)
 FRESHNESS = INTERVAL '30' SECOND
 AS SELECT current_timestamp() as ts, 1 as shop_id, 2 as user_id

@github-actions github-actions bot added the community-reviewed PR has been reviewed by the community. label Nov 11, 2025

```sql
CREATE MATERIALIZED TABLE my_materialized_table_full (
ds, product_id, product_name, avg_sale_price, total_quantity)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

include a data type here? I think specifying both the name and data type is a very common task.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added example below

@snuyanzin snuyanzin closed this in f8e29ba Nov 12, 2025
Samrat002 pushed a commit to Samrat002/flink that referenced this pull request Dec 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community-reviewed PR has been reviewed by the community.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants