-
Notifications
You must be signed in to change notification settings - Fork 140
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
[WIP] FEAT(#3038): iplocation command #3085
base: main
Are you sure you want to change the base?
Changes from all commits
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 |
---|---|---|
|
@@ -5,37 +5,7 @@ | |
|
||
package org.opensearch.sql.ast; | ||
|
||
import org.opensearch.sql.ast.expression.AggregateFunction; | ||
import org.opensearch.sql.ast.expression.Alias; | ||
import org.opensearch.sql.ast.expression.AllFields; | ||
import org.opensearch.sql.ast.expression.And; | ||
import org.opensearch.sql.ast.expression.Argument; | ||
import org.opensearch.sql.ast.expression.AttributeList; | ||
import org.opensearch.sql.ast.expression.Between; | ||
import org.opensearch.sql.ast.expression.Case; | ||
import org.opensearch.sql.ast.expression.Cast; | ||
import org.opensearch.sql.ast.expression.Compare; | ||
import org.opensearch.sql.ast.expression.EqualTo; | ||
import org.opensearch.sql.ast.expression.Field; | ||
import org.opensearch.sql.ast.expression.Function; | ||
import org.opensearch.sql.ast.expression.HighlightFunction; | ||
import org.opensearch.sql.ast.expression.In; | ||
import org.opensearch.sql.ast.expression.Interval; | ||
import org.opensearch.sql.ast.expression.Let; | ||
import org.opensearch.sql.ast.expression.Literal; | ||
import org.opensearch.sql.ast.expression.Map; | ||
import org.opensearch.sql.ast.expression.NestedAllTupleFields; | ||
import org.opensearch.sql.ast.expression.Not; | ||
import org.opensearch.sql.ast.expression.Or; | ||
import org.opensearch.sql.ast.expression.QualifiedName; | ||
import org.opensearch.sql.ast.expression.RelevanceFieldList; | ||
import org.opensearch.sql.ast.expression.ScoreFunction; | ||
import org.opensearch.sql.ast.expression.Span; | ||
import org.opensearch.sql.ast.expression.UnresolvedArgument; | ||
import org.opensearch.sql.ast.expression.UnresolvedAttribute; | ||
import org.opensearch.sql.ast.expression.When; | ||
import org.opensearch.sql.ast.expression.WindowFunction; | ||
import org.opensearch.sql.ast.expression.Xor; | ||
import org.opensearch.sql.ast.expression.*; | ||
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. Avoid using |
||
import org.opensearch.sql.ast.statement.Explain; | ||
import org.opensearch.sql.ast.statement.Query; | ||
import org.opensearch.sql.ast.statement.Statement; | ||
|
@@ -165,6 +135,8 @@ public T visitFunction(Function node, C context) { | |
return visitChildren(node, context); | ||
} | ||
|
||
public T visitGeoip(Geoip node, C context) { return visitChildren(node, context); } | ||
|
||
public T visitWindowFunction(WindowFunction node, C context) { | ||
return visitChildren(node, context); | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,39 +10,7 @@ | |
import java.util.stream.Collectors; | ||
import lombok.experimental.UtilityClass; | ||
import org.apache.commons.lang3.tuple.Pair; | ||
import org.opensearch.sql.ast.expression.AggregateFunction; | ||
import org.opensearch.sql.ast.expression.Alias; | ||
import org.opensearch.sql.ast.expression.AllFields; | ||
import org.opensearch.sql.ast.expression.And; | ||
import org.opensearch.sql.ast.expression.Argument; | ||
import org.opensearch.sql.ast.expression.Between; | ||
import org.opensearch.sql.ast.expression.Case; | ||
import org.opensearch.sql.ast.expression.Cast; | ||
import org.opensearch.sql.ast.expression.Compare; | ||
import org.opensearch.sql.ast.expression.DataType; | ||
import org.opensearch.sql.ast.expression.EqualTo; | ||
import org.opensearch.sql.ast.expression.Field; | ||
import org.opensearch.sql.ast.expression.Function; | ||
import org.opensearch.sql.ast.expression.HighlightFunction; | ||
import org.opensearch.sql.ast.expression.In; | ||
import org.opensearch.sql.ast.expression.Interval; | ||
import org.opensearch.sql.ast.expression.Let; | ||
import org.opensearch.sql.ast.expression.Literal; | ||
import org.opensearch.sql.ast.expression.Map; | ||
import org.opensearch.sql.ast.expression.NestedAllTupleFields; | ||
import org.opensearch.sql.ast.expression.Not; | ||
import org.opensearch.sql.ast.expression.Or; | ||
import org.opensearch.sql.ast.expression.ParseMethod; | ||
import org.opensearch.sql.ast.expression.QualifiedName; | ||
import org.opensearch.sql.ast.expression.ScoreFunction; | ||
import org.opensearch.sql.ast.expression.Span; | ||
import org.opensearch.sql.ast.expression.SpanUnit; | ||
import org.opensearch.sql.ast.expression.UnresolvedArgument; | ||
import org.opensearch.sql.ast.expression.UnresolvedAttribute; | ||
import org.opensearch.sql.ast.expression.UnresolvedExpression; | ||
import org.opensearch.sql.ast.expression.When; | ||
import org.opensearch.sql.ast.expression.WindowFunction; | ||
import org.opensearch.sql.ast.expression.Xor; | ||
import org.opensearch.sql.ast.expression.*; | ||
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. Avoid using |
||
import org.opensearch.sql.ast.tree.Aggregation; | ||
import org.opensearch.sql.ast.tree.Dedupe; | ||
import org.opensearch.sql.ast.tree.Eval; | ||
|
@@ -429,6 +397,10 @@ public static List<Argument> defaultSortFieldArgs() { | |
return exprList(argument("asc", booleanLiteral(true)), argument("type", nullLiteral())); | ||
} | ||
|
||
public static Geoip geoip(UnresolvedExpression datasource, UnresolvedExpression ipAddress, String properties) { | ||
return new Geoip(datasource, ipAddress, properties); | ||
} | ||
|
||
public static Span span(UnresolvedExpression field, UnresolvedExpression value, SpanUnit unit) { | ||
return new Span(field, value, unit); | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package org.opensearch.sql.ast.expression; | ||
|
||
import com.google.common.collect.ImmutableList; | ||
import lombok.EqualsAndHashCode; | ||
import lombok.Getter; | ||
import lombok.RequiredArgsConstructor; | ||
import org.opensearch.sql.ast.AbstractNodeVisitor; | ||
|
||
import java.util.Collections; | ||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
/** | ||
* Expression node of scalar function. Params include function name (@funcName) and function | ||
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. I don't understand this Javadoc comment. |
||
* arguments (@funcArgs) | ||
*/ | ||
@Getter | ||
@EqualsAndHashCode(callSuper = false) | ||
@RequiredArgsConstructor | ||
public class Geoip extends UnresolvedExpression { | ||
private final UnresolvedExpression datasource; | ||
private final UnresolvedExpression ipAddress; | ||
private final String properties; | ||
|
||
@Override | ||
public List<UnresolvedExpression> getChild() { | ||
return ImmutableList.of(datasource, ipAddress); | ||
} | ||
|
||
@Override | ||
public <R, C> R accept(AbstractNodeVisitor<R, C> nodeVisitor, C context) { | ||
return nodeVisitor.visitGeoip(this, context); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package org.opensearch.sql.expression.ip; | ||
|
||
|
||
import lombok.EqualsAndHashCode; | ||
import lombok.Getter; | ||
import lombok.ToString; | ||
import org.opensearch.sql.common.grok.Converter; | ||
import org.opensearch.sql.data.model.ExprValue; | ||
import org.opensearch.sql.data.type.ExprType; | ||
import org.opensearch.sql.expression.Expression; | ||
import org.opensearch.sql.expression.ExpressionNodeVisitor; | ||
import org.opensearch.sql.expression.env.Environment; | ||
import org.opensearch.sql.planner.physical.collector.Rounding; | ||
|
||
import java.util.List; | ||
|
||
import static org.opensearch.sql.data.type.ExprCoreType.ARRAY; | ||
import static org.opensearch.sql.data.type.ExprCoreType.STRING; | ||
|
||
@Getter | ||
@ToString | ||
@EqualsAndHashCode | ||
public class GeoipExpression implements Expression { | ||
private final Expression datasource; | ||
private final Expression ipAddress; | ||
private final String[] properties; | ||
|
||
public GeoipExpression(Expression datasource, Expression ipAddress, String properties) { | ||
this.datasource = datasource; | ||
this.ipAddress = ipAddress; | ||
this.properties = properties.split(","); | ||
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. You probably want the parser to do this for you rather than splitting manually during logical planning. |
||
} | ||
|
||
@Override | ||
public ExprValue valueOf(Environment<Expression, ExprValue> valueEnv) { | ||
return ipAddress.valueOf(valueEnv); | ||
} | ||
|
||
@Override | ||
public ExprType type() { | ||
if (this.properties.length <= 1) { | ||
return STRING; | ||
} else { | ||
return ARRAY; | ||
} | ||
} | ||
|
||
@Override | ||
public <T, C> T accept(ExpressionNodeVisitor<T, C> visitor, C context) { | ||
return visitor.visitNode(this, context); | ||
} | ||
} |
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.
Avoid using
*
imports.