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

from_base64 Presto function isn't decoding the input when the input isn't padded. #8646

Closed
Joe-Abraham opened this issue Feb 2, 2024 · 4 comments
Labels
bug Something isn't working triage Newly created issue that needs attention.

Comments

@Joe-Abraham
Copy link
Contributor

Bug description

Added these test case without padding at velox/functions/prestosql/tests/BinaryFunctionsTest.cpp in TEST_F(BinaryFunctionsTest, fromBase64)

  EXPECT_EQ("a", fromBase64("YQ"));
  EXPECT_EQ("ab", fromBase64("YWI"));
  EXPECT_EQ("abcd", fromBase64("YWJjZA"));

Got the below error when the above test case ran.

[ RUN      ] BinaryFunctionsTest.fromBase64
unknown file: Failure
C++ exception with description "Exception: VeloxUserError
Error Source: USER
Error Code: INVALID_ARGUMENT
Reason: Base64::decode() - invalid input string: string length is not multiple of 4.
Retriable: False
Context: from_base64(c0)
Top-Level Context: Same as context.
Function: call
File: /Users/joe/Developer/velox/./velox/functions/prestosql/BinaryFunctions.h
Line: 297
Stack trace:
Stack trace has been disabled. Use --velox_exception_user_stacktrace_enabled=true to enable it.
" thrown in the test body.
[  FAILED  ] BinaryFunctionsTest.fromBase64 (8 ms)

System information

Velox System Info v0.0.2
Commit: 3004e34
CMake Version: 3.27.8
System: Darwin-23.3.0
Arch: arm64
C++ Compiler: /Library/Developer/CommandLineTools/usr/bin/c++
C++ Compiler Version: 15.0.0.15000100
C Compiler: /Library/Developer/CommandLineTools/usr/bin/cc
C Compiler Version: 15.0.0.15000100
CMake Prefix Path: /Library/Developer/CommandLineTools/SDKs/MacOSX14.2.sdk/usr;/opt/homebrew;/usr/local;/usr;/;/opt/homebrew/Cellar/cmake/3.27.8;/usr/local;/usr/X11R6;/usr/pkg;/opt;/sw;/opt/local

Relevant logs

No response

@Joe-Abraham Joe-Abraham added bug Something isn't working triage Newly created issue that needs attention. labels Feb 2, 2024
@kgpai
Copy link
Contributor

kgpai commented Feb 8, 2024

@Joe-Abraham - Can you confirm whether this behavior is different from Presto java ?

@Joe-Abraham
Copy link
Contributor Author

Joe-Abraham commented Feb 9, 2024

@kgpai wrote a quick test in Presto Java and tested the code below, which is passing successfully. I couldn't find any existing UTs to run.

public class TestBase64
{
    @Test
    public void testDecodeBase64()
    {
        assertEquals(new String(Base64.getDecoder().decode("YQ"), UTF_8), "a");
        assertEquals(new String(Base64.getDecoder().decode("YQ=="), UTF_8), "a");
        assertEquals(new String(Base64.getDecoder().decode("YWI"), UTF_8), "ab");
        assertEquals(new String(Base64.getDecoder().decode("YWI="), UTF_8), "ab");
        assertEquals(new String(Base64.getDecoder().decode("YWJjZA"), UTF_8), "abcd");
    }
}

@aditi-pandit aditi-pandit changed the title Presto function 'from_base64' isn't decoding the input when the input isn't padded. [Native] 'from_base64' isn't decoding the input when the input isn't padded. Mar 5, 2024
@mbasmanova
Copy link
Contributor

@Joe-Abraham Would you like to send a PR to fix this?

@mbasmanova mbasmanova changed the title [Native] 'from_base64' isn't decoding the input when the input isn't padded. from_base64 Presto function isn't decoding the input when the input isn't padded. Mar 13, 2024
@Joe-Abraham
Copy link
Contributor Author

@mbasmanova I have raised a PR for the same #8647.

Joe-Abraham added a commit to Joe-Abraham/velox that referenced this issue May 8, 2024
…ncubator#8647)

Summary:
Fixes facebookincubator#8646

Pull Request resolved: facebookincubator#8647

Reviewed By: amitkdutta, DanielMunozT

Differential Revision: D56792399

Pulled By: bikramSingh91

fbshipit-source-id: 212acce56c0dd708e1220e229e1943380d4d976b
Joe-Abraham added a commit to Joe-Abraham/velox that referenced this issue Jun 7, 2024
…ncubator#8647)

Summary:
Fixes facebookincubator#8646

Pull Request resolved: facebookincubator#8647

Reviewed By: amitkdutta, DanielMunozT

Differential Revision: D56792399

Pulled By: bikramSingh91

fbshipit-source-id: 212acce56c0dd708e1220e229e1943380d4d976b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working triage Newly created issue that needs attention.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants