You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@calcite.apache.org by Erin Drummond <er...@gmail.com> on 2019/12/01 20:19:31 UTC

lex parameter does not get taken into account for views

Hello,

I am currently attempting to test out the views feature of Calcite.

I am using a connection string like so:
jdbc:calcite:lex=JAVA;model=inline:<json model>

I have created a JdbcSchema that is attached to an actual database - lets
call it "t1". I can successfully run the query "select * from t1.table
limit 10"

I then created another schema, defined like so:
{
    "name": "viewtest",
    "tables": [
        { "name": "test_view", "type": "view", "sql": "select * from
t1.table limit 10" }
     ]
}

The idea is to set up connections to a bunch of physical data sources and
then have a "views" schema that just contains views over them.

However, when attempting to run the query "select * from
viewtest.test_view", I get the following exception:

StatementCallback; uncategorized SQLException for SQL [select * from
viewtest.test_view]; SQL state [null]; error code [0];
Error while executing SQL \"select * from viewtest.test_view\": From line
1, column 15 to line 1, column 32: Object 'T1' not found; did you mean 't1'?

I can clearly see that lex=JAVA is not being used for the view and the
default lex=ORACLE is being used. If I change the view SQL to 'select *
from "t1".table limit 10' it works - but I don't want to have to quote the
identifiers oracle style, I would like the lex=JAVA that I specified on the
connection string to flow down to views as well.

What am I missing here?

Cheers,
Erin

Re: lex parameter does not get taken into account for views

Posted by Julian Hyde <jh...@apache.org>.
As I remarked in the Jira, we don’t want views to be expanded according to the rules of the current connection. Views belong to the schema, and the schema is shared among many connections, which may have different lex parameters.

> On Dec 1, 2019, at 10:06 PM, XING JIN <ji...@gmail.com> wrote:
> 
> Filed a JIRA: https://issues.apache.org/jira/browse/CALCITE-3549
> 
> Danny Chan <yu...@gmail.com> 于2019年12月2日周一 上午9:06写道:
> 
>> Dear Erin ~
>> 
>> You are right, Calcite now always hard code the parser config for JDBC
>> query[1], that means, Lex config for view expanding is not supported yet,
>> can you log a issue and probably fire a patch to support that?
>> 
>> [1]
>> https://github.com/apache/calcite/blob/ab136b5f76a4cb951e847fcba6b414c5e80dbbe6/core/src/main/java/org/apache/calcite/prepare/CalcitePrepareImpl.java#L385
>> 
>> Best,
>> Danny Chan
>> 在 2019年12月2日 +0800 AM4:19,Erin Drummond <er...@gmail.com>,写道:
>>> Hello,
>>> 
>>> I am currently attempting to test out the views feature of Calcite.
>>> 
>>> I am using a connection string like so:
>>> jdbc:calcite:lex=JAVA;model=inline:<json model>
>>> 
>>> I have created a JdbcSchema that is attached to an actual database - lets
>>> call it "t1". I can successfully run the query "select * from t1.table
>>> limit 10"
>>> 
>>> I then created another schema, defined like so:
>>> {
>>> "name": "viewtest",
>>> "tables": [
>>> { "name": "test_view", "type": "view", "sql": "select * from
>>> t1.table limit 10" }
>>> ]
>>> }
>>> 
>>> The idea is to set up connections to a bunch of physical data sources and
>>> then have a "views" schema that just contains views over them.
>>> 
>>> However, when attempting to run the query "select * from
>>> viewtest.test_view", I get the following exception:
>>> 
>>> StatementCallback; uncategorized SQLException for SQL [select * from
>>> viewtest.test_view]; SQL state [null]; error code [0];
>>> Error while executing SQL \"select * from viewtest.test_view\": From line
>>> 1, column 15 to line 1, column 32: Object 'T1' not found; did you mean
>> 't1'?
>>> 
>>> I can clearly see that lex=JAVA is not being used for the view and the
>>> default lex=ORACLE is being used. If I change the view SQL to 'select *
>>> from "t1".table limit 10' it works - but I don't want to have to quote
>> the
>>> identifiers oracle style, I would like the lex=JAVA that I specified on
>> the
>>> connection string to flow down to views as well.
>>> 
>>> What am I missing here?
>>> 
>>> Cheers,
>>> Erin
>> 


Re: lex parameter does not get taken into account for views

Posted by XING JIN <ji...@gmail.com>.
Filed a JIRA: https://issues.apache.org/jira/browse/CALCITE-3549

Danny Chan <yu...@gmail.com> 于2019年12月2日周一 上午9:06写道:

> Dear Erin ~
>
> You are right, Calcite now always hard code the parser config for JDBC
> query[1], that means, Lex config for view expanding is not supported yet,
> can you log a issue and probably fire a patch to support that?
>
> [1]
> https://github.com/apache/calcite/blob/ab136b5f76a4cb951e847fcba6b414c5e80dbbe6/core/src/main/java/org/apache/calcite/prepare/CalcitePrepareImpl.java#L385
>
> Best,
> Danny Chan
> 在 2019年12月2日 +0800 AM4:19,Erin Drummond <er...@gmail.com>,写道:
> > Hello,
> >
> > I am currently attempting to test out the views feature of Calcite.
> >
> > I am using a connection string like so:
> > jdbc:calcite:lex=JAVA;model=inline:<json model>
> >
> > I have created a JdbcSchema that is attached to an actual database - lets
> > call it "t1". I can successfully run the query "select * from t1.table
> > limit 10"
> >
> > I then created another schema, defined like so:
> > {
> > "name": "viewtest",
> > "tables": [
> > { "name": "test_view", "type": "view", "sql": "select * from
> > t1.table limit 10" }
> > ]
> > }
> >
> > The idea is to set up connections to a bunch of physical data sources and
> > then have a "views" schema that just contains views over them.
> >
> > However, when attempting to run the query "select * from
> > viewtest.test_view", I get the following exception:
> >
> > StatementCallback; uncategorized SQLException for SQL [select * from
> > viewtest.test_view]; SQL state [null]; error code [0];
> > Error while executing SQL \"select * from viewtest.test_view\": From line
> > 1, column 15 to line 1, column 32: Object 'T1' not found; did you mean
> 't1'?
> >
> > I can clearly see that lex=JAVA is not being used for the view and the
> > default lex=ORACLE is being used. If I change the view SQL to 'select *
> > from "t1".table limit 10' it works - but I don't want to have to quote
> the
> > identifiers oracle style, I would like the lex=JAVA that I specified on
> the
> > connection string to flow down to views as well.
> >
> > What am I missing here?
> >
> > Cheers,
> > Erin
>

Re: lex parameter does not get taken into account for views

Posted by Danny Chan <yu...@gmail.com>.
Dear Erin ~

You are right, Calcite now always hard code the parser config for JDBC query[1], that means, Lex config for view expanding is not supported yet, can you log a issue and probably fire a patch to support that?

[1] https://github.com/apache/calcite/blob/ab136b5f76a4cb951e847fcba6b414c5e80dbbe6/core/src/main/java/org/apache/calcite/prepare/CalcitePrepareImpl.java#L385

Best,
Danny Chan
在 2019年12月2日 +0800 AM4:19,Erin Drummond <er...@gmail.com>,写道:
> Hello,
>
> I am currently attempting to test out the views feature of Calcite.
>
> I am using a connection string like so:
> jdbc:calcite:lex=JAVA;model=inline:<json model>
>
> I have created a JdbcSchema that is attached to an actual database - lets
> call it "t1". I can successfully run the query "select * from t1.table
> limit 10"
>
> I then created another schema, defined like so:
> {
> "name": "viewtest",
> "tables": [
> { "name": "test_view", "type": "view", "sql": "select * from
> t1.table limit 10" }
> ]
> }
>
> The idea is to set up connections to a bunch of physical data sources and
> then have a "views" schema that just contains views over them.
>
> However, when attempting to run the query "select * from
> viewtest.test_view", I get the following exception:
>
> StatementCallback; uncategorized SQLException for SQL [select * from
> viewtest.test_view]; SQL state [null]; error code [0];
> Error while executing SQL \"select * from viewtest.test_view\": From line
> 1, column 15 to line 1, column 32: Object 'T1' not found; did you mean 't1'?
>
> I can clearly see that lex=JAVA is not being used for the view and the
> default lex=ORACLE is being used. If I change the view SQL to 'select *
> from "t1".table limit 10' it works - but I don't want to have to quote the
> identifiers oracle style, I would like the lex=JAVA that I specified on the
> connection string to flow down to views as well.
>
> What am I missing here?
>
> Cheers,
> Erin