-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update for SQL and PPL parser to accept simple_query_string
#53
Changes from 2 commits
6e082af
607b330
dc75ce8
70a7457
6c1d9bb
3a2ff8a
a013d64
d9617ae
0256386
5bc53ef
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -252,8 +252,11 @@ public UnresolvedExpression visitConvertedDataType(ConvertedDataTypeContext ctx) | |
|
||
@Override | ||
public UnresolvedExpression visitRelevanceExpression(RelevanceExpressionContext ctx) { | ||
ParserRuleContext func = ctx.relevanceFunctionNameEx(); | ||
if (func == null) | ||
func = ctx.relevanceFunctionName(); | ||
return new Function( | ||
ctx.relevanceFunctionName().getText().toLowerCase(), | ||
func.getText().toLowerCase(), | ||
relevanceArguments(ctx)); | ||
} | ||
|
||
|
@@ -332,8 +335,11 @@ private List<UnresolvedExpression> relevanceArguments(RelevanceExpressionContext | |
// all the arguments are defaulted to string values | ||
// to skip environment resolving and function signature resolving | ||
ImmutableList.Builder<UnresolvedExpression> builder = ImmutableList.builder(); | ||
ParserRuleContext field = ctx.field; | ||
if (field == null) | ||
field = ctx.fields; | ||
builder.add(new UnresolvedArgument("field", | ||
new Literal(StringUtils.unquoteText(ctx.field.getText()), DataType.STRING))); | ||
new Literal(StringUtils.unquoteText(field.getText()), DataType.STRING))); | ||
builder.add(new UnresolvedArgument("query", | ||
new Literal(StringUtils.unquoteText(ctx.query.getText()), DataType.STRING))); | ||
ctx.relevanceArg().forEach(v -> builder.add(new UnresolvedArgument( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -279,6 +279,7 @@ INCLUDE: 'INCLUDE'; | |
IN_TERMS: 'IN_TERMS'; | ||
MATCHPHRASE: 'MATCHPHRASE'; | ||
MATCH_PHRASE: 'MATCH_PHRASE'; | ||
SIMPLE_QUERY_STRING: 'SIMPLE_QUERY_STRING'; | ||
MATCHQUERY: 'MATCHQUERY'; | ||
MATCH_QUERY: 'MATCH_QUERY'; | ||
MINUTE_OF_DAY: 'MINUTE_OF_DAY'; | ||
|
@@ -357,6 +358,8 @@ BIT_XOR_OP: '^'; | |
DOT: '.'; | ||
LR_BRACKET: '('; | ||
RR_BRACKET: ')'; | ||
LT_SQR_PRTHS: '['; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. where's this name coming from? |
||
RT_SQR_PRTHS: ']'; | ||
COMMA: ','; | ||
SEMI: ';'; | ||
AT_SIGN: '@'; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -51,6 +51,8 @@ | |
import java.util.Collections; | ||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
import org.antlr.v4.runtime.ParserRuleContext; | ||
import org.antlr.v4.runtime.RuleContext; | ||
import org.apache.commons.lang3.tuple.ImmutablePair; | ||
import org.apache.commons.lang3.tuple.Pair; | ||
|
@@ -362,8 +364,11 @@ public UnresolvedExpression visitConvertedDataType( | |
|
||
@Override | ||
public UnresolvedExpression visitRelevanceFunction(RelevanceFunctionContext ctx) { | ||
ParserRuleContext func = ctx.relevanceFunctionNameEx(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
if (func == null) | ||
func = ctx.relevanceFunctionName(); | ||
return new Function( | ||
ctx.relevanceFunctionName().getText().toLowerCase(), | ||
func.getText().toLowerCase(), | ||
relevanceArguments(ctx)); | ||
} | ||
|
||
|
@@ -393,8 +398,11 @@ private List<UnresolvedExpression> relevanceArguments(RelevanceFunctionContext c | |
// all the arguments are defaulted to string values | ||
// to skip environment resolving and function signature resolving | ||
ImmutableList.Builder<UnresolvedExpression> builder = ImmutableList.builder(); | ||
ParserRuleContext field = ctx.field; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ParserRuleContext field = ctx.field != null ctx.field : ctx.field2; |
||
if (field == null) | ||
field = ctx.fields; | ||
builder.add(new UnresolvedArgument("field", | ||
new Literal(StringUtils.unquoteText(ctx.field.getText()), DataType.STRING))); | ||
new Literal(StringUtils.unquoteText(field.getText()), DataType.STRING))); | ||
builder.add(new UnresolvedArgument("query", | ||
new Literal(StringUtils.unquoteText(ctx.query.getText()), DataType.STRING))); | ||
ctx.relevanceArg().forEach(v -> builder.add(new UnresolvedArgument( | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we rename it? Like
relevanceFunctionType1Name
andrelevanceFunctionType2Name
.Or maybe to make
relevanceExpressionType1
andrelevanceExpressionType2
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please be explicit with your naming as possible. Type1 and Type2 don't mean anything. If there's an order associated with the types in the list (and no other way to differentiate the types) we can call them first and second or something similar.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's change it to have separate rule for single-field relevance functions and a separate rule for multi-field relevance functions.
This way we can avoid the cumbersome
?:
inAstExpressionBuilder
. Instead there will be one method to visit single field relevance functions and another to visit multi-field relevance functions.