You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by "anishshri-db (via GitHub)" <gi...@apache.org> on 2025/02/03 06:32:19 UTC
Re: [PR] [SPARK-51065][SQL] Disallowing non-nullable schema when Avro encoding is used for TransformWithState [spark]
anishshri-db commented on code in PR #49751:
URL: https://github.com/apache/spark/pull/49751#discussion_r1938843936
##########
sql/core/src/main/scala/org/apache/spark/sql/execution/streaming/StatefulProcessorHandleImpl.scala:
##########
@@ -363,18 +363,25 @@ class DriverStatefulProcessorHandleImpl(timeMode: TimeMode, keyExprEnc: Expressi
addTimerColFamily()
}
+ private def isInternal(columnFamilyName: String): Boolean = {
+ columnFamilyName.startsWith("_") || columnFamilyName.startsWith("$")
+ }
+
def getColumnFamilySchemas(
- setNullableFields: Boolean
+ shouldCheckNullable: Boolean
): Map[String, StateStoreColFamilySchema] = {
val schemas = columnFamilySchemas.toMap
- if (setNullableFields) {
- schemas.map { case (colFamilyName, stateStoreColFamilySchema) =>
- colFamilyName -> stateStoreColFamilySchema.copy(
- valueSchema = stateStoreColFamilySchema.valueSchema.toNullable
- )
+ schemas.map { case (colFamilyName, schema) =>
+ // assert that each field is nullable if schema evolution is enabled
+ schema.valueSchema.fields.foreach { field =>
+ if (!field.nullable && shouldCheckNullable && !isInternal(colFamilyName)) {
Review Comment:
Why do we need to treat internal col families differently ?
--
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-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org