Github user sureshsubbiah commented on a diff in the pull request:
https://github.com/apache/trafodion/pull/1688#discussion_r221818361
--- Diff: core/sql/parser/sqlparser.y ---
@@ -13280,13 +13288,130 @@ table_expression : from_clause where_clause
sample_clause
SqlParser_CurrentParser->topHasOlapFunctions());
SqlParser_CurrentParser->setTopHasTDFunctions(FALSE);
}
+ | from_clause startwith_clause where_clause
+ {
+ if($1->getOperatorType() == REL_JOIN)
+ {
+ $$ =
+ getTableExpressionRelExpr($1,
+ $3,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ FALSE,
+
SqlParser_CurrentParser->topHasOlapFunctions());
+ }
+ else
+ $$ =
+ getTableExpressionRelExpr($1,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ FALSE,
+
SqlParser_CurrentParser->topHasOlapFunctions());
+ SqlParser_CurrentParser->setTopHasTDFunctions(FALSE);
+ ((BiConnectBy*)$2)->where_clause = $3;
+ $$->setBiConnectBy( $2);
+ $$->setHasConnectByFlag(TRUE);
+ }
+ | from_clause TOK_WHERE search_condition startwith_clause
+ {
+ if($1->getOperatorType() == REL_JOIN)
+ $$ =
+ getTableExpressionRelExpr($1,
+ $3,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ FALSE,
+
SqlParser_CurrentParser->topHasOlapFunctions());
+ else
+ $$ =
+ getTableExpressionRelExpr($1,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ FALSE,
+
SqlParser_CurrentParser->topHasOlapFunctions());
+ SqlParser_CurrentParser->setTopHasTDFunctions(FALSE);
+ ((BiConnectBy*)$4)->where_clause = $3;
+ //((BiConnectBy*)$3)->order_siblings_by_clause = $4;
+ $$->setBiConnectBy( $4);
+ $$->setHasConnectByFlag(TRUE);
+ }
/* type relx */
from_clause : TOK_FROM global_hint table_reference { $$ = $3; }
| from_clause ',' table_reference
{
$$ = new (PARSERHEAP()) Join($1, $3, REL_JOIN);
- }
+ }
+startwith_clause :TOK_START_WITH search_condition CONNECT_IDENTIFIER
TOK_BY search_condition
+ {
+ $$ = new (PARSERHEAP())BiConnectBy ((BiRelat*)$2,
(BiRelat*)$5);
+ //save the predicate text
+ $2->unparse(((BiConnectBy*)$$)->startWithString_,
PARSER_PHASE, USER_FORMAT);
+ }
+ |TOK_START_WITH search_condition CONNECT_IDENTIFIER
TOK_BY TOK_NOCYCLE search_condition
+ {
+ $$ = new (PARSERHEAP())BiConnectBy ((BiRelat*)$2,
(BiRelat*)$6);
+ //save the predicate text
+ $2->unparse(((BiConnectBy*)$$)->startWithString_,
PARSER_PHASE, USER_FORMAT);
+ ((BiConnectBy*)$$)->setNoCycle(TRUE);
+ }
+/*
+ | TOK_START_WITH search_condition CONNECT_IDENTIFIER
TOK_BY search_condition order_by_clause
+ {
+ $$ = new (PARSERHEAP())BiConnectBy ((BiRelat*)$2,
(BiRelat*)$5);
+ //save the predicate text
+ $2->unparse(((BiConnectBy*)$$)->startWithString_,
PARSER_PHASE, USER_FORMAT);
+ ((BiConnectBy*)$$)->order_siblings_by_clause = $5;
+ }
+ |TOK_START_WITH search_condition CONNECT_IDENTIFIER
TOK_BY TOK_NOCYCLE search_condition order_by_clause
+ {
+ $$ = new (PARSERHEAP())BiConnectBy ((BiRelat*)$2,
(BiRelat*)$6);
+ //save the predicate text
+ $2->unparse(((BiConnectBy*)$$)->startWithString_,
PARSER_PHASE, USER_FORMAT);
+ ((BiConnectBy*)$$)->setNoCycle(TRUE);
+ ((BiConnectBy*)$$)->order_siblings_by_clause = $6;
+ }
+*/
+ | CONNECT_IDENTIFIER TOK_BY search_condition
+ {
+ $$ = new (PARSERHEAP())BiConnectBy (NULL,
(BiRelat*)$3);
+ }
+ | CONNECT_IDENTIFIER TOK_BY TOK_NOCYCLE
search_condition
+ {
+ $$ = new (PARSERHEAP())BiConnectBy (NULL,
(BiRelat*)$4);
+ ((BiConnectBy*)$$)->setNoCycle(TRUE);
+ }
+/*
+ | CONNECT_IDENTIFIER TOK_BY search_condition
order_by_clause
+ {
+ $$ = new (PARSERHEAP())BiConnectBy (NULL,
(BiRelat*)$3);
+ ((BiConnectBy*)$$)->order_siblings_by_clause = $4;
+ }
+ | CONNECT_IDENTIFIER TOK_BY TOK_NOCYCLE
search_condition order_by_clause
+ {
+ $$ = new (PARSERHEAP())BiConnectBy (NULL,
(BiRelat*)$4);
+ ((BiConnectBy*)$$)->setNoCycle(TRUE);
+ ((BiConnectBy*)$$)->order_siblings_by_clause = $5;
--- End diff --
I suppose this is for later as it is commented out now. Will there be a
check for existence of SIBLINGS keyword in the binder. Maybe this is a good
place to check it as previous rule would have set the sibling flag in $5?
---