-
Notifications
You must be signed in to change notification settings - Fork 1k
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
fix: ensure null values cast to varchar/string remain null #5769
fix: ensure null values cast to varchar/string remain null #5769
Conversation
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.
The fix LGTM, but I think it's backwards incompatible.
@@ -932,7 +933,7 @@ private CastVisitor() { | |||
final int scale = decimal.getScale(); | |||
exprStr = String.format("DecimalUtil.format(%d, %d, %s)", precision, scale, expr.getLeft()); | |||
} else { | |||
exprStr = "String.valueOf(" + expr.getLeft() + ")"; | |||
exprStr = "Objects.toString(" + expr.getLeft() + ", null)"; |
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.
looking at the plan.json
that was generated from the test, I'm not sure this is backwards compatible - unless I'm missing something, we don't add the generated java code to the plan that we enqueue (cc @rodesai to comment on whether or not including that might be a good idea). That would mean that we would be changing any existing query to have this behavior.
we should consider whether this backwards incompatible change is acceptable or if we should guard this with a config that defaults to disabled, but any new query would have it enabled
e0c79f4
to
66c34ac
Compare
e8a5cbe
to
2a4c54d
Compare
2a4c54d
to
728f4b4
Compare
Added a config for preserving old query behavior.
|
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! Only nit is that I don't love the config name, it's a little cryptic
ksqldb-common/src/main/java/io/confluent/ksql/util/KsqlConfig.java
Outdated
Show resolved
Hide resolved
a38bfc8
to
02a7098
Compare
Description
Fixes #4892
String.valueOf() will return the string "null" when a null value is passed in. Using Object.toString(obj, defaultValue) allows the null value to be returned when a null is passed in https://docs.oracle.com/javase/8/docs/api/java/util/Objects.html#toString-java.lang.Object-java.lang.String-
Testing done
Tested the scenario described in the ticket
Added new QTT case
Reviewer checklist