spark-reviews mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From viirya <...@git.apache.org>
Subject [GitHub] spark pull request: [SPARK-12577][SQL] Better support of parenthes...
Date Wed, 06 Jan 2016 16:38:43 GMT
Github user viirya commented on a diff in the pull request:

    https://github.com/apache/spark/pull/10620#discussion_r48977585
  
    --- Diff: sql/hive/src/main/antlr3/org/apache/spark/sql/parser/ExpressionParser.g ---
    @@ -0,0 +1,509 @@
    +/**
    +   Licensed to the Apache Software Foundation (ASF) under one or more 
    +   contributor license agreements.  See the NOTICE file distributed with 
    +   this work for additional information regarding copyright ownership.
    +   The ASF licenses this file to You under the Apache License, Version 2.0
    +   (the "License"); you may not use this file except in compliance with 
    +   the License.  You may obtain a copy of the License at
    +
    +       http://www.apache.org/licenses/LICENSE-2.0
    +
    +   Unless required by applicable law or agreed to in writing, software
    +   distributed under the License is distributed on an "AS IS" BASIS,
    +   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    +   See the License for the specific language governing permissions and
    +   limitations under the License.
    +*/
    +parser grammar ExpressionParser;
    +
    +options
    +{
    +output=AST;
    +ASTLabelType=CommonTree;
    +backtrack=false;
    +k=3;
    +}
    +
    +@members {
    +  @Override
    +  public Object recoverFromMismatchedSet(IntStream input,
    +      RecognitionException re, BitSet follow) throws RecognitionException {
    +    throw re;
    +  }
    +  @Override
    +  public void displayRecognitionError(String[] tokenNames,
    +      RecognitionException e) {
    +    gParent.errors.add(new ParseError(gParent, e, tokenNames));
    +  }
    +  protected boolean useSQL11ReservedKeywordsForIdentifier() {
    +    return gParent.useSQL11ReservedKeywordsForIdentifier();
    +  }
    +}
    +
    +@rulecatch {
    +catch (RecognitionException e) {
    +  throw e;
    +}
    +}
    +
    +//-----------------------------------------------------------------------------------
    +
    +constant
    +@init { gParent.pushMsg("constant", state); }
    +@after { gParent.popMsg(state); }
    +    :
    +    Number
    +    | dateLiteral
    +    | timestampLiteral
    +    | intervalLiteral
    +    | StringLiteral
    +    | stringLiteralSequence
    +    | BigintLiteral
    +    | SmallintLiteral
    +    | TinyintLiteral
    +    | DecimalLiteral
    +    | charSetStringLiteral
    +    | booleanValue
    +    ;
    +
    +stringLiteralSequence
    +    :
    +    StringLiteral StringLiteral+ -> ^(TOK_STRINGLITERALSEQUENCE StringLiteral StringLiteral+)
    +    ;
    +
    +charSetStringLiteral
    +@init { gParent.pushMsg("character string literal", state); }
    +@after { gParent.popMsg(state); }
    +    :
    +    csName=CharSetName csLiteral=CharSetLiteral -> ^(TOK_CHARSETLITERAL $csName $csLiteral)
    +    ;
    +
    +dateLiteral
    +    :
    +    KW_DATE StringLiteral ->
    +    {
    +      // Create DateLiteral token, but with the text of the string value
    +      // This makes the dateLiteral more consistent with the other type literals.
    +      adaptor.create(TOK_DATELITERAL, $StringLiteral.text)
    +    }
    +    |
    +    KW_CURRENT_DATE -> ^(TOK_FUNCTION KW_CURRENT_DATE)
    +    ;
    +
    +timestampLiteral
    +    :
    +    KW_TIMESTAMP StringLiteral ->
    +    {
    +      adaptor.create(TOK_TIMESTAMPLITERAL, $StringLiteral.text)
    +    }
    +    |
    +    KW_CURRENT_TIMESTAMP -> ^(TOK_FUNCTION KW_CURRENT_TIMESTAMP)
    +    ;
    +
    +intervalLiteral
    +    :
    +    KW_INTERVAL StringLiteral qualifiers=intervalQualifiers ->
    +    {
    +      adaptor.create($qualifiers.tree.token.getType(), $StringLiteral.text)
    +    }
    +    ;
    +
    +intervalQualifiers
    +    :
    +    KW_YEAR KW_TO KW_MONTH -> TOK_INTERVAL_YEAR_MONTH_LITERAL
    +    | KW_DAY KW_TO KW_SECOND -> TOK_INTERVAL_DAY_TIME_LITERAL
    +    | KW_YEAR -> TOK_INTERVAL_YEAR_LITERAL
    +    | KW_MONTH -> TOK_INTERVAL_MONTH_LITERAL
    +    | KW_DAY -> TOK_INTERVAL_DAY_LITERAL
    +    | KW_HOUR -> TOK_INTERVAL_HOUR_LITERAL
    +    | KW_MINUTE -> TOK_INTERVAL_MINUTE_LITERAL
    +    | KW_SECOND -> TOK_INTERVAL_SECOND_LITERAL
    +    ;
    +
    +expression
    +@init { gParent.pushMsg("expression specification", state); }
    +@after { gParent.popMsg(state); }
    +    :
    +    precedenceOrExpression
    +    ;
    +
    +atomExpression
    +    :
    +    (KW_NULL) => KW_NULL -> TOK_NULL
    +    | (constant) => constant
    +    | castExpression
    +    | caseExpression
    +    | whenExpression
    +    | (functionName LPAREN) => function
    +    | tableOrColumn
    +    | LPAREN! expression RPAREN!
    +    ;
    +
    +
    +precedenceFieldExpression
    +    :
    +    atomExpression ((LSQUARE^ expression RSQUARE!) | (DOT^ identifier))*
    +    ;
    +
    +precedenceUnaryOperator
    +    :
    +    PLUS | MINUS | TILDE
    +    ;
    +
    +nullCondition
    +    :
    +    KW_NULL -> ^(TOK_ISNULL)
    +    | KW_NOT KW_NULL -> ^(TOK_ISNOTNULL)
    +    ;
    +
    +precedenceUnaryPrefixExpression
    +    :
    +    (precedenceUnaryOperator^)* precedenceFieldExpression
    +    ;
    +
    +precedenceUnarySuffixExpression
    +    :
    +    (
    +    (LPAREN precedenceUnaryPrefixExpression RPAREN) => LPAREN precedenceUnaryPrefixExpression
(a=KW_IS nullCondition)? RPAREN
    +    |
    +    precedenceUnaryPrefixExpression (a=KW_IS nullCondition)?
    --- End diff --
    
    @hvanhovell I made the change here.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Mime
View raw message