You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@hive.apache.org by "Zoltan Haindrich (JIRA)" <ji...@apache.org> on 2018/11/06 14:21:00 UTC

[jira] [Commented] (HIVE-20871) There are some syntax definition wrong in hqlsql.g4

    [ https://issues.apache.org/jira/browse/HIVE-20871?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16676814#comment-16676814 ] 

Zoltan Haindrich commented on HIVE-20871:
-----------------------------------------

note about: #1; I think '//' is not in the standard comments; so I think it would be better to drop that.. I see only '--' and '/*' / '*/' in sql2011
about: #2: It seems to me that {{limit a,b}} is a nonstandard sql extension; (do we support {{OFFSET n}} ?) ...it seems like {{LIMIT a,b}} is already supported (according to the language manual) and it's kinda logical...

feel free to submit a patch :)

> There are some syntax definition wrong in hqlsql.g4
> ---------------------------------------------------
>
>                 Key: HIVE-20871
>                 URL: https://issues.apache.org/jira/browse/HIVE-20871
>             Project: Hive
>          Issue Type: Bug
>    Affects Versions: 2.1.0, 3.1.1
>            Reporter: flying
>            Priority: Major
>
> hqlsql.g4 in version 3.x:
> h2. 1. Any comment in the last line of sql text can not be identified.
> sql:
> {code:java}
> // You will get an error if try parsing it.
> select a from b; // I am comment
> {code}
> cause:
> {code:java}
> // line 1917
> L_S_COMMENT : ('--' | '//')  .*? '\r'? '\n' -> channel(HIDDEN) ;       // Single line comment
> {code}
> maybe the code can fix to:
> {code:java}
> L_S_COMMENT : ('--' | '//')  .*? (('\r'? '\n') | EOF) -> channel(HIDDEN) ;       // Single line comment
> // The EOF can be recognized as the end of the single line comment
> {code}
> h2. 2. "limit" syntax definition may be mistake.
> two sqls:
> {code:java}
> select a from b limit 10; // just limit 10 record. this sql can be parsed normally.
> select a from b limit 10, 10; // pagnation, 10 record per page. you will get an error if try parsing it.
> {code}
> cause:
> {code:java}
> // line 900
> select_options_item :
>        T_LIMIT expr
>      | T_WITH (T_RR | T_RS | T_CS | T_UR) (T_USE T_AND T_KEEP (T_EXCLUSIVE | T_UPDATE | T_SHARE) T_LOCKS)?
>      ;
> {code}
> maybe the code can fix to:
> {code:java}
> // line 900
> select_options_item :
>        T_LIMIT expr (T_COMMA expr)?
>      | T_WITH (T_RR | T_RS | T_CS | T_UR) (T_USE T_AND T_KEEP (T_EXCLUSIVE | T_UPDATE | T_SHARE) T_LOCKS)?
>      ;
> // add optional '(T_COMMA expr)?' after 'T_LIMIT expr'.{code}
> h2. 3. The word 'type' can not be recognized as a column name.
> sql:
> {code:java}
> select type from someTable;
> // 'type' is a column. you will get an error if try parsing it. but you can execute the sql in hive query engine normally.
> {code}
> Cause the lexer 'T_TYPE' is not added to 'non_reserved_words'.
> // Sorry for good at English. Talk is cheap, just show you code. :)



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)