This file contains hidden or 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
// Problem: creating a Spark UDF that take extra parameter at invocation time. | |
// Solution: using currying | |
// http://stackoverflow.com/questions/35546576/how-can-i-pass-extra-parameters-to-udfs-in-sparksql | |
// We want to create hideTabooValues, a Spark UDF that set to -1 fields that contains any of given taboo values. | |
// E.g. forbiddenValues = [1, 2, 3] | |
// dataframe = [1, 2, 3, 4, 5, 6] | |
// dataframe.select(hideTabooValues(forbiddenValues)) :> [-1, -1, -1, 4, 5, 6] | |
// | |
// Implementing this in Spark, we find two major issues: |
This file contains hidden or 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
package services | |
import java.lang.reflect.Type | |
import com.google.gson._ | |
import org.joda.time.format.ISODateTimeFormat | |
import org.joda.time.{DateTime, DateTimeZone} | |
object Serializers { |