Hydrospheredata / mist

Serverless proxy for Spark cluster
http://hydrosphere.io/mist/
Apache License 2.0
326 stars 68 forks source link

Default values in case class not used when used in `withArgs` #473

Closed gowravshekar closed 6 years ago

gowravshekar commented 6 years ago
case class Request(filePath: String,
                   attributes: CsvAttributes,
                   method: String = "pearson",
                   columns: Seq[String] = Nil,
                   precision: Option[Int] = None)

def handle: Handle[Response] = withArgs(arg[Request]("request"))
.withMistExtras.onSparkSession((request: Request, 
extras: MistExtras, sparkSession:SparkSession) => {
...
}

Error when submitting the request without method or columns.

Bad request: field method:[value is null] Bad request: field columns:[value is null]

Missing precision works fine.

dos65 commented 6 years ago

I didn't know that possible to obtain default values using shapeless. It seems that we can implement that feature (shapeless defaults)

dos65 commented 6 years ago

Done. You could use mist.api.encoding.generic.extractorWithDefaults - docs