Versions Compared

Key

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

...

Code Block
languagesql
col_name [data_type] AS expr
  [VIRTUAL | STORED] [NOT NULL | NULL]
  [COMMENT 'string']
  • The optional DATA_TYPE, if you want to force the data type of the computed column, specify a data type as a type hint that Flink would use. Such as the Decimal, user can coerce to the precision/scale they want.
  • The VIRTUAL keyword: Column values are not stored, but are evaluated when rows are read, it would trigger computation when it outputs, specifically for proc time(we may do some materialization eagerly, see RelTimeIndicatorConverter for details). A virtual column will not output to the table sink.
  • The STORED keyword: Column values are evaluated and stored when rows are inserted or updated. A stored column does require storage space and can be indexed.(We may support this in the future if it is needed.)
  • The default keyword is VIRTUAL if neither keyword is specified.
  • It can be combined with a NULL attribute, or provide a comment. The nullability is decided by the expression and can not be specified.

...

Code Block
languagejava
public enum ColumnStrategy {
    NULLABLE, // markMark the column as nullable value, only used for normal column
    NOT_NULLABLE, // markMark the column as not nullable, only used for normal column
    STORED, // Computed and stored, but can not insert into
    VIRTUAL; // Computed and not stored, can not insert into

    public String asSerializableString() {
      switch (this) {
      case NULLABLE:
        return "NULL";
      case NOT_NULLABLE:
        return "NOT NULL";
      case STORED:
        return "STORED";
      case VIRTUAL:
        return "VIRTUAL";
      default:
        throw new TableException("Unexpected column strategy " + this);
      }
    }

...