Package org.apache.flink.table.functions
Interface TableSemantics
-
@PublicEvolving public interface TableSemantics
Provides call information about the table that has been passed to a table argument.This class is only available for table arguments (i.e. arguments of a
ProcessTableFunction
that are annotated with@ArgumentHint(TABLE_AS_SET)
or@ArgumentHint(TABLE_AS_ROW)
).
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description Optional<ChangelogMode>
changelogMode()
Actual changelog mode for the passed table.List<String>
coPartitionArgs()
Returns information about which passed tables are co-partitioned with the passed table.DataType
dataType()
Data type of the passed table.int[]
orderByColumns()
Returns information about how the passed table is ordered.int[]
partitionByColumns()
Returns information about how the passed table is partitioned.int
timeColumn()
Returns information about the time attribute of the passed table.
-
-
-
Method Detail
-
dataType
DataType dataType()
Data type of the passed table.The returned data type might be the one that has been explicitly defined for the argument or a
DataTypes.ROW(org.apache.flink.table.api.DataTypes.Field...)
data type for polymorphic arguments that accept any type of row.For example:
// Function with explicit table argument type of row class MyPTF extends ProcessTableFunction<String> { public void eval(Context ctx, @ArgumentHint(value = ArgumentTrait.TABLE_AS_SET, type = "ROW < s STRING >") Row t) { TableSemantics semantics = ctx.tableSemanticsFor("t"); // Always returns "ROW < s STRING >" semantics.dataType(); ... } } // Function with explicit table argument type of structured type "Customer" class MyPTF extends ProcessTableFunction<String> { public void eval(Context ctx, @ArgumentHint(value = ArgumentTrait.TABLE_AS_SET) Customer c) { TableSemantics semantics = ctx.tableSemanticsFor("c"); // Always returns structured type of "Customer" semantics.dataType(); ... } } // Function with polymorphic table argument class MyPTF extends ProcessTableFunction<String> { public void eval(Context ctx, @ArgumentHint(value = ArgumentTrait.TABLE_AS_SET) Row t) { TableSemantics semantics = ctx.tableSemanticsFor("t"); // Always returns "ROW" but content depends on the table that is passed into the call semantics.dataType(); ... } }
-
partitionByColumns
int[] partitionByColumns()
Returns information about how the passed table is partitioned. Applies only to table arguments with set semantics.- Returns:
- An array of indexes (0-based) that specify the PARTITION BY columns.
-
orderByColumns
int[] orderByColumns()
Returns information about how the passed table is ordered. Applies only to table arguments with set semantics.- Returns:
- An array of indexes (0-based) that specify the ORDER BY columns.
-
timeColumn
int timeColumn()
Returns information about the time attribute of the passed table. The time attribute column powers the concept of rowtime and timers. Applies to both table arguments with row and set semantics.- Returns:
- Position of the "ON_TIME" column. Returns -1 in case no time attribute has been passed.
-
coPartitionArgs
List<String> coPartitionArgs()
Returns information about which passed tables are co-partitioned with the passed table. Applies only to table arguments with set semantics.- Returns:
- List of table argument names (not table names!) that are co-partitioned with the passed table.
-
changelogMode
Optional<ChangelogMode> changelogMode()
Actual changelog mode for the passed table. By default, table arguments take onlyChangelogMode.insertOnly()
. They are able to take tables of other changelog modes, if specified to do so (e.g. via anArgumentTrait
). This method returns the final changelog mode determined by the planner.- Returns:
- The definitive changelog mode expected for the passed table after physical optimization. Returns an actual value when called during runtime. Returns empty during type inference phase as the changelog mode is still unknown.
-
-