You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@spark.apache.org by yael aharon <ya...@gmail.com> on 2016/08/18 13:14:09 UTC
Reporting errors from spark sql
Hello,
I am working on an SQL editor which is powered by spark SQL. When the SQL
is not valid, I would like to provide the user with a line number and
column number where the first error occurred. I am having a hard time
finding a mechanism that will give me that information programmatically.
Most of the time, if an erroneous SQL statement is used, I am getting a
RuntimeException, where line number and column number are implicitly
embedded within the text of the message, but it is really error prone to
parse the message text and count the number of spaces prior to the '^'
symbol...
Sometimes, AnalysisException is used, but when I try to extract the line
and startPosition from it, they are always empty.
Any help would be greatly appreciated.
thanks!
Re: Reporting errors from spark sql
Posted by Jacek Laskowski <ja...@japila.pl>.
Hi,
See https://github.com/apache/spark/blob/master/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/parser/ParseDriver.scala#L65
to learn how Spark SQL parses SQL texts. It could give you a way out.
Pozdrawiam,
Jacek Laskowski
----
https://medium.com/@jaceklaskowski/
Mastering Apache Spark 2.0 http://bit.ly/mastering-apache-spark
Follow me at https://twitter.com/jaceklaskowski
On Thu, Aug 18, 2016 at 3:14 PM, yael aharon <ya...@gmail.com> wrote:
> Hello,
> I am working on an SQL editor which is powered by spark SQL. When the SQL is
> not valid, I would like to provide the user with a line number and column
> number where the first error occurred. I am having a hard time finding a
> mechanism that will give me that information programmatically.
>
> Most of the time, if an erroneous SQL statement is used, I am getting a
> RuntimeException, where line number and column number are implicitly
> embedded within the text of the message, but it is really error prone to
> parse the message text and count the number of spaces prior to the '^'
> symbol...
>
> Sometimes, AnalysisException is used, but when I try to extract the line and
> startPosition from it, they are always empty.
>
> Any help would be greatly appreciated.
> thanks!
---------------------------------------------------------------------
To unsubscribe e-mail: user-unsubscribe@spark.apache.org