Skip to content
This repository was archived by the owner on Aug 2, 2022. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,7 @@ public Expression visitEqualTo(EqualTo node, AnalysisContext context) {

@Override
public Expression visitLiteral(Literal node, AnalysisContext context) {
return DSL
.literal(ExprValueUtils.fromObjectValue(node.getValue(), node.getType().getCoreType()));
return DSL.literal(ExprValueUtils.fromObjectValue(node.getValue()));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,18 +123,6 @@ public static Literal intLiteral(Integer value) {
return literal(value, DataType.INTEGER);
}

public static Literal dateLiteral(String value) {
return literal(value, DataType.DATE);
}

public static Literal timeLiteral(String value) {
return literal(value, DataType.TIME);
}

public static Literal timestampLiteral(String value) {
return literal(value, DataType.TIMESTAMP);
}

public static Literal doubleLiteral(Double value) {
return literal(value, DataType.DOUBLE);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,28 +15,12 @@

package com.amazon.opendistroforelasticsearch.sql.ast.expression;

import com.amazon.opendistroforelasticsearch.sql.data.type.ExprCoreType;
import lombok.Getter;
import lombok.RequiredArgsConstructor;

/**
* The DataType defintion in AST.
* Question, could we use {@link ExprCoreType} directly in AST?
*/
@RequiredArgsConstructor
public enum DataType {
TYPE_ERROR(ExprCoreType.UNKNOWN),
NULL(ExprCoreType.UNKNOWN),

INTEGER(ExprCoreType.INTEGER),
DOUBLE(ExprCoreType.DOUBLE),
STRING(ExprCoreType.STRING),
BOOLEAN(ExprCoreType.BOOLEAN),

DATE(ExprCoreType.DATE),
TIME(ExprCoreType.TIME),
TIMESTAMP(ExprCoreType.TIMESTAMP);
TYPE_ERROR,
NULL,

@Getter
private final ExprCoreType coreType;
INTEGER,
DOUBLE,
STRING,
BOOLEAN
}

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import com.amazon.opendistroforelasticsearch.sql.data.type.ExprCoreType;
import com.amazon.opendistroforelasticsearch.sql.exception.ExpressionEvaluationException;
import com.google.common.annotations.VisibleForTesting;
import java.time.ZonedDateTime;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
Expand Down Expand Up @@ -118,22 +117,6 @@ public static ExprValue fromObjectValue(Object o) {
}
}

/**
* Construct ExprValue from Object with ExprCoreType.
*/
public static ExprValue fromObjectValue(Object o, ExprCoreType type) {
switch (type) {
case TIMESTAMP:
return new ExprTimestampValue((String)o);
case DATE:
return new ExprDateValue((String)o);
case TIME:
return new ExprTimeValue((String)o);
default:
return fromObjectValue(o);
}
}

public static Integer getIntegerValue(ExprValue exprValue) {
return getNumberValue(exprValue).intValue();
}
Expand Down Expand Up @@ -166,19 +149,6 @@ public static Boolean getBooleanValue(ExprValue exprValue) {
return convert(exprValue, BOOLEAN);
}

/**
* Get {@link ZonedDateTime} from ExprValue of Date type.
*/
public static ZonedDateTime getDateValue(ExprValue exprValue) {
if (ExprCoreType.DATE == exprValue.type()) {
return ((ExprDateValue) exprValue).getDate();
} else {
throw new ExpressionEvaluationException(
String.format("invalid to convert expression with type:%s to type:%s", exprValue.type(),
ExprCoreType.DATE));
}
}

/**
* Get Number Value from {@link ExprValue}.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,6 @@ public FunctionExpression multiply(Expression... expressions) {
repository.compile(BuiltinFunctionName.MULTIPLY.getName(), Arrays.asList(expressions));
}

public FunctionExpression dayofmonth(Expression... expressions) {
return (FunctionExpression)
repository.compile(BuiltinFunctionName.DAYOFMONTH.getName(), Arrays.asList(expressions));
}

public FunctionExpression divide(Expression... expressions) {
return (FunctionExpression)
repository.compile(BuiltinFunctionName.DIVIDE.getName(), Arrays.asList(expressions));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

import com.amazon.opendistroforelasticsearch.sql.expression.DSL;
import com.amazon.opendistroforelasticsearch.sql.expression.aggregation.AggregatorFunction;
import com.amazon.opendistroforelasticsearch.sql.expression.datetime.DateTimeFunction;
import com.amazon.opendistroforelasticsearch.sql.expression.function.BuiltinFunctionRepository;
import com.amazon.opendistroforelasticsearch.sql.expression.operator.arthmetic.ArithmeticFunction;
import com.amazon.opendistroforelasticsearch.sql.expression.operator.arthmetic.UnaryFunction;
Expand All @@ -44,7 +43,6 @@ public BuiltinFunctionRepository functionRepository() {
UnaryFunction.register(builtinFunctionRepository);
UnaryPredicateOperator.register(builtinFunctionRepository);
AggregatorFunction.register(builtinFunctionRepository);
DateTimeFunction.register(builtinFunctionRepository);
return builtinFunctionRepository;
}

Expand Down
Loading