flying created HIVE-20871:
-----------------------------

             Summary: there is 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: 3.1.1, 2.1.0
            Reporter: flying


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. 2. 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)

Reply via email to