-
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
PHOENIX-7424 Support toStringBinary/toBytesBinary conversion #2020
base: master
Are you sure you want to change the base?
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.
Apart from using the wrong names, the functionality looks good.
...x-core-client/src/main/java/org/apache/phoenix/expression/function/DecodeBinaryFunction.java
Show resolved
Hide resolved
@FunctionParseNode.BuiltInFunction(name = EncodeBinaryFunction.NAME, args = { | ||
@FunctionParseNode.Argument(allowedTypes = {PVarchar.class}), | ||
@FunctionParseNode.Argument(enumeration = "EncodeFormat")}) | ||
public class EncodeBinaryFunction extends ScalarFunction { |
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.
This is derived from and backward compatible with DecodeFunction.
(After fixing the names) instead of duplicating the code, they should share the same code via inheritance.
Adding the new functionality to the existing DECODE function does not break functionality, so DECODE and DECODE_BINARY should be basically aliases to each other.
(Unless the annotations somehow prevent inheritance from working properly)
501e459
to
88a1498
Compare
@@ -22,5 +22,6 @@ public enum EncodeFormat { | |||
HEX, //format for encoding HEX value to bytes | |||
BASE62, //format for encoding a base 10 long value to base 62 string | |||
BASE64, //format for encoding a base 10 long value to base 64 string | |||
ASCII // Plain Text | |||
ASCII, //Plain Text | |||
HBASE //HBase-specific binary encoding format |
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.
nit: this is more of an escaping format than encoding.
@FunctionParseNode.BuiltInFunction(name = DecodeBinaryFunction.NAME, args = { | ||
@FunctionParseNode.Argument(allowedTypes = {PVarchar.class}), | ||
@FunctionParseNode.Argument(enumeration = "EncodeFormat")}) | ||
public class DecodeBinaryFunction extends DecodeFunction { |
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.
This leaves us with a less capable DECODE() function, and the more capable DECODE_BINARY() function.
Since we are only extending the functionality, we could use the exact same implementation, adding more features to DECODE() is not a problem.
The only reason we are adding new functions at all is the "interesting" existing ENCODE() function.
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.
Technically, we do not even need the new DECODE_BINARY function, we are only adding it so that the encoding/decoding functions have intuitive names.
No description provided.