anishshri-db commented on code in PR #47508: URL: https://github.com/apache/spark/pull/47508#discussion_r1694465328
########## sql/core/src/main/scala/org/apache/spark/sql/execution/streaming/TransformWithStateExec.scala: ########## @@ -441,6 +443,43 @@ case class TransformWithStateExec( new Path(new Path(storeNamePath, "_metadata"), "schema") } + private def checkStateVariableEquality( + oldStateVariableInfos: List[TransformWithStateVariableInfo]): Unit = { + val newStateVariableInfos = getStateVariableInfos() + oldStateVariableInfos.foreach { oldInfo => + val newInfo = newStateVariableInfos.get(oldInfo.stateName) + newInfo match { + case Some(stateVarInfo) => + if (oldInfo.stateVariableType != stateVarInfo.stateVariableType) { + throw StateStoreErrors.invalidVariableTypeChange( + stateVarInfo.stateName, + oldInfo.stateVariableType.toString, + stateVarInfo.stateVariableType.toString + ) + } + case None => + } + } + } + + override def validateNewMetadata( + oldOperatorMetadata: OperatorStateMetadata, + newOperatorMetadata: OperatorStateMetadata): Unit = { + (oldOperatorMetadata, newOperatorMetadata) match { + case ( + oldMetadataV2: OperatorStateMetadataV2, + newMetadataV2: OperatorStateMetadataV2) => + val oldOperatorProps = TransformWithStateOperatorProperties.fromJson( + oldMetadataV2.operatorPropertiesJson) + val newOperatorProps = TransformWithStateOperatorProperties.fromJson( + newMetadataV2.operatorPropertiesJson) + TransformWithStateOperatorProperties.validateOperatorProperties( + oldOperatorProps, newOperatorProps) + checkStateVariableEquality(oldOperatorProps.stateVariables) Review Comment: Can we just move this to the `validate` function itself ? -- 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: reviews-unsubscr...@spark.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org