-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
[multistage] Support TIMESTAMP type and date ops functions #11350
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) { | ||
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. Does this still apply? Ideally we should always have internal format value. If we break that contract, |
||
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.
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) { | ||
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. Are we going to hit both? If so, can you add some java doc explaining when will we hit both? If we can hit both, then 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. Certain non strong typed functions in v2 might return long value then in datablock build, we need to do the conversion. |
||
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) { | ||
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 feel this applies to all data types 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. For other data types, only BIG_DECIMAL is the inferable type. So just need to add support for that. |
||
_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