HeartSaVioR commented on code in PR #49277: URL: https://github.com/apache/spark/pull/49277#discussion_r1916056086
########## sql/core/src/main/scala/org/apache/spark/sql/execution/streaming/state/StateSchemaCompatibilityChecker.scala: ########## @@ -206,22 +206,23 @@ class StateSchemaCompatibilityChecker( } else if (!ignoreValueSchema && schemaEvolutionEnabled) { // Check value schema evolution // Sort schemas by most recent to least recent - val oldAvroSchemas = oldSchemas.sortBy(_.valueSchemaId).reverse.map { oldSchema => - SchemaConverters.toAvroTypeWithDefaults(oldSchema.valueSchema) + val oldStateSchemas = oldSchemas.sortBy(_.valueSchemaId).reverse.map { oldSchema => + StateSchemaMetadataValue( + oldSchema.valueSchema, SchemaConverters.toAvroTypeWithDefaults(oldSchema.valueSchema)) }.asJava - val l = oldSchemas.sortBy(_.valueSchemaId).reverse.map { oldSchema => - SchemaConverters.toAvroTypeWithDefaults(oldSchema.valueSchema) - } + val newAvroSchema = SchemaConverters.toAvroTypeWithDefaults(valueSchema) val validator = new SchemaValidatorBuilder().canReadStrategy.validateAll() - try { - validator.validate(newAvroSchema, oldAvroSchemas) - } catch { - case s: SchemaValidationException => - throw StateStoreErrors.stateStoreInvalidValueSchemaEvolution( - valueSchema.toString, s.getMessage) - case e: Throwable => throw e + oldStateSchemas.forEach { oldStateSchema => Review Comment: This seems to follow the model of BACKWARD_TRANSITIVE in Schema Registry. https://docs.confluent.io/platform/current/schema-registry/fundamentals/schema-evolution.html#compatibility-types I'm OK with it. If users bring the column up again when it was removed before, they take a risk. This is a trade-off between flexibility and safety, and I'm yet to be sure whether we want to define a new model for schema evolution, hence OK to follow the existing model. -- 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