davidradl commented on code in PR #26154: URL: https://github.com/apache/flink/pull/26154#discussion_r1954505598
########## docs/content/docs/libs/state_processor_api.md: ########## @@ -514,3 +512,120 @@ savepointWriter OperatorIdentifier.forUid("new-uid")) ... ``` + +## Table API + +### Getting started + +Before getting started with state SQL connector, make sure to review our [Flink SQL](../development/sql.md) guidelines. + +IMPORTANT NOTE: State Table API is now only supports keyed state. + +### Keyed State + +[Keyed state]({{< ref "docs/dev/datastream/fault-tolerance/state" >}}#keyed-state), or partitioned state, is any state that is partitioned relative to a key. + +The SQL connector allows users to read arbitrary columns as ValueState and complex state types such as ListState, MapState. +This means if an operator contains a stateful process function such as: +```java +eventStream + .keyBy(e -> (Integer)e.key) + .process(new StatefulFunction()) + .uid("my-uid"); + +... + +public class Account { + private Integer id; + public Double amount; + + public Integer geId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } +} + +public class StatefulFunction extends KeyedProcessFunction<Integer, Integer, Void> { + private ValueState<Integer> myValueState; + private ValueState<Account> myAccountValueState; + private ListState<Integer> myListState; + private MapState<Integer, Integer> myMapState; + + @Override + public void open(OpenContext openContext) { + myValueState = getRuntimeContext().getState(new ValueStateDescriptor<>("MyValueState", Integer.class)); + myAccountValueState = getRuntimeContext().getState(new ValueStateDescriptor<>("MyAccountValueState", Account.class)); + myValueState = getRuntimeContext().getListState(new ListStateDescriptor<>("MyListState", Integer.class)); + myMapState = getRuntimeContext().getMapState(new MapStateDescriptor<>("MyMapState", Integer.class, Integer.class)); + } + ... +} +``` + +Then it can read by using the following SQL statement: Review Comment: nit: the create table is not reading it. Maybe change this to "Then it can read by querying a table created using the following SQL statement" -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@flink.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org