Versions Compared

Key

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

...

To enable configuring different state TTLs for stream join or group aggregate, users need to specify a new hint (`STATE_TTL`) in the select clause, similar to the current SQL hints[45].

Code Block
languagesql
themeConfluence
query:
  select /*+ STATE_TTL(kv_option[,kv_option]) */ ...
   
kv_option:
  key_string_literal = value_string_literal
   
key_string_literal:
  table_name | view_name | table_alias | query_block_alias
   
value_string_literal:
  ttl_duration

...

Parameter Granularity and Priority

Different ways to change state TTL for Table API/ SQL PipelineGranularityPriority
SET 'table.exec.state.ttl' = '...' The value applies to the whole pipeline, all stateful operators will use the value as state TTL by default. This is the default state TTL configuration and can be overridden by enabling the STATE_TTL hint or modifying the value of the serialized CompiledPlan.
SELECT /*+ STATE_TTL(...) */ ... The value only applies to the specific operator (currently is join and group aggregate), which is translated from the hinted query block containing the specific clause.The hint precedes the default table.exec.state.ttl. This value will be serialized to the CompiledPlan during the plan translation phase.
Modify serialized JSON content of CompiledPlan The TTL for each stateful operator is explicitly serialized as an entry of the JSON. Modifying the JSON file can change the TTL for any stateful operator.The state metadata value derives from either <1> table.exec.state.ttl or <2> STATE_TTL hint. However, if users first enable the hint, compile the query to a JSON file, manually change the TTL for the join operator, and then submit the job via the plan, the deserialized compiled plan will accept the last modified value as the final TTL parameter.


Compatibility, Deprecation, and Migration Plan

...

[3] https://nightlies.apache.org/flink/flink-docs-master/docs/dev/table/sql/queries/joins/#regular-joins

[4] https://nightlies.apache.org/flink/flink-docs-master/docs/dev/table/sql/queries/group-agg/

[5] https://nightlies.apache.org/flink/flink-docs-master/docs/dev/table/sql/queries/hints/

...