Skip to content


StateManagerImplV2 is a concrete <> (as a <>) that is used by default in FlatMapGroupsWithStateExec physical operator (per spark.sql.streaming.flatMapGroupsWithState.stateFormatVersion internal configuration property).

StateManagerImplV2 is <> exclusively when FlatMapGroupsWithStateExecHelper utility is requested for a <> (when the stateFormatVersion is 2).

=== [[creating-instance]] Creating StateManagerImplV2 Instance

StateManagerImplV2 takes the following to be created:

  • [[stateEncoder]] State encoder (ExpressionEncoder[Any])
  • [[shouldStoreTimestamp]] shouldStoreTimestamp flag

StateManagerImplV2 initializes the <>.

=== [[stateSchema]] State Schema -- stateSchema Value

[source, scala]

stateSchema: StructType

NOTE: stateSchema is part of the <> for the schema of the state.


=== [[stateSerializerExprs]] State Serializer -- stateSerializerExprs Value

[source, scala]

stateSerializerExprs: Seq[Expression]

NOTE: stateSerializerExprs is part of the <> for the state serializer, i.e. Catalyst expressions to serialize a state object to a row (UnsafeRow).


=== [[stateDeserializerExpr]] State Deserializer -- stateDeserializerExpr Value

[source, scala]

stateDeserializerExpr: Expression

NOTE: stateDeserializerExpr is part of the <> for the state deserializer, i.e. a Catalyst expression to deserialize a state object from a row (UnsafeRow).


=== [[internal-properties]] Internal Properties

[cols="30m,70",options="header",width="100%"] |=== | Name | Description

| nestedStateOrdinal a| [[nestedStateOrdinal]] Position of the state in a state row (0)

Used when...FIXME

| timeoutTimestampOrdinalInRow a| [[timeoutTimestampOrdinalInRow]] Position of the timeout timestamp in a state row (1)

Used when...FIXME