-
Notifications
You must be signed in to change notification settings - Fork 1.5k
[multistage] Support TIMESTAMP type and date ops functions #11350
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
Changes from all commits
84d731f
8c9ad60
c9e4c1b
494f6a1
c82697e
a386ac2
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 |
|---|---|---|
|
|
@@ -353,7 +353,10 @@ public Serializable convert(Object value) { | |
| case BOOLEAN: | ||
| return ((Number) value).intValue() == 1; | ||
| case TIMESTAMP: | ||
| return new Timestamp((long) value); | ||
| if (value instanceof Timestamp) { | ||
|
||
| return (Timestamp) value; | ||
| } | ||
| return new Timestamp(((Number) value).longValue()); | ||
| case STRING: | ||
| case JSON: | ||
| return value.toString(); | ||
|
|
@@ -416,8 +419,14 @@ public Serializable convertAndFormat(Object value) { | |
| case BIG_DECIMAL: | ||
| return (BigDecimal) value; | ||
| case BOOLEAN: | ||
| if (value instanceof Boolean) { | ||
| return (boolean) value; | ||
xiangfu0 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
| return ((Number) value).intValue() == 1; | ||
| case TIMESTAMP: | ||
| if (value instanceof Timestamp) { | ||
| return value.toString(); | ||
| } | ||
| return new Timestamp((long) value).toString(); | ||
| case STRING: | ||
| case JSON: | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -148,10 +148,19 @@ public static RowDataBlock buildFromRows(List<Object[]> rows, DataSchema dataSch | |
| setColumn(rowBuilder, byteBuffer, (BigDecimal) value); | ||
| break; | ||
| case BOOLEAN: | ||
| byteBuffer.putInt(((Boolean) value) ? 1 : 0); | ||
| if (value instanceof Boolean) { | ||
| byteBuffer.putInt(((Boolean) value) ? 1 : 0); | ||
| } else { | ||
| byteBuffer.putInt(((Number) value).intValue() > 0 ? 1 : 0); | ||
| } | ||
| break; | ||
| case TIMESTAMP: | ||
| byteBuffer.putLong(((Timestamp) value).getTime()); | ||
| // Certain non strong typed functions in v2 might return long value instead of Timestamp. | ||
| if (value instanceof Long) { | ||
|
||
| byteBuffer.putLong((long) value); | ||
| } else { | ||
| byteBuffer.putLong(((Timestamp) value).getTime()); | ||
| } | ||
| break; | ||
| case STRING: | ||
| setColumn(rowBuilder, byteBuffer, (String) value); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -117,10 +117,18 @@ public void init(List<TransformFunction> arguments, Map<String, ColumnContext> c | |
| parameterTypes[i].convert(literalTransformFunction.getDoubleLiteral(), PinotDataType.DOUBLE); | ||
| break; | ||
| case BIG_DECIMAL: | ||
| if (parameterTypes[i] == PinotDataType.STRING) { | ||
| _scalarArguments[i] = literalTransformFunction.getStringLiteral(); | ||
| break; | ||
| } | ||
| _scalarArguments[i] = | ||
| parameterTypes[i].convert(literalTransformFunction.getBigDecimalLiteral(), PinotDataType.BIG_DECIMAL); | ||
| break; | ||
| case TIMESTAMP: | ||
| if (parameterTypes[i] == PinotDataType.STRING) { | ||
|
||
| _scalarArguments[i] = literalTransformFunction.getStringLiteral(); | ||
| break; | ||
| } | ||
| _scalarArguments[i] = | ||
| parameterTypes[i].convert(literalTransformFunction.getLongLiteral(), PinotDataType.TIMESTAMP); | ||
| break; | ||
|
|
||
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 add a TODO to auto generate signature for scalar function. We should not manually add this for scalar function