Jackie-Jiang commented on a change in pull request #6728:
URL: https://github.com/apache/incubator-pinot/pull/6728#discussion_r605136714
##########
File path:
pinot-common/src/main/java/org/apache/pinot/common/utils/request/RequestUtils.java
##########
@@ -127,62 +126,41 @@ public static Expression createNewLiteralExpression() {
return expression;
}
- public static Expression getLiteralExpression(String value) {
+ public static Expression getLiteralExpression(long value) {
Expression expression = createNewLiteralExpression();
- expression.getLiteral().setStringValue(value);
+ expression.getLiteral().setLongValue(value);
return expression;
}
- public static Expression getLiteralExpression(byte[] value) {
+ public static Expression getLiteralExpression(double value) {
Expression expression = createNewLiteralExpression();
- expression.getLiteral().setStringValue(BytesUtils.toHexString(value));
+ expression.getLiteral().setDoubleValue(value);
return expression;
}
- public static Expression getLiteralExpression(Integer value) {
- return getLiteralExpression(value.longValue());
- }
-
- public static Expression getLiteralExpression(Long value) {
+ public static Expression getLiteralExpression(String value) {
Expression expression = createNewLiteralExpression();
- expression.getLiteral().setLongValue(value);
+ expression.getLiteral().setStringValue(value);
return expression;
}
- public static Expression getLiteralExpression(Float value) {
- return getLiteralExpression(value.doubleValue());
- }
-
- public static Expression getLiteralExpression(Double value) {
+ public static Expression getLiteralExpression(byte[] value) {
Expression expression = createNewLiteralExpression();
- expression.getLiteral().setDoubleValue(value);
+ expression.getLiteral().setStringValue(BytesUtils.toHexString(value));
return expression;
}
public static Expression getLiteralExpression(Object object) {
- if (object instanceof Integer) {
- return RequestUtils.getLiteralExpression((Integer) object);
- }
- if (object instanceof Long) {
- return RequestUtils.getLiteralExpression((Long) object);
- }
- if (object instanceof Float) {
- return RequestUtils.getLiteralExpression((Float) object);
- }
- if (object instanceof Double) {
- return RequestUtils.getLiteralExpression((Double) object);
- }
- if (object instanceof String) {
- return RequestUtils.getLiteralExpression((String) object);
+ if (object instanceof Integer || object instanceof Long) {
+ return RequestUtils.getLiteralExpression(((Number) object).longValue());
}
- if (object instanceof SqlLiteral) {
- return RequestUtils.getLiteralExpression((SqlLiteral) object);
+ if (object instanceof Float || object instanceof Double) {
+ return RequestUtils.getLiteralExpression(((Number)
object).doubleValue());
}
if (object instanceof byte[]) {
return RequestUtils.getLiteralExpression((byte[]) object);
}
- throw new SqlCompilationException(
Review comment:
We want to handle all other types as string. The input could be of other
data types, e.g. `boolean` etc.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]