micheal-o commented on code in PR #53386:
URL: https://github.com/apache/spark/pull/53386#discussion_r2632581091
##########
sql/core/src/main/scala/org/apache/spark/sql/execution/streaming/state/StatePartitionWriter.scala:
##########
@@ -47,30 +52,39 @@ class StatePartitionAllColumnFamiliesWriter(
operatorId: Int,
storeName: String,
currentBatchId: Long,
- columnFamilyToSchemaMap: HashMap[String, StateStoreColFamilySchema]) {
+ columnFamilyToSchemaMap: HashMap[String,
StatePartitionWriterColumnFamilyInfo]) {
private val defaultSchema = {
- columnFamilyToSchemaMap.getOrElse(
- StateStore.DEFAULT_COL_FAMILY_NAME,
- throw new IllegalArgumentException(
- s"Column family ${StateStore.DEFAULT_COL_FAMILY_NAME} not found in
schema map")
- )
+ columnFamilyToSchemaMap.get(StateStore.DEFAULT_COL_FAMILY_NAME) match {
+ case Some(info) => info.schema
+ case None =>
+ // Return a dummy StateStoreColFamilySchema if not found
+ val placeholderSchema = columnFamilyToSchemaMap.head._2.schema
+ StateStoreColFamilySchema(
+ colFamilyName = "__dummy__",
+ keySchemaId = 0,
+ keySchema = placeholderSchema.keySchema,
+ valueSchemaId = 0,
+ valueSchema = placeholderSchema.valueSchema,
+ keyStateEncoderSpec =
Option(NoPrefixKeyStateEncoderSpec(placeholderSchema.keySchema)))
+ }
}
private val columnFamilyToKeySchemaLenMap: MapView[String, Int] =
- columnFamilyToSchemaMap.view.mapValues(_.keySchema.length)
+ columnFamilyToSchemaMap.view.mapValues(_.schema.keySchema.length)
private val columnFamilyToValueSchemaLenMap: MapView[String, Int] =
- columnFamilyToSchemaMap.view.mapValues(_.valueSchema.length)
+ columnFamilyToSchemaMap.view.mapValues(_.schema.valueSchema.length)
protected lazy val provider: StateStoreProvider = {
val stateCheckpointLocation = new Path(targetCpLocation,
DIR_NAME_STATE).toString
val stateStoreId = StateStoreId(stateCheckpointLocation,
operatorId, partitionId, storeName)
val stateStoreProviderId = StateStoreProviderId(stateStoreId,
UUID.randomUUID())
+ val useColumnFamilies = columnFamilyToSchemaMap.size > 1
val provider = StateStoreProvider.createAndInit(
stateStoreProviderId, defaultSchema.keySchema, defaultSchema.valueSchema,
defaultSchema.keyStateEncoderSpec.get,
- useColumnFamilies = false, storeConf, hadoopConf,
+ useColumnFamilies = useColumnFamilies, storeConf, hadoopConf,
useMultipleValuesPerKey = false, stateSchemaProvider = None)
Review Comment:
`stateSchemaProvider` must be passed in, otherwise it won't work with Avro
state format.
--
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]