pyflink.table.schema.Schema.Builder.column_by_expression#
- Builder.column_by_expression(column_name: str, expr: Union[str, pyflink.table.expression.Expression]) pyflink.table.schema.Schema.Builder #
Declares a computed column that is appended to this schema.
Computed columns are virtual columns that are generated by evaluating an expression that can reference other columns declared in the same table. Both physical columns and metadata columns can be accessed. The column itself is not physically stored within the table. The column’s data type is derived automatically from the given expression and does not have to be declared manually.
Computed columns are commonly used for defining time attributes. For example, the computed column can be used if the original field is not TIMESTAMP(3) type or is nested in a JSON string.
Example:
>>> Schema.new_builder() \ ... .column_by_expression("ts", "orig_ts - INTERVAL '60' MINUTE") \ ... .column_by_metadata("orig_ts", DataTypes.TIMESTAMP(3), "timestamp")
- Parameters
column_name – Column name
expr – Computation of the column