You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@calcite.apache.org by Jariv Narup <ja...@gmail.com> on 2021/08/16 20:57:59 UTC

Runtime Exception while using SqlParse.

Hi Team,
   I am getting the following exception while trying to parse a SQL
statement into its tokens. Is this expected behavior? If not, what would
you suggest to work around this problem. The particulars are given below:

*Issue:*
*Method threw 'java.lang.RuntimeException' exception. Cannot evaluate
org.apache.calcite.sql.SqlJoin.toString().*

*Where:*
This happens when I use the following API (it is visible on the "from"
value):

        SqlParser.Config parserConfig = SqlParser.config();
        parserConfig
                .withCaseSensitive(false)
                .withLex(Lex.ORACLE);
        SqlParser parser = SqlParser.create(sqlString, parserConfig);
>>> [Line with the issue]        *SqlNode sqlNode = parser.parseStmt();*


*Debugger Image:*
[image: image.png]
*Version In Use:*
I am using the following maven GAVs
-org.apache.calcite:calcite-babel:1.27.0, so my assumption is that I am at
the latest.

*SQL Statement with the issue:*

*SELECT Purchase.Purchase_Date, Products.Product_Name FROM Purchase JOIN
Products ON Purchase.Product_ID = Purchase.ID WHERE Purchase.Quantity > 10*

I would appreciate any help on this.

Thanks - Jariv

Re: Runtime Exception while using SqlParse.

Posted by Yanjing Wang <zh...@gmail.com>.
Further, you may try sqlNode.toSqlString().getSql().

Julian Hyde <jh...@gmail.com> 于2021年8月19日周四 上午5:48写道:

> Yes, the error message is not good enough. Can you please log a bug? The
> error comes from org.apache.calcite.linq4j.tree.BinaryExpression, which I
> very much doubt happens at parse time. If you can add a test case, or a
> complete error stack, that would be appreciated.
>
> > On Aug 18, 2021, at 9:30 PM, Jariv Narup <ja...@gmail.com>
> wrote:
> >
> > Hi Thomas,
> >   That is my bad - a carry over from the debugging. However the error
> > still persists even with the following query:
> >
> > *SELECT Purchase.Purchase_Date, Products.Product_Name FROM Purchase JOIN
> > Products ON Purchase.Product_ID = Products.ID WHERE Purchase.Quantity >
> 10*
> >
> > This is what I see:
> >
> > *from: org.apache.calcite.sql.SqlNode  =
> > {org.apache.calcite.sql.SqlJoin@2039} Method threw
> > 'java.lang.RuntimeException' exception. Cannot evaluate
> > org.apache.calcite.sql.SqlJoin.toString()* left:
> > org.apache.calcite.sql.SqlNode  =
> {org.apache.calcite.sql.SqlIdentifier@2141}
> > "PURCHASE"
> > natural: org.apache.calcite.sql.SqlLiteral  =
> > {org.apache.calcite.sql.SqlLiteral@2142} "FALSE"
> > joinType: org.apache.calcite.sql.SqlLiteral  =
> > {org.apache.calcite.sql.SqlLiteral@2143} "INNER"
> > right: org.apache.calcite.sql.SqlNode  =
> > {org.apache.calcite.sql.SqlIdentifier@2144} "PRODUCTS"
> > conditionType: org.apache.calcite.sql.SqlLiteral  =
> > {org.apache.calcite.sql.SqlLiteral@2145} "ON"
> > condition: org.apache.calcite.sql.SqlNode  =
> > {org.apache.calcite.sql.SqlBasicCall@2146} "`PURCHASE`.`PRODUCT_ID` =
> > `PRODUCTS`.`ID`"
> > pos: org.apache.calcite.sql.parser.SqlParserPos  =
> > {org.apache.calcite.sql.parser.SqlParserPos@2147} "line 1, column 68"
> >
> > That said, a more directed error text might definitely be more helpful.
> >
> > Regards,
> > Viraj Purang
> >
> > On Tue, Aug 17, 2021 at 1:27 AM Thomas Rebele <tr...@tibco.com> wrote:
> >
> >> Hi Jariv,
> >>
> >> are you sure you want to join two columns of Purchase:
> *Purchase.Product_ID
> >> = Purchase.ID*?
> >> If that's the cause of the exception, the error message could be
> improved.
> >>
> >> Cordialement / Best Regards,
> >> *Thomas Rebele, PhD* | R&D Developer | Germany | www.tibco.com
> >>
> >>
> >> On Mon, Aug 16, 2021 at 10:58 PM Jariv Narup <ja...@gmail.com>
> >> wrote:
> >>
> >>> Hi Team,
> >>>   I am getting the following exception while trying to parse a SQL
> >>> statement into its tokens. Is this expected behavior? If not, what
> would
> >>> you suggest to work around this problem. The particulars are given
> below:
> >>>
> >>> *Issue:*
> >>> *Method threw 'java.lang.RuntimeException' exception. Cannot evaluate
> >>> org.apache.calcite.sql.SqlJoin.toString().*
> >>>
> >>> *Where:*
> >>> This happens when I use the following API (it is visible on the "from"
> >>> value):
> >>>
> >>>        SqlParser.Config parserConfig = SqlParser.config();
> >>>        parserConfig
> >>>                .withCaseSensitive(false)
> >>>                .withLex(Lex.ORACLE);
> >>>        SqlParser parser = SqlParser.create(sqlString, parserConfig);
> >>>>>> [Line with the issue]        *SqlNode sqlNode = parser.parseStmt();*
> >>>
> >>>
> >>> *Debugger Image:*
> >>> [image: image.png]
> >>> *Version In Use:*
> >>> I am using the following maven GAVs
> >>> -org.apache.calcite:calcite-babel:1.27.0, so my assumption is that I
> am at
> >>> the latest.
> >>>
> >>> *SQL Statement with the issue:*
> >>>
> >>> *SELECT Purchase.Purchase_Date, Products.Product_Name FROM Purchase
> JOIN
> >>> Products ON Purchase.Product_ID = Purchase.ID WHERE Purchase.Quantity
> > 10*
> >>>
> >>> I would appreciate any help on this.
> >>>
> >>> Thanks - Jariv
> >>>
> >>
>
>

Re: Runtime Exception while using SqlParse.

Posted by Julian Hyde <jh...@gmail.com>.
Yes, the error message is not good enough. Can you please log a bug? The error comes from org.apache.calcite.linq4j.tree.BinaryExpression, which I very much doubt happens at parse time. If you can add a test case, or a complete error stack, that would be appreciated. 

> On Aug 18, 2021, at 9:30 PM, Jariv Narup <ja...@gmail.com> wrote:
> 
> Hi Thomas,
>   That is my bad - a carry over from the debugging. However the error
> still persists even with the following query:
> 
> *SELECT Purchase.Purchase_Date, Products.Product_Name FROM Purchase JOIN
> Products ON Purchase.Product_ID = Products.ID WHERE Purchase.Quantity > 10*
> 
> This is what I see:
> 
> *from: org.apache.calcite.sql.SqlNode  =
> {org.apache.calcite.sql.SqlJoin@2039} Method threw
> 'java.lang.RuntimeException' exception. Cannot evaluate
> org.apache.calcite.sql.SqlJoin.toString()* left:
> org.apache.calcite.sql.SqlNode  = {org.apache.calcite.sql.SqlIdentifier@2141}
> "PURCHASE"
> natural: org.apache.calcite.sql.SqlLiteral  =
> {org.apache.calcite.sql.SqlLiteral@2142} "FALSE"
> joinType: org.apache.calcite.sql.SqlLiteral  =
> {org.apache.calcite.sql.SqlLiteral@2143} "INNER"
> right: org.apache.calcite.sql.SqlNode  =
> {org.apache.calcite.sql.SqlIdentifier@2144} "PRODUCTS"
> conditionType: org.apache.calcite.sql.SqlLiteral  =
> {org.apache.calcite.sql.SqlLiteral@2145} "ON"
> condition: org.apache.calcite.sql.SqlNode  =
> {org.apache.calcite.sql.SqlBasicCall@2146} "`PURCHASE`.`PRODUCT_ID` =
> `PRODUCTS`.`ID`"
> pos: org.apache.calcite.sql.parser.SqlParserPos  =
> {org.apache.calcite.sql.parser.SqlParserPos@2147} "line 1, column 68"
> 
> That said, a more directed error text might definitely be more helpful.
> 
> Regards,
> Viraj Purang
> 
> On Tue, Aug 17, 2021 at 1:27 AM Thomas Rebele <tr...@tibco.com> wrote:
> 
>> Hi Jariv,
>> 
>> are you sure you want to join two columns of Purchase: *Purchase.Product_ID
>> = Purchase.ID*?
>> If that's the cause of the exception, the error message could be improved.
>> 
>> Cordialement / Best Regards,
>> *Thomas Rebele, PhD* | R&D Developer | Germany | www.tibco.com
>> 
>> 
>> On Mon, Aug 16, 2021 at 10:58 PM Jariv Narup <ja...@gmail.com>
>> wrote:
>> 
>>> Hi Team,
>>>   I am getting the following exception while trying to parse a SQL
>>> statement into its tokens. Is this expected behavior? If not, what would
>>> you suggest to work around this problem. The particulars are given below:
>>> 
>>> *Issue:*
>>> *Method threw 'java.lang.RuntimeException' exception. Cannot evaluate
>>> org.apache.calcite.sql.SqlJoin.toString().*
>>> 
>>> *Where:*
>>> This happens when I use the following API (it is visible on the "from"
>>> value):
>>> 
>>>        SqlParser.Config parserConfig = SqlParser.config();
>>>        parserConfig
>>>                .withCaseSensitive(false)
>>>                .withLex(Lex.ORACLE);
>>>        SqlParser parser = SqlParser.create(sqlString, parserConfig);
>>>>>> [Line with the issue]        *SqlNode sqlNode = parser.parseStmt();*
>>> 
>>> 
>>> *Debugger Image:*
>>> [image: image.png]
>>> *Version In Use:*
>>> I am using the following maven GAVs
>>> -org.apache.calcite:calcite-babel:1.27.0, so my assumption is that I am at
>>> the latest.
>>> 
>>> *SQL Statement with the issue:*
>>> 
>>> *SELECT Purchase.Purchase_Date, Products.Product_Name FROM Purchase JOIN
>>> Products ON Purchase.Product_ID = Purchase.ID WHERE Purchase.Quantity > 10*
>>> 
>>> I would appreciate any help on this.
>>> 
>>> Thanks - Jariv
>>> 
>> 


Re: Runtime Exception while using SqlParse.

Posted by Jariv Narup <ja...@gmail.com>.
Hi Thomas,
   That is my bad - a carry over from the debugging. However the error
still persists even with the following query:

*SELECT Purchase.Purchase_Date, Products.Product_Name FROM Purchase JOIN
Products ON Purchase.Product_ID = Products.ID WHERE Purchase.Quantity > 10*

This is what I see:

*from: org.apache.calcite.sql.SqlNode  =
{org.apache.calcite.sql.SqlJoin@2039} Method threw
'java.lang.RuntimeException' exception. Cannot evaluate
org.apache.calcite.sql.SqlJoin.toString()* left:
org.apache.calcite.sql.SqlNode  = {org.apache.calcite.sql.SqlIdentifier@2141}
"PURCHASE"
 natural: org.apache.calcite.sql.SqlLiteral  =
{org.apache.calcite.sql.SqlLiteral@2142} "FALSE"
 joinType: org.apache.calcite.sql.SqlLiteral  =
{org.apache.calcite.sql.SqlLiteral@2143} "INNER"
 right: org.apache.calcite.sql.SqlNode  =
{org.apache.calcite.sql.SqlIdentifier@2144} "PRODUCTS"
 conditionType: org.apache.calcite.sql.SqlLiteral  =
{org.apache.calcite.sql.SqlLiteral@2145} "ON"
 condition: org.apache.calcite.sql.SqlNode  =
{org.apache.calcite.sql.SqlBasicCall@2146} "`PURCHASE`.`PRODUCT_ID` =
`PRODUCTS`.`ID`"
 pos: org.apache.calcite.sql.parser.SqlParserPos  =
{org.apache.calcite.sql.parser.SqlParserPos@2147} "line 1, column 68"

That said, a more directed error text might definitely be more helpful.

Regards,
Viraj Purang

On Tue, Aug 17, 2021 at 1:27 AM Thomas Rebele <tr...@tibco.com> wrote:

> Hi Jariv,
>
> are you sure you want to join two columns of Purchase: *Purchase.Product_ID
> = Purchase.ID*?
> If that's the cause of the exception, the error message could be improved.
>
> Cordialement / Best Regards,
> *Thomas Rebele, PhD* | R&D Developer | Germany | www.tibco.com
>
>
> On Mon, Aug 16, 2021 at 10:58 PM Jariv Narup <ja...@gmail.com>
> wrote:
>
>> Hi Team,
>>    I am getting the following exception while trying to parse a SQL
>> statement into its tokens. Is this expected behavior? If not, what would
>> you suggest to work around this problem. The particulars are given below:
>>
>> *Issue:*
>> *Method threw 'java.lang.RuntimeException' exception. Cannot evaluate
>> org.apache.calcite.sql.SqlJoin.toString().*
>>
>> *Where:*
>> This happens when I use the following API (it is visible on the "from"
>> value):
>>
>>         SqlParser.Config parserConfig = SqlParser.config();
>>         parserConfig
>>                 .withCaseSensitive(false)
>>                 .withLex(Lex.ORACLE);
>>         SqlParser parser = SqlParser.create(sqlString, parserConfig);
>> >>> [Line with the issue]        *SqlNode sqlNode = parser.parseStmt();*
>>
>>
>> *Debugger Image:*
>> [image: image.png]
>> *Version In Use:*
>> I am using the following maven GAVs
>> -org.apache.calcite:calcite-babel:1.27.0, so my assumption is that I am at
>> the latest.
>>
>> *SQL Statement with the issue:*
>>
>> *SELECT Purchase.Purchase_Date, Products.Product_Name FROM Purchase JOIN
>> Products ON Purchase.Product_ID = Purchase.ID WHERE Purchase.Quantity > 10*
>>
>> I would appreciate any help on this.
>>
>> Thanks - Jariv
>>
>

Re: Runtime Exception while using SqlParse.

Posted by Thomas Rebele <tr...@tibco.com.INVALID>.
Hi Jariv,

are you sure you want to join two columns of Purchase: *Purchase.Product_ID
= Purchase.ID*?
If that's the cause of the exception, the error message could be improved.

Cordialement / Best Regards,
*Thomas Rebele, PhD* | R&D Developer | Germany | www.tibco.com


On Mon, Aug 16, 2021 at 10:58 PM Jariv Narup <ja...@gmail.com>
wrote:

> Hi Team,
>    I am getting the following exception while trying to parse a SQL
> statement into its tokens. Is this expected behavior? If not, what would
> you suggest to work around this problem. The particulars are given below:
>
> *Issue:*
> *Method threw 'java.lang.RuntimeException' exception. Cannot evaluate
> org.apache.calcite.sql.SqlJoin.toString().*
>
> *Where:*
> This happens when I use the following API (it is visible on the "from"
> value):
>
>         SqlParser.Config parserConfig = SqlParser.config();
>         parserConfig
>                 .withCaseSensitive(false)
>                 .withLex(Lex.ORACLE);
>         SqlParser parser = SqlParser.create(sqlString, parserConfig);
> >>> [Line with the issue]        *SqlNode sqlNode = parser.parseStmt();*
>
>
> *Debugger Image:*
> [image: image.png]
> *Version In Use:*
> I am using the following maven GAVs
> -org.apache.calcite:calcite-babel:1.27.0, so my assumption is that I am at
> the latest.
>
> *SQL Statement with the issue:*
>
> *SELECT Purchase.Purchase_Date, Products.Product_Name FROM Purchase JOIN
> Products ON Purchase.Product_ID = Purchase.ID WHERE Purchase.Quantity > 10*
>
> I would appreciate any help on this.
>
> Thanks - Jariv
>