calcite-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Enrico Olivelli <eolive...@gmail.com>
Subject Re: Parser error on trivial JDBC update
Date Fri, 17 Nov 2017 07:59:48 GMT
OK
I would like to pick up this issue and provide a fix.

This is the test, working
@Test public void testUpdateBind() {
    final String sql = "update emp"
        + " set sal = sal + ? where slacker = false";
    sql(sql).ok();
  }

This is a new, simpler test, which is not working, same error as expected
  @Test public void testUpdateBind2() {
    final String sql = "update emp"
        + " set sal = ? where slacker = false";
    sql(sql).ok();
  }

Below this test there is a test marked as @Ignore due to CALCITE-1708,
which is the same problem, but the test case was more complex.

Can you give me some hint ?
I am still a newbie in Calcite.
How is it supposed to be bound the type for a dynamic parameter?
In this case I think we could derive the type from the column which is
going to be updated/filtered.
Another approach would be to drop the assertion in this special case. I
don't think it is bad to have a unknown type in this case, but maybe I am
missing something.


2017-11-15 14:06 GMT+01:00 Enrico Olivelli <eolivelli@gmail.com>:

> here it is
> https://issues.apache.org/jira/browse/CALCITE-2054
>
> 2017-11-15 14:02 GMT+01:00 Enrico Olivelli <eolivelli@gmail.com>:
>
>> I will do,
>> It crashes even if I switch to ProjectableFilterableTable I fall into
>> this,
>>
>> For updates without parameters and using ProjectableFilterableTable I
>> fall into this
>> https://issues.apache.org/jira/browse/CALCITE-2039
>> I have attached a reproducer.
>>
>> The same is for this email, I will create a JIRA now
>>
>> Can you please take into account of addressing the two for 1.15 ? They
>> are realy blocker.
>> At least CALCITE-2039
>> In fact I went away from ProjectableFilterableTable because of
>> CALCITE-2039
>>
>> I will do my best to support triage and testing,
>> Thanks
>> I hope to be able to leverage Calcite power soon
>>
>> Enrico
>>
>> 2017-11-14 23:55 GMT+01:00 Julian Hyde <jhyde@apache.org>:
>>
>>> I see we have SqlValidatorTest.testUpdateBind(), which seems very
>>> similar to your query, and it succeeds validation. But I don’t recall us
>>> testing dynamic parameters in the SET clause end-to-end, and your query is
>>> failing in sql-to-rel translation, just after validation. Can you log a
>>> JIRA case please?
>>>
>>> Julian
>>>
>>>
>>> > On Nov 14, 2017, at 12:45 PM, Enrico Olivelli <eolivelli@gmail.com>
>>> wrote:
>>> >
>>> > Hi,
>>> > with a simple UPDATE like:
>>> > UPDATE mytable set a=? where b=?
>>> >
>>> > I get the error below.
>>> > The "Table" is a ModifiableTable + ScannableTable, with "a" of type
>>> INTEGER
>>> > and "b" of type VARCHAR
>>> >
>>> > Any hint ?
>>> > Thank you
>>> > Enrico
>>> >
>>> >
>>> > org.apache.calcite.runtime.CalciteContextException: At line 1, column
>>> 30:
>>> > Illegal use of dynamic parameter
>>> >    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
>>> Method)
>>> >    at
>>> > sun.reflect.NativeConstructorAccessorImpl.newInstance(Native
>>> ConstructorAccessorImpl.java:62)
>>> >    at
>>> > sun.reflect.DelegatingConstructorAccessorImpl.newInstance(De
>>> legatingConstructorAccessorImpl.java:45)
>>> >    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
>>> >    at
>>> > org.apache.calcite.runtime.Resources$ExInstWithCause.ex(Reso
>>> urces.java:463)
>>> >    at org.apache.calcite.sql.SqlUtil.newContextException(SqlUtil.j
>>> ava:803)
>>> >    at org.apache.calcite.sql.SqlUtil.newContextException(SqlUtil.j
>>> ava:788)
>>> >    at
>>> > org.apache.calcite.sql.validate.SqlValidatorImpl.newValidati
>>> onError(SqlValidatorImpl.java:4651)
>>> >    at
>>> > org.apache.calcite.sql.validate.SqlValidatorImpl.inferUnknow
>>> nTypes(SqlValidatorImpl.java:1694)
>>> >    at
>>> > org.apache.calcite.sql.validate.SqlValidatorImpl.inferUnknow
>>> nTypes(SqlValidatorImpl.java:1769)
>>> >    at
>>> > org.apache.calcite.sql.validate.SqlValidatorImpl.expandSelec
>>> tItem(SqlValidatorImpl.java:457)
>>> >    at
>>> > org.apache.calcite.sql.validate.SqlValidatorImpl.expandStar(
>>> SqlValidatorImpl.java:347)
>>> >    at
>>> > org.apache.calcite.sql2rel.SqlToRelConverter.convertSelectLi
>>> st(SqlToRelConverter.java:3709)
>>> >    at
>>> > org.apache.calcite.sql2rel.SqlToRelConverter.convertSelectIm
>>> pl(SqlToRelConverter.java:663)
>>> >    at
>>> > org.apache.calcite.sql2rel.SqlToRelConverter.convertSelect(S
>>> qlToRelConverter.java:620)
>>> >    at
>>> > org.apache.calcite.sql2rel.SqlToRelConverter.convertUpdate(S
>>> qlToRelConverter.java:3398)
>>> >    at
>>> > org.apache.calcite.sql2rel.SqlToRelConverter.convertQueryRec
>>> ursive(SqlToRelConverter.java:3048)
>>> >    at
>>> > org.apache.calcite.sql2rel.SqlToRelConverter.convertQuery(Sq
>>> lToRelConverter.java:556)
>>> >    at org.apache.calcite.prepare.PlannerImpl.rel(PlannerImpl.java:240)
>>>
>>>
>>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message