Skip to content

Commit

Permalink
apacheGH-41433: [C++][Gandiva] Fix ascii_utf8 function to return same…
Browse files Browse the repository at this point in the history
… result on x86 and Arm (apache#41434)

Fixing ascii_utf8 function that has different return result on x86 and Arm due to default char type sign difference on those platforms. Added tests to cover existing x86 behavior for ascii symbols with code >127.

1. Added type cast to signed char to save existing x86 behavior on Arm platform.
2. Added tests cases for negative results.

UT included.

None

* GitHub Issue: apache#41433

Authored-by: DenisTarasyuk <[email protected]>
Signed-off-by: Sutou Kouhei <[email protected]>
  • Loading branch information
DenisTarasyuk committed Oct 2, 2024
1 parent 0924124 commit 5ec7493
Show file tree
Hide file tree
Showing 10 changed files with 14 additions and 12 deletions.
2 changes: 1 addition & 1 deletion cpp/src/gandiva/precompiled/string_ops.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1377,7 +1377,7 @@ gdv_int32 ascii_utf8(const char* data, gdv_int32 data_len) {
if (data_len == 0) {
return 0;
}
return static_cast<gdv_int32>(data[0]);
return static_cast<gdv_int32>(static_cast<signed char>(data[0]));
}

// Returns the ASCII character having the binary equivalent to A.
Expand Down
2 changes: 2 additions & 0 deletions cpp/src/gandiva/precompiled/string_ops_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ TEST(TestStringOps, TestAscii) {
EXPECT_EQ(ascii_utf8("", 0), 0);
EXPECT_EQ(ascii_utf8("123", 3), 49);
EXPECT_EQ(ascii_utf8("999", 3), 57);
EXPECT_EQ(ascii_utf8("\x80", 1), -128);
EXPECT_EQ(ascii_utf8("\xFF", 1), -1);
}

TEST(TestStringOps, TestChrBigInt) {
Expand Down
2 changes: 1 addition & 1 deletion dev/tasks/docker-tests/github.linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ jobs:
done
- name: Save the R test output
if: always()
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: test-output
path: arrow/r/check/arrow.Rcheck/tests/testthat.Rout*
Expand Down
6 changes: 3 additions & 3 deletions dev/tasks/java-jars/github.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ jobs:
- name: Compress into single artifact to keep directory structure
run: tar -cvzf arrow-shared-libs-linux-{{ arch }}.tar.gz arrow/java-dist/
- name: Upload artifacts
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: ubuntu-shared-lib-{{ arch }}
path: arrow-shared-libs-linux-{{ arch }}.tar.gz
Expand Down Expand Up @@ -154,7 +154,7 @@ jobs:
- name: Compress into single artifact to keep directory structure
run: tar -cvzf arrow-shared-libs-macos-{{ arch }}.tar.gz arrow/java-dist/
- name: Upload artifacts
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: macos-shared-lib-{{ arch }}
path: arrow-shared-libs-macos-{{ arch }}.tar.gz
Expand Down Expand Up @@ -188,7 +188,7 @@ jobs:
shell: bash
run: tar -cvzf arrow-shared-libs-windows.tar.gz arrow/java-dist/
- name: Upload artifacts
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: windows-shared-lib
path: arrow-shared-libs-windows.tar.gz
Expand Down
2 changes: 1 addition & 1 deletion dev/tasks/r/github.devdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ jobs:
EOF
shell: bash -l {0}
- name: Save the install script
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: {{ "devdocs-script_os-${{ matrix.os }}_sysinstall-${{ matrix.system-install }}" }}
path: arrow/r/vignettes/developers/script.sh
Expand Down
2 changes: 1 addition & 1 deletion dev/tasks/r/github.linux.arrow.version.back.compat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ jobs:
shell: bash

- name: Upload the parquet artifacts
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: files
path: arrow/r/extra-tests/files
Expand Down
2 changes: 1 addition & 1 deletion dev/tasks/r/github.linux.cran.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ jobs:
if: always()
- name: Save the test output
if: always()
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: test-output
path: arrow/r/check/arrow.Rcheck/tests/testthat.Rout*
4 changes: 2 additions & 2 deletions dev/tasks/r/github.linux.offline.build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
R -e "source('R/install-arrow.R'); create_package_with_all_dependencies(dest_file = 'arrow_with_deps.tar.gz', source_file = \"${built_tar}\")"
shell: bash
- name: Upload the third party dependency artifacts
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: thirdparty_deps
path: arrow/r/arrow_with_deps.tar.gz
Expand Down Expand Up @@ -91,7 +91,7 @@ jobs:
run: cat arrow-tests/testthat.Rout*
if: always()
- name: Save the test output
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: test-output
path: arrow-tests/testthat.Rout*
Expand Down
2 changes: 1 addition & 1 deletion dev/tasks/r/github.linux.versions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ jobs:
if: always()
- name: Save the test output
if: always()
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: test-output
path: arrow/r/check/arrow.Rcheck/tests/testthat.Rout*
2 changes: 1 addition & 1 deletion dev/tasks/r/github.macos-linux.local.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ jobs:
run: cat arrow-tests/testthat.Rout*
if: failure()
- name: Save the test output
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: test-output
path: arrow-tests/testthat.Rout*
Expand Down

0 comments on commit 5ec7493

Please sign in to comment.