Repository: incubator-trafodion Updated Branches: refs/heads/master 1ce089a0f -> 160785a30
add limit clause support for LOAD-INTO statement. add limit clause support for LOAD-INTO statement. Project: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/commit/2299f3df Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/tree/2299f3df Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/diff/2299f3df Branch: refs/heads/master Commit: 2299f3dfc156ca230c935c4ac150f7037d5d4dde Parents: f574b54 Author: eedy <[email protected]> Authored: Sun Dec 3 19:43:31 2017 +0800 Committer: EEDY <[email protected]> Committed: Mon Dec 11 09:38:58 2017 +0800 ---------------------------------------------------------------------- core/sql/parser/sqlparser.y | 46 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 44 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/2299f3df/core/sql/parser/sqlparser.y ---------------------------------------------------------------------- diff --git a/core/sql/parser/sqlparser.y b/core/sql/parser/sqlparser.y index 2580127..4cd13ad 100755 --- a/core/sql/parser/sqlparser.y +++ b/core/sql/parser/sqlparser.y @@ -17934,12 +17934,34 @@ aqr_option : TOK_SQLCODE '=' NUMERIC_LITERAL_EXACT_NO_SCALE /* type relx */ //HBASE LOAD -load_statement : TOK_LOAD TOK_TRANSFORM load_sample_option TOK_INTO table_name query_expression +load_statement : TOK_LOAD TOK_TRANSFORM load_sample_option TOK_INTO table_name query_expression optional_limit_spec { //disabled by default in 0.8.0 release if (CmpCommon::getDefault(COMP_BOOL_226) != DF_ON) YYERROR; + //limit clause + if ($7) + { + RelExpr *query = $6; + + if (query->getFirstNRows() >= 0) + { + // cannot specify LIMIT and FIRST N clauses together. + YYERROR; + } + else + { + NABoolean negate; + if ($7->castToConstValue(negate)) + { + ConstValue * limit = (ConstValue*)$7; + Lng32 scale = 0; + query->setFirstNRows(limit->getExactNumericValue(scale)); + } + } + } + $$ = new (PARSERHEAP()) HBaseBulkLoadPrep(CorrName(*$5, PARSERHEAP()), NULL, @@ -17949,7 +17971,7 @@ load_statement : TOK_LOAD TOK_TRANSFORM load_sample_option TOK_INTO table_name q //NULL ); } - | TOK_LOAD optional_hbbload_options TOK_INTO table_name query_expression + | TOK_LOAD optional_hbbload_options TOK_INTO table_name query_expression optional_limit_spec { CharInfo::CharSet stmtCharSet = CharInfo::UnknownCharSet; NAString * stmt = getSqlStmtStr ( stmtCharSet // out - CharInfo::CharSet & @@ -17966,6 +17988,26 @@ load_statement : TOK_LOAD TOK_TRANSFORM load_sample_option TOK_INTO table_name q stmt->index(" into ", 0, NAString::ignoreCase); RelRoot *top = finalize($5); + //limit clause + if ($6) + { + if (top->getFirstNRows() >= 0) + { + // cannot specify LIMIT and FIRST N clauses together. + YYERROR; + } + else + { + NABoolean negate; + if ($6->castToConstValue(negate)) + { + ConstValue * limit = (ConstValue*)$6; + Lng32 scale = 0; + top->setFirstNRows(limit->getExactNumericValue(scale)); + top->setFirstNRowsParam(NULL); + } + } + } ExeUtilHBaseBulkLoad * eubl = new (PARSERHEAP()) ExeUtilHBaseBulkLoad(CorrName(*$4, PARSERHEAP()),
