Skip to content

Commit

Permalink
fix serialization issue
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-bli committed Oct 18, 2024
1 parent ec723ee commit e71ba74
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ object Parameters {
Set("off", "no", "false", "0", "disabled")

// enable parquet format
val PARAM_USE_PARQUET_IN_WRITE: String = knownParam("use_parquet_in_write ")
val PARAM_USE_PARQUET_IN_WRITE: String = knownParam("use_parquet_in_write")

/**
* Helper method to check if a given string represents some form
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import net.snowflake.spark.snowflake.io.SupportedFormat
import net.snowflake.spark.snowflake.io.SupportedFormat.SupportedFormat
import org.apache.avro.Schema
import org.apache.avro.generic.GenericData
import org.apache.avro.generic.GenericData.Record
import org.apache.spark.rdd.RDD
import org.apache.spark.sql.types._
import org.apache.spark.sql._
Expand Down Expand Up @@ -198,8 +199,9 @@ private[snowflake] class SnowflakeWriter(jdbcWrapper: JDBCWrapper) {
format match {
case SupportedFormat.PARQUET =>
val snowflakeStyleSchema = mapColumn(data.schema, params, snowflakeStyle = true)
val schema = io.ParquetUtils.convertStructToAvro(snowflakeStyleSchema)
(data.rdd.map (row => {
(data.rdd.mapPartitions(rows => {
val schema = io.ParquetUtils.convertStructToAvro(snowflakeStyleSchema)
rows.map(row => {
def rowToAvroRecord(row: Row,
schema: Schema,
snowflakeStyleSchema: StructType,
Expand Down Expand Up @@ -232,7 +234,8 @@ private[snowflake] class SnowflakeWriter(jdbcWrapper: JDBCWrapper) {
}
record
}
rowToAvroRecord(row, schema, snowflakeStyleSchema, params)
rowToAvroRecord(row, schema, snowflakeStyleSchema, params)
})
}), snowflakeStyleSchema)
case SupportedFormat.CSV =>
val conversionFunction = genConversionFunctions(data.schema, params)
Expand Down

0 comments on commit e71ba74

Please sign in to comment.