Re: Is there a way to validate the syntax of raw spark sql query?

2019-03-05 Thread kant kodali
Hi Akshay, Thanks for this. I will give it a try. The Java API for .explain returns void. It doesn't throw any checked exception. so I guess I have to catch the generic RuntimeException and walk through the stacktrace to see if there is any ParseException. In short, the code just gets really

Re: Is there a way to validate the syntax of raw spark sql query?

2019-03-05 Thread Akshay Bhardwaj
Hi Kant, You can try "explaining" the sql query. spark.sql(sqlText).explain(true); //the parameter true is to get more verbose query plan and it is optional. This is the safest way to validate sql without actually executing/creating a df/view in spark. It validates syntax as well as schema of

Is there a way to validate the syntax of raw spark sql query?

2019-03-01 Thread kant kodali
Hi All, Is there a way to validate the syntax of raw spark SQL query? for example, I would like to know if there is any isValid API call spark provides? val query = "select * from table"if(isValid(query)) { sparkSession.sql(query) } else { log.error("Invalid Syntax")} I tried the