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

Major issue with predicate constant decoding that causes incorrect results from many queries #5

Open
carlaustin opened this issue Apr 11, 2014 · 2 comments

Comments

@carlaustin
Copy link

The base64 encoded constant (128 in this case) used when doing something like WHERE field > 128, when decoded, is read into a string of which the bytes are retrieved as per the code below. This unfortunately causes the constant to read as the wrong number in a number of cases.

PrimitiveComparisonFilter:

        String b64Const = options.get(CONST_VAL);
        String constStr = new String(Base64.decodeBase64(b64Const.getBytes()));
        byte [] constant = constStr.getBytes();

For example, doing > 128, 128 is encoded correctly but then when decoding in this manner the number is being read as 239 and thus obviously the statement doesn't return rows with a value between 128 and 239, a serious issue. The fix is to change the code to:

        String b64Const = options.get(CONST_VAL);
        byte [] constant = Base64.decodeBase64(b64Const.getBytes());

as there is no need to wrap the byte array in a string just to get it back again (which causes the issue).

@bfemiano
Copy link
Owner

Thank you for this. I will integrate back into trunk.

@joshelser
Copy link

Just fixed this in the code that's destined to make it into Hive

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

No branches or pull requests

3 participants