|
@@ -406,11 +406,6 @@ HiveOrImpalaCreate
|
|
|
| '<impala>CREATE'
|
|
| '<impala>CREATE'
|
|
|
;
|
|
;
|
|
|
|
|
|
|
|
-HiveOrImpalaCurrent
|
|
|
|
|
- : '<hive>CURRENT'
|
|
|
|
|
- | '<impala>CURRENT'
|
|
|
|
|
- ;
|
|
|
|
|
-
|
|
|
|
|
HiveOrImpalaDatabasesOrSchemas
|
|
HiveOrImpalaDatabasesOrSchemas
|
|
|
: '<hive>DATABASES'
|
|
: '<hive>DATABASES'
|
|
|
| '<hive>SCHEMAS'
|
|
| '<hive>SCHEMAS'
|
|
@@ -423,11 +418,6 @@ HiveOrImpalaEscaped
|
|
|
| '<impala>ESCAPED'
|
|
| '<impala>ESCAPED'
|
|
|
;
|
|
;
|
|
|
|
|
|
|
|
-HiveOrImpalaExternal
|
|
|
|
|
- : '<hive>EXTERNAL'
|
|
|
|
|
- | '<impala>EXTERNAL'
|
|
|
|
|
- ;
|
|
|
|
|
-
|
|
|
|
|
HiveOrImpalaFields
|
|
HiveOrImpalaFields
|
|
|
: '<hive>FIELDS'
|
|
: '<hive>FIELDS'
|
|
|
| '<impala>FIELDS'
|
|
| '<impala>FIELDS'
|
|
@@ -1062,25 +1052,14 @@ DerivedColumnChain_EDIT
|
|
|
;
|
|
;
|
|
|
|
|
|
|
|
ColumnIdentifier
|
|
ColumnIdentifier
|
|
|
- : RegularOrBacktickedIdentifier OptionalMapOrArrayKey
|
|
|
|
|
- {
|
|
|
|
|
- if ($2) {
|
|
|
|
|
- $$ = { name: $1, keySet: true };
|
|
|
|
|
- } else {
|
|
|
|
|
- $$ = { name: $1 };
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ : RegularOrBacktickedIdentifier -> { name: $1 };
|
|
|
|
|
+ | RegularOrBacktickedIdentifier HiveOrImpalaLeftSquareBracket ValueExpression HiveOrImpalaRightSquareBracket -> { name: $1, keySet: true }
|
|
|
|
|
+ | RegularOrBacktickedIdentifier HiveOrImpalaLeftSquareBracket HiveOrImpalaRightSquareBracket -> { name: $1, keySet: true }
|
|
|
;
|
|
;
|
|
|
|
|
|
|
|
ColumnIdentifier_EDIT
|
|
ColumnIdentifier_EDIT
|
|
|
- : RegularOrBacktickedIdentifier HiveOrImpalaLeftSquareBracket AnyCursor HiveOrImpalaRightSquareBracketOrError
|
|
|
|
|
- {
|
|
|
|
|
- $$ = { name: $1, insideKey: true }
|
|
|
|
|
- }
|
|
|
|
|
- | RegularOrBacktickedIdentifier HiveOrImpalaLeftSquareBracket ValueExpression_EDIT HiveOrImpalaRightSquareBracketOrError
|
|
|
|
|
- {
|
|
|
|
|
- $$ = { name: $1 }
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ : RegularOrBacktickedIdentifier HiveOrImpalaLeftSquareBracket AnyCursor HiveOrImpalaRightSquareBracketOrError -> { name: $1, insideKey: true }
|
|
|
|
|
+ | RegularOrBacktickedIdentifier HiveOrImpalaLeftSquareBracket ValueExpression_EDIT HiveOrImpalaRightSquareBracketOrError -> { name: $1 };
|
|
|
;
|
|
;
|
|
|
|
|
|
|
|
PartialBacktickedIdentifierOrPartialCursor
|
|
PartialBacktickedIdentifierOrPartialCursor
|
|
@@ -1088,12 +1067,6 @@ PartialBacktickedIdentifierOrPartialCursor
|
|
|
| 'PARTIAL_CURSOR'
|
|
| 'PARTIAL_CURSOR'
|
|
|
;
|
|
;
|
|
|
|
|
|
|
|
-OptionalMapOrArrayKey
|
|
|
|
|
- :
|
|
|
|
|
- | HiveOrImpalaLeftSquareBracket ValueExpression HiveOrImpalaRightSquareBracket
|
|
|
|
|
- | HiveOrImpalaLeftSquareBracket HiveOrImpalaRightSquareBracket
|
|
|
|
|
- ;
|
|
|
|
|
-
|
|
|
|
|
HiveOrImpalaRightSquareBracketOrError
|
|
HiveOrImpalaRightSquareBracketOrError
|
|
|
: HiveOrImpalaRightSquareBracket
|
|
: HiveOrImpalaRightSquareBracket
|
|
|
| error
|
|
| error
|
|
@@ -1289,16 +1262,6 @@ QuerySpecification_EDIT
|
|
|
| CommonTableExpression_EDIT SelectStatement OptionalUnions
|
|
| CommonTableExpression_EDIT SelectStatement OptionalUnions
|
|
|
;
|
|
;
|
|
|
|
|
|
|
|
-OptionallyParenthesizedSelectStatement
|
|
|
|
|
- : SelectStatement
|
|
|
|
|
- | '(' SelectStatement ')' // Impala specific
|
|
|
|
|
- ;
|
|
|
|
|
-
|
|
|
|
|
-OptionallyParenthesizedSelectStatement_EDIT
|
|
|
|
|
- : SelectStatement_EDIT
|
|
|
|
|
- | '(' SelectStatement_EDIT RightParenthesisOrError
|
|
|
|
|
- ;
|
|
|
|
|
-
|
|
|
|
|
SelectStatement
|
|
SelectStatement
|
|
|
: 'SELECT' OptionalAllOrDistinct SelectList -> { selectList: $3 }
|
|
: 'SELECT' OptionalAllOrDistinct SelectList -> { selectList: $3 }
|
|
|
| 'SELECT' OptionalAllOrDistinct SelectList TableExpression -> { selectList: $3, tableExpression: $4 }
|
|
| 'SELECT' OptionalAllOrDistinct SelectList TableExpression -> { selectList: $3, tableExpression: $4 }
|
|
@@ -2273,17 +2236,42 @@ InValueList
|
|
|
| InValueList ',' NonParenthesizedValueExpressionPrimary
|
|
| InValueList ',' NonParenthesizedValueExpressionPrimary
|
|
|
;
|
|
;
|
|
|
|
|
|
|
|
-InValueList_EDIT
|
|
|
|
|
- : NonParenthesizedValueExpressionPrimary_EDIT
|
|
|
|
|
- | InValueList ',' AnyCursor
|
|
|
|
|
- | InValueList ',' NonParenthesizedValueExpressionPrimary_EDIT
|
|
|
|
|
- | InValueList ',' NonParenthesizedValueExpressionPrimary_EDIT ',' InValueList
|
|
|
|
|
- | NonParenthesizedValueExpressionPrimary_EDIT ',' InValueList
|
|
|
|
|
- ;
|
|
|
|
|
-
|
|
|
|
|
NonParenthesizedValueExpressionPrimary
|
|
NonParenthesizedValueExpressionPrimary
|
|
|
: UnsignedValueSpecification
|
|
: UnsignedValueSpecification
|
|
|
- | ColumnReference -> { types: ['COLREF'], columnReference: $1 }
|
|
|
|
|
|
|
+ | ColumnOrArbitraryFunctionRef -> { types: ['COLREF'], columnReference: $1.chain }
|
|
|
|
|
+ | ColumnOrArbitraryFunctionRef ArbitraryFunctionRightPart
|
|
|
|
|
+ {
|
|
|
|
|
+ // We need to handle arbitrary UDFs here instead of inside UserDefinedFunction or there will be a conflict
|
|
|
|
|
+ // with columnReference for functions like: db.udf(foo)
|
|
|
|
|
+ var fn = $1.chain[$1.chain.length - 1].name.toLowerCase();
|
|
|
|
|
+ $1.lastLoc.type = 'function';
|
|
|
|
|
+ $1.lastLoc.function = fn;
|
|
|
|
|
+ $1.lastLoc.location = {
|
|
|
|
|
+ first_line: $1.lastLoc.location.first_line,
|
|
|
|
|
+ last_line: $1.lastLoc.location.last_line,
|
|
|
|
|
+ first_column: $1.lastLoc.location.first_column,
|
|
|
|
|
+ last_column: $1.lastLoc.location.last_column - 1
|
|
|
|
|
+ }
|
|
|
|
|
+ if ($1.lastLoc !== $1.firstLoc) {
|
|
|
|
|
+ $1.firstLoc.type = 'database';
|
|
|
|
|
+ } else {
|
|
|
|
|
+ delete $1.lastLoc.identifierChain;
|
|
|
|
|
+ }
|
|
|
|
|
+ if ($2.expression) {
|
|
|
|
|
+ $$ = { function: fn, expression: $2.expression, types: parser.findReturnTypes(fn) }
|
|
|
|
|
+ } else {
|
|
|
|
|
+ $$ = { function: fn, types: parser.findReturnTypes(fn) }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ | ArbitraryFunctionName ArbitraryFunctionRightPart
|
|
|
|
|
+ {
|
|
|
|
|
+ parser.addFunctionLocation(@1, $1);
|
|
|
|
|
+ if ($2.expression) {
|
|
|
|
|
+ $$ = { function: $1, expression: $2.expression, types: parser.findReturnTypes($1) }
|
|
|
|
|
+ } else {
|
|
|
|
|
+ $$ = { function: $1, types: parser.findReturnTypes($1) }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
| UserDefinedFunction
|
|
| UserDefinedFunction
|
|
|
| 'NULL' -> { types: [ 'NULL' ] }
|
|
| 'NULL' -> { types: [ 'NULL' ] }
|
|
|
| ImpalaInterval -> { types: [ 'TIMESTAMP' ] }
|
|
| ImpalaInterval -> { types: [ 'TIMESTAMP' ] }
|
|
@@ -2291,7 +2279,7 @@ NonParenthesizedValueExpressionPrimary
|
|
|
|
|
|
|
|
NonParenthesizedValueExpressionPrimary_EDIT
|
|
NonParenthesizedValueExpressionPrimary_EDIT
|
|
|
: UnsignedValueSpecification_EDIT
|
|
: UnsignedValueSpecification_EDIT
|
|
|
- | ColumnReference_EDIT
|
|
|
|
|
|
|
+ | ColumnOrArbitraryFunctionRef_EDIT
|
|
|
{
|
|
{
|
|
|
if ($1.suggestKeywords) {
|
|
if ($1.suggestKeywords) {
|
|
|
$$ = { types: ['COLREF'], columnReference: $1, suggestKeywords: $1.suggestKeywords };
|
|
$$ = { types: ['COLREF'], columnReference: $1, suggestKeywords: $1.suggestKeywords };
|
|
@@ -2299,10 +2287,58 @@ NonParenthesizedValueExpressionPrimary_EDIT
|
|
|
$$ = { types: ['COLREF'], columnReference: $1 };
|
|
$$ = { types: ['COLREF'], columnReference: $1 };
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+ | ColumnOrArbitraryFunctionRef ArbitraryFunctionRightPart_EDIT
|
|
|
|
|
+ {
|
|
|
|
|
+ var fn = $1.chain[$1.chain.length - 1].name.toLowerCase();
|
|
|
|
|
+ $1.lastLoc.type = 'function';
|
|
|
|
|
+ $1.lastLoc.function = fn;
|
|
|
|
|
+ $1.lastLoc.location = {
|
|
|
|
|
+ first_line: $1.lastLoc.location.first_line,
|
|
|
|
|
+ last_line: $1.lastLoc.location.last_line,
|
|
|
|
|
+ first_column: $1.lastLoc.location.first_column,
|
|
|
|
|
+ last_column: $1.lastLoc.location.last_column - 1
|
|
|
|
|
+ }
|
|
|
|
|
+ if ($1.lastLoc !== $1.firstLoc) {
|
|
|
|
|
+ $1.firstLoc.type = 'database';
|
|
|
|
|
+ } else {
|
|
|
|
|
+ delete $1.lastLoc.identifierChain;
|
|
|
|
|
+ }
|
|
|
|
|
+ if ($2.position) {
|
|
|
|
|
+ parser.applyArgumentTypesToSuggestions(fn, $2.position);
|
|
|
|
|
+ }
|
|
|
|
|
+ $$ = { types: parser.findReturnTypes(fn) };
|
|
|
|
|
+ }
|
|
|
|
|
+ | ArbitraryFunctionName ArbitraryFunctionRightPart_EDIT
|
|
|
|
|
+ {
|
|
|
|
|
+ parser.addFunctionLocation(@1, $1);
|
|
|
|
|
+ if ($2.position) {
|
|
|
|
|
+ parser.applyArgumentTypesToSuggestions($1, $2.position);
|
|
|
|
|
+ }
|
|
|
|
|
+ $$ = { types: parser.findReturnTypes($1) };
|
|
|
|
|
+ }
|
|
|
| UserDefinedFunction_EDIT
|
|
| UserDefinedFunction_EDIT
|
|
|
| ImpalaInterval_EDIT
|
|
| ImpalaInterval_EDIT
|
|
|
;
|
|
;
|
|
|
|
|
|
|
|
|
|
+ColumnOrArbitraryFunctionRef
|
|
|
|
|
+ : BasicIdentifierChain
|
|
|
|
|
+ {
|
|
|
|
|
+ var lastLoc = parser.yy.locations[parser.yy.locations.length - 1];
|
|
|
|
|
+ lastLoc.type = 'column';
|
|
|
|
|
+ // used for function references with db prefix
|
|
|
|
|
+ var firstLoc = parser.yy.locations[parser.yy.locations.length - $1.length];
|
|
|
|
|
+ $$ = { chain: $1, firstLoc: firstLoc, lastLoc: lastLoc }
|
|
|
|
|
+ }
|
|
|
|
|
+ | BasicIdentifierChain AnyDot '*'
|
|
|
|
|
+ {
|
|
|
|
|
+ parser.addAsteriskLocation(@3, $1.concat({ asterisk: true }));
|
|
|
|
|
+ }
|
|
|
|
|
+ ;
|
|
|
|
|
+
|
|
|
|
|
+ColumnOrArbitraryFunctionRef_EDIT
|
|
|
|
|
+ : BasicIdentifierChain_EDIT
|
|
|
|
|
+ ;
|
|
|
|
|
+
|
|
|
ImpalaInterval
|
|
ImpalaInterval
|
|
|
: '<impala>INTERVAL' SignedInteger RegularIdentifier
|
|
: '<impala>INTERVAL' SignedInteger RegularIdentifier
|
|
|
;
|
|
;
|
|
@@ -2464,48 +2500,6 @@ SelectList_EDIT
|
|
|
| SelectList ',' SelectSpecification_EDIT ',' SelectList -> $3
|
|
| SelectList ',' SelectSpecification_EDIT ',' SelectList -> $3
|
|
|
;
|
|
;
|
|
|
|
|
|
|
|
-DerivedColumn_TWO
|
|
|
|
|
- : ColumnIdentifier
|
|
|
|
|
- {
|
|
|
|
|
- parser.addColumnLocation(@1, [$1]);
|
|
|
|
|
- }
|
|
|
|
|
- | ColumnIdentifier AnyDot '*'
|
|
|
|
|
- {
|
|
|
|
|
- parser.addColumnLocation(@1, [$1]);
|
|
|
|
|
- }
|
|
|
|
|
- | ColumnIdentifier AnyDot DerivedColumnChain
|
|
|
|
|
- {
|
|
|
|
|
- parser.addColumnLocation(@2, [$1].concat($3));
|
|
|
|
|
- }
|
|
|
|
|
- ;
|
|
|
|
|
-
|
|
|
|
|
-DerivedColumn_EDIT_TWO
|
|
|
|
|
- : ColumnIdentifier AnyDot PartialBacktickedOrPartialCursor
|
|
|
|
|
- {
|
|
|
|
|
- // TODO: Check if valid: SELECT testMap["key"].* FROM foo
|
|
|
|
|
- if (typeof $1.key === 'undefined') {
|
|
|
|
|
- parser.yy.result.suggestStar = true;
|
|
|
|
|
- }
|
|
|
|
|
- parser.suggestColumns({
|
|
|
|
|
- identifierChain: [ $1 ]
|
|
|
|
|
- });
|
|
|
|
|
- }
|
|
|
|
|
- | ColumnIdentifier AnyDot DerivedColumnChain '<impala>.' 'PARTIAL_CURSOR'
|
|
|
|
|
- {
|
|
|
|
|
- $3.unshift($1);
|
|
|
|
|
- parser.suggestColumns({
|
|
|
|
|
- identifierChain: $3
|
|
|
|
|
- });
|
|
|
|
|
- }
|
|
|
|
|
- | ColumnIdentifier AnyDot DerivedColumnChain '<hive>.' 'PARTIAL_CURSOR'
|
|
|
|
|
- {
|
|
|
|
|
- $3.unshift($1);
|
|
|
|
|
- parser.suggestColumns({
|
|
|
|
|
- identifierChain: $3
|
|
|
|
|
- });
|
|
|
|
|
- }
|
|
|
|
|
- ;
|
|
|
|
|
-
|
|
|
|
|
TableReferenceList
|
|
TableReferenceList
|
|
|
: TableReference
|
|
: TableReference
|
|
|
| TableReferenceList ',' TableReference -> $3
|
|
| TableReferenceList ',' TableReference -> $3
|
|
@@ -2999,8 +2993,7 @@ OptionalLateralViews_EDIT
|
|
|
;
|
|
;
|
|
|
|
|
|
|
|
UserDefinedFunction
|
|
UserDefinedFunction
|
|
|
- : ArbitraryFunction
|
|
|
|
|
- | AggregateFunction OptionalOverClause
|
|
|
|
|
|
|
+ : AggregateFunction OptionalOverClause
|
|
|
{
|
|
{
|
|
|
if (!$2) {
|
|
if (!$2) {
|
|
|
$1.suggestKeywords = ['OVER'];
|
|
$1.suggestKeywords = ['OVER'];
|
|
@@ -3013,8 +3006,7 @@ UserDefinedFunction
|
|
|
;
|
|
;
|
|
|
|
|
|
|
|
UserDefinedFunction_EDIT
|
|
UserDefinedFunction_EDIT
|
|
|
- : ArbitraryFunction_EDIT
|
|
|
|
|
- | AggregateFunction_EDIT
|
|
|
|
|
|
|
+ : AggregateFunction_EDIT
|
|
|
| AggregateFunction OptionalOverClause_EDIT
|
|
| AggregateFunction OptionalOverClause_EDIT
|
|
|
| AnalyticFunction_EDIT
|
|
| AnalyticFunction_EDIT
|
|
|
| AnalyticFunction_EDIT OverClause
|
|
| AnalyticFunction_EDIT OverClause
|
|
@@ -3711,8 +3703,8 @@ SumFunction_EDIT
|
|
|
;
|
|
;
|
|
|
|
|
|
|
|
LateralView
|
|
LateralView
|
|
|
- : '<hive>LATERAL' '<hive>VIEW' OptionalOuter UserDefinedFunction RegularOrBacktickedIdentifier LateralViewColumnAliases -> { lateralView: { udtf: $4, tableAlias: $5, columnAliases: $6 }}
|
|
|
|
|
- | '<hive>LATERAL' '<hive>VIEW' OptionalOuter UserDefinedFunction RegularOrBacktickedIdentifier
|
|
|
|
|
|
|
+ : '<hive>LATERAL' '<hive>VIEW' OptionalOuter ArbitraryFunction RegularOrBacktickedIdentifier LateralViewColumnAliases -> { lateralView: { udtf: $4, tableAlias: $5, columnAliases: $6 }}
|
|
|
|
|
+ | '<hive>LATERAL' '<hive>VIEW' OptionalOuter ArbitraryFunction RegularOrBacktickedIdentifier
|
|
|
{
|
|
{
|
|
|
if ($4.function.toLowerCase() === 'explode') {
|
|
if ($4.function.toLowerCase() === 'explode') {
|
|
|
$$ = { lateralView: { udtf: $4, tableAlias: $5, columnAliases: ['key', 'value'] }, suggestKeywords: ['AS'] };
|
|
$$ = { lateralView: { udtf: $4, tableAlias: $5, columnAliases: ['key', 'value'] }, suggestKeywords: ['AS'] };
|
|
@@ -3722,16 +3714,16 @@ LateralView
|
|
|
$$ = { lateralView: { udtf: $4, tableAlias: $5, columnAliases: [] }, suggestKeywords: ['AS'] };
|
|
$$ = { lateralView: { udtf: $4, tableAlias: $5, columnAliases: [] }, suggestKeywords: ['AS'] };
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- | '<hive>LATERAL' '<hive>VIEW' OptionalOuter UserDefinedFunction LateralViewColumnAliases -> { lateralView: { udtf: $4, columnAliases: $5 }}
|
|
|
|
|
|
|
+ | '<hive>LATERAL' '<hive>VIEW' OptionalOuter ArbitraryFunction LateralViewColumnAliases -> { lateralView: { udtf: $4, columnAliases: $5 }}
|
|
|
;
|
|
;
|
|
|
|
|
|
|
|
LateralView_EDIT
|
|
LateralView_EDIT
|
|
|
- : '<hive>LATERAL' '<hive>VIEW' OptionalOuter UserDefinedFunction_EDIT
|
|
|
|
|
- | '<hive>LATERAL' '<hive>VIEW' OptionalOuter UserDefinedFunction_EDIT RegularOrBacktickedIdentifier
|
|
|
|
|
- | '<hive>LATERAL' '<hive>VIEW' OptionalOuter UserDefinedFunction_EDIT RegularOrBacktickedIdentifier LateralViewColumnAliases
|
|
|
|
|
- | '<hive>LATERAL' '<hive>VIEW' OptionalOuter UserDefinedFunction RegularOrBacktickedIdentifier LateralViewColumnAliases_EDIT
|
|
|
|
|
- | '<hive>LATERAL' '<hive>VIEW' OptionalOuter UserDefinedFunction PartialBacktickedOrCursor
|
|
|
|
|
- | '<hive>LATERAL' '<hive>VIEW' OptionalOuter UserDefinedFunction PartialBacktickedOrCursor LateralViewColumnAliases
|
|
|
|
|
|
|
+ : '<hive>LATERAL' '<hive>VIEW' OptionalOuter ArbitraryFunction_EDIT
|
|
|
|
|
+ | '<hive>LATERAL' '<hive>VIEW' OptionalOuter ArbitraryFunction_EDIT RegularOrBacktickedIdentifier
|
|
|
|
|
+ | '<hive>LATERAL' '<hive>VIEW' OptionalOuter ArbitraryFunction_EDIT RegularOrBacktickedIdentifier LateralViewColumnAliases
|
|
|
|
|
+ | '<hive>LATERAL' '<hive>VIEW' OptionalOuter ArbitraryFunction RegularOrBacktickedIdentifier LateralViewColumnAliases_EDIT
|
|
|
|
|
+ | '<hive>LATERAL' '<hive>VIEW' OptionalOuter ArbitraryFunction PartialBacktickedOrCursor
|
|
|
|
|
+ | '<hive>LATERAL' '<hive>VIEW' OptionalOuter ArbitraryFunction PartialBacktickedOrCursor LateralViewColumnAliases
|
|
|
| '<hive>LATERAL' '<hive>VIEW' OptionalOuter 'CURSOR'
|
|
| '<hive>LATERAL' '<hive>VIEW' OptionalOuter 'CURSOR'
|
|
|
{
|
|
{
|
|
|
if (!$3) {
|
|
if (!$3) {
|