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

ASF GitHub Bot commented on TRAFODION-1673:
-------------------------------------------

Github user traflm commented on a diff in the pull request:

    https://github.com/apache/incubator-trafodion/pull/577#discussion_r70736959
  
    --- Diff: core/sql/parser/sqlparser.y ---
    @@ -14684,6 +14759,11 @@ optional_limit_spec : TOK_LIMIT 
NUMERIC_LITERAL_EXACT_NO_SCALE
     
     dml_statement : dml_query { $$ = $1; }
     
    +               | with_clause_list dml_query
    --- End diff --
    
    I found a way to avoid the reduce/shift and reduce/reduce error by add 
with_clause down to the underlying rules of non_join_query_expression, instead 
of add it at same level of non_join_query_expression. non_join_query_expression 
can represent many different styles of query expression, including utilities, 
which we don't want a with_clause as prefix, so in the underlying rules, only 
add with_clause before those SELECT syntax, and it solve the problem.
    
    And it seems if use redundant rule explicitly (looks annoying) , we can 
avoid the error. 
    For example:
      A : b  | c
    is better to change to 
      A : b 
      A : c
    I am still trying to understand this.
    
    I checked with PostgreSQL parser, they are doing similar things, comments 
from postgresql parser:
    
     * This rule parses the equivalent of the standard's <query expression>.
     * The duplicative productions are annoying, but hard to get rid of without
     * creating shift/reduce conflicts.


> Implement the WITH clause in Trafodion SQL for simple use cases
> ---------------------------------------------------------------
>
>                 Key: TRAFODION-1673
>                 URL: https://issues.apache.org/jira/browse/TRAFODION-1673
>             Project: Apache Trafodion
>          Issue Type: New Feature
>          Components: sql-cmp
>            Reporter: Hans Zeller
>            Assignee: liu ming
>
> We keep running into queries that use a WITH clause to define a temporary 
> view that can be used once or multiple times in a FROM clause in the query.
> For non-recursive queries, the WITH clause could probably be handled very 
> similar to a view. When it is defined, we create an in-memory view 
> descriptor, containing the name and the definition. When it is used in a FROM 
> clause, we could go through a code path similar to that of a view - bind the 
> (temporary) view text and substitute it in the query. The fix could probably 
> be handled entirely in the binder.
> This JIRA is *not* about recursive queries, those would require a lot more 
> effort, involving many components in addition to the binder.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to