Create scala filter conditions based on JSON in API gateway -
i getting json filter conditions spark sql. json of format:
{ "x": { "lt": "2" } } which should become like: spark.sql("select * df x < 2")
any idea how can proceed? data read parquet file using
spark.read.parquet(filepath) so code follows:
val df = spark.read.parquet(filepath) implicit val formats = org.json4s.defaultformats parse(filterjson).extract[map[string, any]] // once tables have been registered, can run sql queries on them. for((k,v)<-map){ v match { case "eq"=>"===" case "gt"=>">" case "lt"=>"<" } } df.filter(k) any appreciated.
Comments
Post a Comment