@@ -79,14 +79,7 @@ class StateDataSource extends TableProvider with DataSourceRegister with Logging
7979 val (stateStoreReaderInfo, storeMetadata) = getStoreMetadataAndRunChecks(
8080 sourceOptions)
8181
82- // Extract stateFormatVersion from StateStoreConf for SYMMETRIC_HASH_JOIN operator
83- val isJoin = (
84- storeMetadata.head.operatorName == StatefulOperatorsUtils .SYMMETRIC_HASH_JOIN_EXEC_OP_NAME )
85- val stateFormatVersion : Int = if (storeMetadata.nonEmpty && isJoin) {
86- session.conf.get(SQLConf .STREAMING_JOIN_STATE_FORMAT_VERSION )
87- } else {
88- 1
89- }
82+ val stateFormatVersion = getStateFormatVersion(storeMetadata)
9083
9184 // The key state encoder spec should be available for all operators except stream-stream joins
9285 val keyStateEncoderSpec = if (stateStoreReaderInfo.keyStateEncoderSpecOpt.isDefined) {
@@ -102,7 +95,7 @@ class StateDataSource extends TableProvider with DataSourceRegister with Logging
10295 stateStoreReaderInfo.stateSchemaProviderOpt,
10396 stateStoreReaderInfo.joinColFamilyOpt,
10497 Option (stateStoreReaderInfo.allColumnFamiliesReaderInfo),
105- Option ( stateFormatVersion) )
98+ stateFormatVersion)
10699 }
107100
108101 override def inferSchema (options : CaseInsensitiveStringMap ): StructType = {
@@ -112,14 +105,7 @@ class StateDataSource extends TableProvider with DataSourceRegister with Logging
112105 val (stateStoreReaderInfo, storeMetadata) = getStoreMetadataAndRunChecks(sourceOptions)
113106 val oldSchemaFilePaths = StateDataSource .getOldSchemaFilePaths(sourceOptions, hadoopConf)
114107
115- // Extract stateFormatVersion from StateStoreConf for SYMMETRIC_HASH_JOIN operator
116- val stateFormatVersion = if (storeMetadata.nonEmpty &&
117- (storeMetadata.head.operatorName ==
118- StatefulOperatorsUtils .SYMMETRIC_HASH_JOIN_EXEC_OP_NAME )) {
119- Some (session.conf.get(SQLConf .STREAMING_JOIN_STATE_FORMAT_VERSION ))
120- } else {
121- None
122- }
108+ val stateFormatVersion = getStateFormatVersion(storeMetadata)
123109
124110 val stateCheckpointLocation = sourceOptions.stateCheckpointLocation
125111 try {
@@ -159,6 +145,20 @@ class StateDataSource extends TableProvider with DataSourceRegister with Logging
159145
160146 override def supportsExternalMetadata (): Boolean = false
161147
148+ /**
149+ * Returns the state format version for SYMMETRIC_HASH_JOIN operators.
150+ * For join operators, returns the configured version; for other operators returns None.
151+ */
152+ private def getStateFormatVersion (
153+ storeMetadata : Array [StateMetadataTableEntry ]): Option [Int ] = {
154+ if (storeMetadata.nonEmpty &&
155+ storeMetadata.head.operatorName == StatefulOperatorsUtils .SYMMETRIC_HASH_JOIN_EXEC_OP_NAME ) {
156+ Some (session.conf.get(SQLConf .STREAMING_JOIN_STATE_FORMAT_VERSION ))
157+ } else {
158+ None
159+ }
160+ }
161+
162162 /**
163163 * Returns true if this is a read-all-column-families request for a stream-stream join
164164 * that uses virtual column families (state format version 3).
@@ -389,13 +389,14 @@ class StateDataSource extends TableProvider with DataSourceRegister with Logging
389389 }
390390 }
391391
392+ val operatorName = if (storeMetadata.nonEmpty) storeMetadata.head.operatorName else " "
392393 (StateStoreReaderInfo (
393394 keyStateEncoderSpecOpt,
394395 stateStoreColFamilySchemaOpt,
395396 transformWithStateVariableInfoOpt,
396397 stateSchemaProvider,
397398 joinColFamilyOpt,
398- AllColumnFamiliesReaderInfo (stateStoreColFamilySchemas, stateVariableInfos)
399+ AllColumnFamiliesReaderInfo (stateStoreColFamilySchemas, stateVariableInfos, operatorName )
399400 ), storeMetadata)
400401 }
401402
0 commit comments