Skip to content
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

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

szucsvillo
Copy link
Contributor

No description provided.

@szucsvillo szucsvillo marked this pull request as draft October 29, 2024 14:32
Copy link
Contributor

@stoty stoty left a 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.

@FunctionParseNode.BuiltInFunction(name = EncodeBinaryFunction.NAME, args = {
@FunctionParseNode.Argument(allowedTypes = {PVarchar.class}),
@FunctionParseNode.Argument(enumeration = "EncodeFormat")})
public class EncodeBinaryFunction extends ScalarFunction {
Copy link
Contributor

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)

@@ -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
Copy link
Contributor

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 {
Copy link
Contributor

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.

Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants