Skip to content

Commit

Permalink
Reverting commits in ast folder attempt #2
Browse files Browse the repository at this point in the history
Signed-off-by: Mitchell Gale <[email protected]>
  • Loading branch information
MitchellGale committed Aug 3, 2023
1 parent de6831d commit 9381892
Show file tree
Hide file tree
Showing 8 changed files with 62 additions and 63 deletions.
64 changes: 32 additions & 32 deletions core/src/main/java/org/opensearch/sql/ast/dsl/AstDSL.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public UnresolvedPlan relation(String tableName) {

public UnresolvedPlan relation(List<String> tableNames) {
return new Relation(
tableNames.stream().map(AstDSL::qualifiedName).collect(Collectors.toList()));
tableNames.stream().map(AstDSL::qualifiedName).collect(Collectors.toList()));
}

public UnresolvedPlan relation(QualifiedName tableName) {
Expand All @@ -103,26 +103,26 @@ public static Eval eval(UnresolvedPlan input, Let... projectList) {
}

public static UnresolvedPlan projectWithArg(
UnresolvedPlan input, List<Argument> argList, UnresolvedExpression... projectList) {
UnresolvedPlan input, List<Argument> argList, UnresolvedExpression... projectList) {
return new Project(Arrays.asList(projectList), argList).attach(input);
}

public static UnresolvedPlan agg(
UnresolvedPlan input,
List<UnresolvedExpression> aggList,
List<UnresolvedExpression> sortList,
List<UnresolvedExpression> groupList,
List<Argument> argList) {
UnresolvedPlan input,
List<UnresolvedExpression> aggList,
List<UnresolvedExpression> sortList,
List<UnresolvedExpression> groupList,
List<Argument> argList) {
return new Aggregation(aggList, sortList, groupList, null, argList).attach(input);
}

public static UnresolvedPlan agg(
UnresolvedPlan input,
List<UnresolvedExpression> aggList,
List<UnresolvedExpression> sortList,
List<UnresolvedExpression> groupList,
UnresolvedExpression span,
List<Argument> argList) {
UnresolvedPlan input,
List<UnresolvedExpression> aggList,
List<UnresolvedExpression> sortList,
List<UnresolvedExpression> groupList,
UnresolvedExpression span,
List<Argument> argList) {
return new Aggregation(aggList, sortList, groupList, span, argList).attach(input);
}

Expand All @@ -145,7 +145,7 @@ public static QualifiedName qualifiedName(String... parts) {
}

public static UnresolvedExpression equalTo(
UnresolvedExpression left, UnresolvedExpression right) {
UnresolvedExpression left, UnresolvedExpression right) {
return new EqualTo(left, right);
}

Expand Down Expand Up @@ -226,12 +226,12 @@ public static UnresolvedExpression aggregate(String func, UnresolvedExpression f
}

public static UnresolvedExpression aggregate(
String func, UnresolvedExpression field, UnresolvedExpression... args) {
String func, UnresolvedExpression field, UnresolvedExpression... args) {
return new AggregateFunction(func, field, Arrays.asList(args));
}

public static UnresolvedExpression filteredAggregate(
String func, UnresolvedExpression field, UnresolvedExpression condition) {
String func, UnresolvedExpression field, UnresolvedExpression condition) {
return new AggregateFunction(func, field).condition(condition);
}

Expand All @@ -240,7 +240,7 @@ public static UnresolvedExpression distinctAggregate(String func, UnresolvedExpr
}

public static UnresolvedExpression filteredDistinctCount(
String func, UnresolvedExpression field, UnresolvedExpression condition) {
String func, UnresolvedExpression field, UnresolvedExpression condition) {
return new AggregateFunction(func, field, true).condition(condition);
}

Expand Down Expand Up @@ -282,7 +282,7 @@ public When when(UnresolvedExpression condition, UnresolvedExpression result) {
}

public UnresolvedExpression highlight(UnresolvedExpression fieldName,
java.util.Map<String, Literal> arguments) {
java.util.Map<String, Literal> arguments) {
return new HighlightFunction(fieldName, arguments);
}

Expand Down Expand Up @@ -314,17 +314,17 @@ public static UnresolvedExpression xor(UnresolvedExpression left, UnresolvedExpr
}

public static UnresolvedExpression in(
UnresolvedExpression field, UnresolvedExpression... valueList) {
UnresolvedExpression field, UnresolvedExpression... valueList) {
return new In(field, Arrays.asList(valueList));
}

public static UnresolvedExpression in(
UnresolvedExpression field, List<UnresolvedExpression> valueList) {
UnresolvedExpression field, List<UnresolvedExpression> valueList) {
return new In(field, valueList);
}

public static UnresolvedExpression compare(
String operator, UnresolvedExpression left, UnresolvedExpression right) {
String operator, UnresolvedExpression left, UnresolvedExpression right) {
return new Compare(operator, left, right);
}

Expand Down Expand Up @@ -403,20 +403,20 @@ public static List<Argument> defaultFieldsArgs() {
*/
public static List<Argument> defaultStatsArgs() {
return exprList(
argument("partitions", intLiteral(1)),
argument("allnum", booleanLiteral(false)),
argument("delim", stringLiteral(" ")),
argument("dedupsplit", booleanLiteral(false)));
argument("partitions", intLiteral(1)),
argument("allnum", booleanLiteral(false)),
argument("delim", stringLiteral(" ")),
argument("dedupsplit", booleanLiteral(false)));
}

/**
* Default Dedup Command Args.
*/
public static List<Argument> defaultDedupArgs() {
return exprList(
argument("number", intLiteral(1)),
argument("keepempty", booleanLiteral(false)),
argument("consecutive", booleanLiteral(false)));
argument("number", intLiteral(1)),
argument("keepempty", booleanLiteral(false)),
argument("consecutive", booleanLiteral(false)));
}

public static List<Argument> sortOptions() {
Expand Down Expand Up @@ -451,17 +451,17 @@ public static RareTopN rareTopN(UnresolvedPlan input, CommandType commandType,
List<Argument> noOfResults, List<UnresolvedExpression> groupList,
Field... fields) {
return new RareTopN(input, commandType, noOfResults, Arrays.asList(fields), groupList)
.attach(input);
.attach(input);
}

public static Limit limit(UnresolvedPlan input, Integer limit, Integer offset) {
return new Limit(limit, offset).attach(input);
}

public static Parse parse(UnresolvedPlan input, ParseMethod parseMethod,
UnresolvedExpression sourceField,
Literal pattern,
java.util.Map<String, Literal> arguments) {
UnresolvedExpression sourceField,
Literal pattern,
java.util.Map<String, Literal> arguments) {
return new Parse(parseMethod, sourceField, pattern, arguments, input);
}

Expand Down
30 changes: 15 additions & 15 deletions core/src/main/java/org/opensearch/sql/ast/expression/Cast.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,21 +43,21 @@
public class Cast extends UnresolvedExpression {

private static final Map<String, FunctionName> CONVERTED_TYPE_FUNCTION_NAME_MAP =
new ImmutableMap.Builder<String, FunctionName>()
.put("string", CAST_TO_STRING.getName())
.put("byte", CAST_TO_BYTE.getName())
.put("short", CAST_TO_SHORT.getName())
.put("int", CAST_TO_INT.getName())
.put("integer", CAST_TO_INT.getName())
.put("long", CAST_TO_LONG.getName())
.put("float", CAST_TO_FLOAT.getName())
.put("double", CAST_TO_DOUBLE.getName())
.put("boolean", CAST_TO_BOOLEAN.getName())
.put("date", CAST_TO_DATE.getName())
.put("time", CAST_TO_TIME.getName())
.put("timestamp", CAST_TO_TIMESTAMP.getName())
.put("datetime", CAST_TO_DATETIME.getName())
.build();
new ImmutableMap.Builder<String, FunctionName>()
.put("string", CAST_TO_STRING.getName())
.put("byte", CAST_TO_BYTE.getName())
.put("short", CAST_TO_SHORT.getName())
.put("int", CAST_TO_INT.getName())
.put("integer", CAST_TO_INT.getName())
.put("long", CAST_TO_LONG.getName())
.put("float", CAST_TO_FLOAT.getName())
.put("double", CAST_TO_DOUBLE.getName())
.put("boolean", CAST_TO_BOOLEAN.getName())
.put("date", CAST_TO_DATE.getName())
.put("time", CAST_TO_TIME.getName())
.put("timestamp", CAST_TO_TIMESTAMP.getName())
.put("datetime", CAST_TO_DATETIME.getName())
.build();

/**
* The source expression cast from.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ public <R, C> R accept(AbstractNodeVisitor<R, C> nodeVisitor, C context) {
@Override
public String toString() {
return String.format("%s(%s)", funcName,
funcArgs.stream()
.map(Object::toString)
.collect(Collectors.joining(", ")));
funcArgs.stream()
.map(Object::toString)
.collect(Collectors.joining(", ")));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ public enum IntervalUnit {
*/
public static IntervalUnit of(String unit) {
return INTERVAL_UNITS.stream()
.filter(v -> unit.equalsIgnoreCase(v.name()))
.findFirst()
.orElse(IntervalUnit.UNKNOWN);
.filter(v -> unit.equalsIgnoreCase(v.name()))
.findFirst()
.orElse(IntervalUnit.UNKNOWN);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ public <R, C> R accept(AbstractNodeVisitor<R, C> nodeVisitor, C context) {
@Override
public String toString() {
return fieldList
.entrySet()
.stream()
.map(e -> String.format("\"%s\" ^ %s", e.getKey(), e.getValue()))
.collect(Collectors.joining(", "));
.entrySet()
.stream()
.map(e -> String.format("\"%s\" ^ %s", e.getKey(), e.getValue()))
.collect(Collectors.joining(", "));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ public static SpanUnit of(String unit) {
return m;
default:
return SPAN_UNITS.stream()
.filter(v -> unit.equalsIgnoreCase(v.name()))
.findFirst()
.orElse(UNKNOWN);
.filter(v -> unit.equalsIgnoreCase(v.name()))
.findFirst()
.orElse(UNKNOWN);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,3 @@ public enum CommandType {
RARE
}
}

4 changes: 2 additions & 2 deletions core/src/main/java/org/opensearch/sql/ast/tree/Relation.java
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ public QualifiedName getTableQualifiedName() {
return (QualifiedName) tableName.get(0);
} else {
return new QualifiedName(tableName.stream()
.map(UnresolvedExpression::toString)
.collect(Collectors.joining(COMMA)));
.map(UnresolvedExpression::toString)
.collect(Collectors.joining(COMMA)));
}
}

Expand Down

0 comments on commit 9381892

Please sign in to comment.