Skip to content

Commit 67a7751

Browse files
committed
apacheGH-41433: [C++][Gandiva] Fix ascii_utf8 function to return same 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 <denis.tarasyuk@dremio.com> Signed-off-by: Sutou Kouhei <kou@clear-code.com>
1 parent 0924124 commit 67a7751

10 files changed

Lines changed: 14 additions & 12 deletions

cpp/src/gandiva/precompiled/string_ops.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1377,7 +1377,7 @@ gdv_int32 ascii_utf8(const char* data, gdv_int32 data_len) {
13771377
if (data_len == 0) {
13781378
return 0;
13791379
}
1380-
return static_cast<gdv_int32>(data[0]);
1380+
return static_cast<gdv_int32>(static_cast<signed char>(data[0]));
13811381
}
13821382

13831383
// Returns the ASCII character having the binary equivalent to A.

cpp/src/gandiva/precompiled/string_ops_test.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ TEST(TestStringOps, TestAscii) {
5151
EXPECT_EQ(ascii_utf8("", 0), 0);
5252
EXPECT_EQ(ascii_utf8("123", 3), 49);
5353
EXPECT_EQ(ascii_utf8("999", 3), 57);
54+
EXPECT_EQ(ascii_utf8("\x80", 1), -128);
55+
EXPECT_EQ(ascii_utf8("\xFF", 1), -1);
5456
}
5557

5658
TEST(TestStringOps, TestChrBigInt) {

dev/tasks/docker-tests/github.linux.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ jobs:
6161
done
6262
- name: Save the R test output
6363
if: always()
64-
uses: actions/upload-artifact@v2
64+
uses: actions/upload-artifact@v3
6565
with:
6666
name: test-output
6767
path: arrow/r/check/arrow.Rcheck/tests/testthat.Rout*

dev/tasks/java-jars/github.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ jobs:
7474
- name: Compress into single artifact to keep directory structure
7575
run: tar -cvzf arrow-shared-libs-linux-{{ arch }}.tar.gz arrow/java-dist/
7676
- name: Upload artifacts
77-
uses: actions/upload-artifact@v2
77+
uses: actions/upload-artifact@v3
7878
with:
7979
name: ubuntu-shared-lib-{{ arch }}
8080
path: arrow-shared-libs-linux-{{ arch }}.tar.gz
@@ -154,7 +154,7 @@ jobs:
154154
- name: Compress into single artifact to keep directory structure
155155
run: tar -cvzf arrow-shared-libs-macos-{{ arch }}.tar.gz arrow/java-dist/
156156
- name: Upload artifacts
157-
uses: actions/upload-artifact@v2
157+
uses: actions/upload-artifact@v3
158158
with:
159159
name: macos-shared-lib-{{ arch }}
160160
path: arrow-shared-libs-macos-{{ arch }}.tar.gz
@@ -188,7 +188,7 @@ jobs:
188188
shell: bash
189189
run: tar -cvzf arrow-shared-libs-windows.tar.gz arrow/java-dist/
190190
- name: Upload artifacts
191-
uses: actions/upload-artifact@v2
191+
uses: actions/upload-artifact@v3
192192
with:
193193
name: windows-shared-lib
194194
path: arrow-shared-libs-windows.tar.gz

dev/tasks/r/github.devdocs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ jobs:
6868
EOF
6969
shell: bash -l {0}
7070
- name: Save the install script
71-
uses: actions/upload-artifact@v2
71+
uses: actions/upload-artifact@v3
7272
with:
7373
name: {{ "devdocs-script_os-${{ matrix.os }}_sysinstall-${{ matrix.system-install }}" }}
7474
path: arrow/r/vignettes/developers/script.sh

dev/tasks/r/github.linux.arrow.version.back.compat.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ jobs:
5858
shell: bash
5959

6060
- name: Upload the parquet artifacts
61-
uses: actions/upload-artifact@v2
61+
uses: actions/upload-artifact@v3
6262
with:
6363
name: files
6464
path: arrow/r/extra-tests/files

dev/tasks/r/github.linux.cran.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ jobs:
5656
if: always()
5757
- name: Save the test output
5858
if: always()
59-
uses: actions/upload-artifact@v2
59+
uses: actions/upload-artifact@v3
6060
with:
6161
name: test-output
6262
path: arrow/r/check/arrow.Rcheck/tests/testthat.Rout*

dev/tasks/r/github.linux.offline.build.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ jobs:
4141
R -e "source('R/install-arrow.R'); create_package_with_all_dependencies(dest_file = 'arrow_with_deps.tar.gz', source_file = \"${built_tar}\")"
4242
shell: bash
4343
- name: Upload the third party dependency artifacts
44-
uses: actions/upload-artifact@v2
44+
uses: actions/upload-artifact@v3
4545
with:
4646
name: thirdparty_deps
4747
path: arrow/r/arrow_with_deps.tar.gz
@@ -91,7 +91,7 @@ jobs:
9191
run: cat arrow-tests/testthat.Rout*
9292
if: always()
9393
- name: Save the test output
94-
uses: actions/upload-artifact@v2
94+
uses: actions/upload-artifact@v3
9595
with:
9696
name: test-output
9797
path: arrow-tests/testthat.Rout*

dev/tasks/r/github.linux.versions.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ jobs:
5555
if: always()
5656
- name: Save the test output
5757
if: always()
58-
uses: actions/upload-artifact@v2
58+
uses: actions/upload-artifact@v3
5959
with:
6060
name: test-output
6161
path: arrow/r/check/arrow.Rcheck/tests/testthat.Rout*

dev/tasks/r/github.macos-linux.local.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ jobs:
9797
run: cat arrow-tests/testthat.Rout*
9898
if: failure()
9999
- name: Save the test output
100-
uses: actions/upload-artifact@v2
100+
uses: actions/upload-artifact@v3
101101
with:
102102
name: test-output
103103
path: arrow-tests/testthat.Rout*

0 commit comments

Comments
 (0)