"select as" in Flink SQL

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

"select as" in Flink SQL

Davran Muzafarov

I am try to execute simple sql like this:

 

DataSet<MarketDataInfo> dataSet0 = env.fromCollection( infos0 );

tableEnv.registerDataSet( "table0", dataSet0 );

 

 

Table table = tableEnv.sql( "select assetClass as \”asset class\” from tabel0" );

 

I am getting:

 

org.apache.calcite.sql.parser.SqlParseException: Encountered "as \"" at line 1, column 19.

Was expecting one of:

    "FROM" ...

    "," ...

    "AS" <IDENTIFIER> ...

    "AS" <QUOTED_IDENTIFIER> ...

    "AS" <BACK_QUOTED_IDENTIFIER> ...

    "AS" <BRACKET_QUOTED_IDENTIFIER> ...

    "AS" <UNICODE_QUOTED_IDENTIFIER> ...

    "." ...

    "(" ...

    "NOT" ...

    "IN" ...

    "BETWEEN" ...

    "LIKE" ...

    "SIMILAR" ...

    "=" ...

    ">" ...

    "<" ...

    "<=" ...

    ">=" ...

    "<>" ...

    "+" ...

    "-" ...

    "*" ...

    "/" ...

    "||" ...

    "AND" ...

    "OR" ...

    "IS" ...

    "MEMBER" ...

    "SUBMULTISET" ...

    "MULTISET" ...

    "[" ...

   

        at org.apache.calcite.sql.parser.impl.SqlParserImpl.convertException(SqlParserImpl.java:388)

        at org.apache.calcite.sql.parser.impl.SqlParserImpl.normalizeException(SqlParserImpl.java:119)

        at org.apache.calcite.sql.parser.SqlParser.parseQuery(SqlParser.java:131)

        at org.apache.calcite.sql.parser.SqlParser.parseStmt(SqlParser.java:156)

        at org.apache.flink.api.table.FlinkPlannerImpl.parse(FlinkPlannerImpl.scala:75)

        …

 

If I use [ insteand of “, I am getting:

org.apache.calcite.sql.parser.SqlParseException: Encountered "as [" at line 1, column 19.
Was expecting one of:
    "FROM" ...
    "," ...
    "AS" <IDENTIFIER> ...
    "AS" <QUOTED_IDENTIFIER> ...
    "AS" <BACK_QUOTED_IDENTIFIER> ...
    "AS" <BRACKET_QUOTED_IDENTIFIER> ...
    "AS" <UNICODE_QUOTED_IDENTIFIER> ...
    "." ...
    "(" ...
    "NOT" ...
    "IN" ...
    "BETWEEN" ...
    "LIKE" ...
    "SIMILAR" ...
    "=" ...
    ">" ...
    "<" ...
    "<=" ...
    ">=" ...
    "<>" ...
    "+" ...
    "-" ...
    "*" ...
    "/" ...
    "||" ...
    "AND" ...
    "OR" ...
    "IS" ...
    "MEMBER" ...
    "SUBMULTISET" ...
    "MULTISET" ...
    "[" ...
    
        at org.apache.calcite.sql.parser.impl.SqlParserImpl.convertException(SqlParserImpl.java:388)
        at org.apache.calcite.sql.parser.impl.SqlParserImpl.normalizeException(SqlParserImpl.java:119)
        at org.apache.calcite.sql.parser.SqlParser.parseQuery(SqlParser.java:131)
        at org.apache.calcite.sql.parser.SqlParser.parseStmt(SqlParser.java:156)
        at org.apache.flink.api.table.FlinkPlannerImpl.parse(FlinkPlannerImpl.scala:75)
        at org.apache.flink.api.table.BatchTableEnvironment.sql(BatchTableEnvironment.scala:128)

        …

 

How would I use aliases which contain space(s)?

 

Thank you,

Davran.

 

 

 

 

 

 

 

 

 

Reply | Threaded
Open this post in threaded view
|

Re: "select as" in Flink SQL

Timo Walther
Hi Davran,

Flink SQL uses a lexical policy similar to Java:
The case of identifiers is preserved whether or not they are quoted; after which, identifiers are matched case-sensitively. Unlike Java, back-ticks allow identifiers to contain non-alphanumeric characters.

So "select assetClass as `asset class` from tabel0" should do the trick.

I will improve the documentation about this.

Regards,
Timo

Am 30/08/16 um 21:49 schrieb Davran Muzafarov:

I am try to execute simple sql like this:

 

DataSet<MarketDataInfo> dataSet0 = env.fromCollection( infos0 );

tableEnv.registerDataSet( "table0", dataSet0 );

 

 

Table table = tableEnv.sql( "select assetClass as \”asset class\” from tabel0" );

 

I am getting:

 

org.apache.calcite.sql.parser.SqlParseException: Encountered "as \"" at line 1, column 19.

Was expecting one of:

    "FROM" ...

    "," ...

    "AS" <IDENTIFIER> ...

    "AS" <QUOTED_IDENTIFIER> ...

    "AS" <BACK_QUOTED_IDENTIFIER> ...

    "AS" <BRACKET_QUOTED_IDENTIFIER> ...

    "AS" <UNICODE_QUOTED_IDENTIFIER> ...

    "." ...

    "(" ...

    "NOT" ...

    "IN" ...

    "BETWEEN" ...

    "LIKE" ...

    "SIMILAR" ...

    "=" ...

    ">" ...

    "<" ...

    "<=" ...

    ">=" ...

    "<>" ...

    "+" ...

    "-" ...

    "*" ...

    "/" ...

    "||" ...

    "AND" ...

    "OR" ...

    "IS" ...

    "MEMBER" ...

    "SUBMULTISET" ...

    "MULTISET" ...

    "[" ...

   

        at org.apache.calcite.sql.parser.impl.SqlParserImpl.convertException(SqlParserImpl.java:388)

        at org.apache.calcite.sql.parser.impl.SqlParserImpl.normalizeException(SqlParserImpl.java:119)

        at org.apache.calcite.sql.parser.SqlParser.parseQuery(SqlParser.java:131)

        at org.apache.calcite.sql.parser.SqlParser.parseStmt(SqlParser.java:156)

        at org.apache.flink.api.table.FlinkPlannerImpl.parse(FlinkPlannerImpl.scala:75)

        …

 

If I use [ insteand of “, I am getting:

org.apache.calcite.sql.parser.SqlParseException: Encountered "as [" at line 1, column 19.
Was expecting one of:
    "FROM" ...
    "," ...
    "AS" <IDENTIFIER> ...
    "AS" <QUOTED_IDENTIFIER> ...
    "AS" <BACK_QUOTED_IDENTIFIER> ...
    "AS" <BRACKET_QUOTED_IDENTIFIER> ...
    "AS" <UNICODE_QUOTED_IDENTIFIER> ...
    "." ...
    "(" ...
    "NOT" ...
    "IN" ...
    "BETWEEN" ...
    "LIKE" ...
    "SIMILAR" ...
    "=" ...
    ">" ...
    "<" ...
    "<=" ...
    ">=" ...
    "<>" ...
    "+" ...
    "-" ...
    "*" ...
    "/" ...
    "||" ...
    "AND" ...
    "OR" ...
    "IS" ...
    "MEMBER" ...
    "SUBMULTISET" ...
    "MULTISET" ...
    "[" ...
    
        at org.apache.calcite.sql.parser.impl.SqlParserImpl.convertException(SqlParserImpl.java:388)
        at org.apache.calcite.sql.parser.impl.SqlParserImpl.normalizeException(SqlParserImpl.java:119)
        at org.apache.calcite.sql.parser.SqlParser.parseQuery(SqlParser.java:131)
        at org.apache.calcite.sql.parser.SqlParser.parseStmt(SqlParser.java:156)
        at org.apache.flink.api.table.FlinkPlannerImpl.parse(FlinkPlannerImpl.scala:75)
        at org.apache.flink.api.table.BatchTableEnvironment.sql(BatchTableEnvironment.scala:128)

        …

 

How would I use aliases which contain space(s)?

 

Thank you,

Davran.

 

 

 

 

 

 

 

 

 



-- 
Freundliche Grüße / Kind Regards

Timo Walther 

Follow me: @twalthr
https://www.linkedin.com/in/twalthr
Reply | Threaded
Open this post in threaded view
|

RE: "select as" in Flink SQL

Davran Muzafarov

Thank you Timo.

 

From: Timo Walther [mailto:[hidden email]]
Sent: Wednesday, August 31, 2016 4:28 AM
To: [hidden email]
Subject: Re: "select as" in Flink SQL

 

Hi Davran,

Flink SQL uses a lexical policy similar to Java:
The case of identifiers is preserved whether or not they are quoted; after which, identifiers are matched case-sensitively. Unlike Java, back-ticks allow identifiers to contain non-alphanumeric characters.

So "select assetClass as `asset class` from tabel0" should do the trick.

I will improve the documentation about this.

Regards,
Timo

Am 30/08/16 um 21:49 schrieb Davran Muzafarov:

I am try to execute simple sql like this:

 

DataSet<MarketDataInfo> dataSet0 = env.fromCollection( infos0 );

tableEnv.registerDataSet( "table0", dataSet0 );

 

 

Table table = tableEnv.sql( "select assetClass as \”asset class\” from tabel0" );

 

I am getting:

 

org.apache.calcite.sql.parser.SqlParseException: Encountered "as \"" at line 1, column 19.

Was expecting one of:

    "FROM" ...

    "," ...

    "AS" <IDENTIFIER> ...

    "AS" <QUOTED_IDENTIFIER> ...

    "AS" <BACK_QUOTED_IDENTIFIER> ...

    "AS" <BRACKET_QUOTED_IDENTIFIER> ...

    "AS" <UNICODE_QUOTED_IDENTIFIER> ...

    "." ...

    "(" ...

    "NOT" ...

    "IN" ...

    "BETWEEN" ...

    "LIKE" ...

    "SIMILAR" ...

    "=" ...

    ">" ...

    "<" ...

    "<=" ...

    ">=" ...

    "<>" ...

    "+" ...

    "-" ...

    "*" ...

    "/" ...

    "||" ...

    "AND" ...

    "OR" ...

    "IS" ...

    "MEMBER" ...

    "SUBMULTISET" ...

    "MULTISET" ...

    "[" ...

   

        at org.apache.calcite.sql.parser.impl.SqlParserImpl.convertException(SqlParserImpl.java:388)

        at org.apache.calcite.sql.parser.impl.SqlParserImpl.normalizeException(SqlParserImpl.java:119)

        at org.apache.calcite.sql.parser.SqlParser.parseQuery(SqlParser.java:131)

        at org.apache.calcite.sql.parser.SqlParser.parseStmt(SqlParser.java:156)

        at org.apache.flink.api.table.FlinkPlannerImpl.parse(FlinkPlannerImpl.scala:75)

        …

 

If I use [ insteand of “, I am getting:

org.apache.calcite.sql.parser.SqlParseException: Encountered "as [" at line 1, column 19.
Was expecting one of:
    "FROM" ...
    "," ...
    "AS" <IDENTIFIER> ...
    "AS" <QUOTED_IDENTIFIER> ...
    "AS" <BACK_QUOTED_IDENTIFIER> ...
    "AS" <BRACKET_QUOTED_IDENTIFIER> ...
    "AS" <UNICODE_QUOTED_IDENTIFIER> ...
    "." ...
    "(" ...
    "NOT" ...
    "IN" ...
    "BETWEEN" ...
    "LIKE" ...
    "SIMILAR" ...
    "=" ...
    ">" ...
    "<" ...
    "<=" ...
    ">=" ...
    "<>" ...
    "+" ...
    "-" ...
    "*" ...
    "/" ...
    "||" ...
    "AND" ...
    "OR" ...
    "IS" ...
    "MEMBER" ...
    "SUBMULTISET" ...
    "MULTISET" ...
    "[" ...
    
        at org.apache.calcite.sql.parser.impl.SqlParserImpl.convertException(SqlParserImpl.java:388)
        at org.apache.calcite.sql.parser.impl.SqlParserImpl.normalizeException(SqlParserImpl.java:119)
        at org.apache.calcite.sql.parser.SqlParser.parseQuery(SqlParser.java:131)
        at org.apache.calcite.sql.parser.SqlParser.parseStmt(SqlParser.java:156)
        at org.apache.flink.api.table.FlinkPlannerImpl.parse(FlinkPlannerImpl.scala:75)
        at org.apache.flink.api.table.BatchTableEnvironment.sql(BatchTableEnvironment.scala:128)

        …

 

How would I use aliases which contain space(s)?

 

Thank you,

Davran.

 

 

 

 

 

 

 

 

 

 

 

-- 
Freundliche Grüße / Kind Regards
 
Timo Walther 
 
Follow me: @twalthr
https://www.linkedin.com/in/twalthr