forked from RedisLabs/spark-redis
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Binary serde issue. Type inconsistency with Spark Catalyst
- Loading branch information
Showing
4 changed files
with
39 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
src/main/scala/com/redislabs/provider/redis/util/SparkUtils.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.redislabs.provider.redis.util | ||
|
||
import org.apache.spark.sql.types.StructType | ||
|
||
object SparkUtils { | ||
/** | ||
* Setting the schema column positions the same order as in requiredFields | ||
* @param schema Current schema | ||
* @param requiredColumns Column positions expecting by Catalyst | ||
*/ | ||
def alignSchemaWithCatalyst(schema: StructType, requiredColumns: Seq[String]): StructType = { | ||
val fieldsMap = schema.fields.map(f => (f.name, f)).toMap | ||
StructType(requiredColumns.map { c => | ||
fieldsMap(c) | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters