anishshri-db commented on code in PR #48401:
URL: https://github.com/apache/spark/pull/48401#discussion_r1817400618
##########
sql/core/src/main/scala/org/apache/spark/sql/execution/streaming/StateStoreColumnFamilySchemaUtils.scala:
##########
@@ -17,35 +17,64 @@
package org.apache.spark.sql.execution.streaming
import org.apache.spark.sql.Encoder
+import org.apache.spark.sql.avro.{AvroDeserializer, AvroOptions,
AvroSerializer, SchemaConverters}
import org.apache.spark.sql.catalyst.encoders.ExpressionEncoder
import
org.apache.spark.sql.execution.streaming.TransformWithStateKeyValueRowSchemaUtils._
import
org.apache.spark.sql.execution.streaming.state.{NoPrefixKeyStateEncoderSpec,
PrefixKeyScanStateEncoderSpec, StateStoreColFamilySchema}
+import org.apache.spark.sql.execution.streaming.state.AvroEncoderSpec
import org.apache.spark.sql.types.StructType
object StateStoreColumnFamilySchemaUtils {
+ def apply(initializeAvroSerde: Boolean): StateStoreColumnFamilySchemaUtils =
+ new StateStoreColumnFamilySchemaUtils(initializeAvroSerde)
+}
+
+class StateStoreColumnFamilySchemaUtils(initializeAvroSerde: Boolean) {
+
+ private def getAvroSerde(
+ keySchema: StructType, valSchema: StructType): Option[AvroEncoderSpec] =
{
+ if (initializeAvroSerde) {
+ val avroType = SchemaConverters.toAvroType(valSchema)
+ val avroOptions = AvroOptions(Map.empty)
+ val keyAvroType = SchemaConverters.toAvroType(keySchema)
+ val keySer = new AvroSerializer(keySchema, keyAvroType, nullable = false)
+ val ser = new AvroSerializer(valSchema, avroType, nullable = false)
+ val de = new AvroDeserializer(avroType, valSchema,
+ avroOptions.datetimeRebaseModeInRead,
avroOptions.useStableIdForUnionType,
+ avroOptions.stableIdPrefixForUnionType,
avroOptions.recursiveFieldMaxDepth)
Review Comment:
lets go through these options and make sure they are safe ?
--
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]