-
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
Do not allow implicit cast for BOOLEAN and TIMESTAMP #9385
Conversation
1efcfb8
to
635cda0
Compare
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.
looks good to me overall. several questions
- is this backward incompatible, should we add release note?
- can we write a detail rules on what implicit type case are supported and what are not. from my understanding it is now it only support between any number types, yes?
@@ -43,6 +43,7 @@ private DataTypeConversionFunctions() { | |||
public static Object cast(Object value, String targetTypeLiteral) { | |||
try { | |||
Class<?> clazz = value.getClass(); | |||
// TODO: Support cast for MV |
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.
did you meant element-wise? how would the semantic work?
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.
Yes. It is supported in the transform function, but not in the scalar function
testFetchStringValues(INT_COLUMN); | ||
testFetchStringValues(LONG_COLUMN); | ||
testFetchStringValues(FLOAT_COLUMN); | ||
testFetchStringValues(DOUBLE_COLUMN); | ||
testFetchStringValues(BIG_DECIMAL_COLUMN); | ||
testFetchStringValues(STRING_COLUMN); | ||
testFetchStringValues(NO_DICT_INT_COLUMN); | ||
testFetchStringValues(NO_DICT_LONG_COLUMN); | ||
testFetchStringValues(NO_DICT_FLOAT_COLUMN); | ||
testFetchStringValues(NO_DICT_DOUBLE_COLUMN); | ||
testFetchStringValues(NO_DICT_BIG_DECIMAL_COLUMN); |
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.
I understand implicit type cast from STRING to NUMBER is not a good practice. but do we want to support the otherway around?
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.
I don't think implicit type cast from other type to STRING is good practice either, and we have observed performance regression doing it in #9287
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.
sounds good. good to add release note and backward incompatible tags to explain
import static org.testng.Assert.assertNull; | ||
import static org.testng.Assert.assertThrows; | ||
import static org.testng.Assert.assertTrue; | ||
import static org.testng.Assert.*; |
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.
import Assert instead of star import?
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.
We usually import Assert.*
in test to simplify the code
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.
lgtm mostly.
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.
Is there any reference available that talks about the restriction on implicit cast between them? If yes, can you link it to the description section of this PR?
We might need to carefully monitor the deployment in order to detect any existing use cases once this PR is merged.
yes I was suggesting either a release note or a backward incompatible section in the PR but also in Pinot doc. In terms of the rationale, AFAIK,
so IMO as long as we state clearly in our user-facing implicit cast rule in doc we are good. I am incline to the following:
|
@walterddr @jackjlli Seems different DB have different implicit conversion behavior between number and string: Let me see if we can support it without paying too much overhead |
635cda0
to
76ba24f
Compare
After some discussion, decided to keep the existing supported conversions, but revert the new added #9287 which causes the performance regression. |
Codecov Report
@@ Coverage Diff @@
## master #9385 +/- ##
============================================
+ Coverage 69.73% 69.76% +0.03%
+ Complexity 5093 4792 -301
============================================
Files 1890 1890
Lines 100754 100858 +104
Branches 15350 15333 -17
============================================
+ Hits 70259 70365 +106
- Misses 25499 25522 +23
+ Partials 4996 4971 -25
Flags with carried forward coverage won't be shown. Click here to find out more.
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
76ba24f
to
ef1a234
Compare
We have observed performance regression after #9287 where we try to support implicit conversion from
BOOLEAN
andTIMESTAMP
toSTRING
. Several implicit conversions toBOOLEAN
andTIMESTAMP
is still not supported.This PR removes the implicit conversion support for
BOOLEAN
andTIMESTAMP
, and enhancesCAST
function to support all explicit conversions. It also includes several bugfixes and cleanups related to type conversion.To fully support implicit conversion for
BOOLEAN
andTIMESTAMP
without big overhead, we need to add read APIs for them (similar to how we handleBIG_DECIMAL
. We will address that separately.Release Notes
Implicit conversion from/to
BOOLEAN
andTIMESTAMP
is not supported. The conversion can be done explicitly withCAST
transform function