Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

This is a new feature and compatible with old version Flink. We may extend the TableSourceTable to support computed column interfaces, but this is transparent to user.

Implementation Plan

  1. Introduce ColumnStrategy enum to describe the NULL/NOT NULL/VIRTUAL/STORED attributes of the DDL table column, a table column can have multiple attributes, i.g. a VIRTUAL column can also be declared as NOT NULL.
  2. Introduce the InitializerExpressionFactory to handle the initialization of the default value and generation of the computation expressions for generated columns.
  3. Make the FlinkRelOptTable extend the interface InitializerExpressionFactory because it is the abstraction of out Flink table for Calcite schema look up.
  4. Introduce the TableColumn structure in InternalTableSchema to describe the name/type/expression of the declared columns from the DDL. TableColumn should be kept serializable in order to be persisted within the BaseCatalogTable into the catalog.
  5. Introduce the InternalTableSchema to describe our internal table schema(not visible to the table source/sink). The InternalTableSchema contains definitions of all the TableColumn.

Test Plan

The implementation can be tested with unit tests for every new feature. And we can add integration tests for connectors to verify it can cooperate with existing source implementations.


Reference:

[1] https://docs.microsoft.com/en-us/sql/relational-databases/tables/specify-computed-columns-in-a-table?view=sql-server-2016

[2] https://dev.mysql.com/doc/refman/5.7/en/create-table-generated-columns.html

[3] https://oracle-base.com/articles/11g/virtual-columns-11gr1