jingz-db commented on code in PR #47574:
URL: https://github.com/apache/spark/pull/47574#discussion_r1710382348


##########
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/v2/state/StateDataSource.scala:
##########
@@ -91,9 +224,40 @@ class StateDataSource extends TableProvider with 
DataSourceRegister {
           val storeId = new StateStoreId(stateCheckpointLocation.toString, 
sourceOptions.operatorId,
             partitionId, sourceOptions.storeName)
           val providerId = new StateStoreProviderId(storeId, UUID.randomUUID())
-          val manager = new StateSchemaCompatibilityChecker(providerId, 
hadoopConf)
-          val stateSchema = manager.readSchemaFile().head
-          (stateSchema.keySchema, stateSchema.valueSchema)
+          val storeMetadata = stateStoreMetadata.get
+
+          val stateVarName = sourceOptions.stateVarName
+            .getOrElse(StateStore.DEFAULT_COL_FAMILY_NAME)
+
+          // Read the schema file path from operator metadata version v2 
onwards
+          val oldSchemaFilePath = if (storeMetadata.length > 0 && 
storeMetadata.head.version == 2) {
+            val storeMetadataEntry = storeMetadata.head
+            val operatorProperties = 
TransformWithStateOperatorProperties.fromJson(
+              storeMetadataEntry.operatorPropertiesJson)
+            val stateVarInfoList = operatorProperties.stateVariables
+              .filter(stateVar => stateVar.stateName == stateVarName)
+            require(stateVarInfoList.size == 1)

Review Comment:
   nits: Shall we add some message in the `require` here?



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to