This is an automated email from the ASF dual-hosted git repository.
lidavidm pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow-adbc.git
The following commit(s) were added to refs/heads/main by this push:
new e9ac773db3 ci: run PostgreSQL tests on Windows x64 (#4849)
e9ac773db3 is described below
commit e9ac773db316bea6c52fd013bce7d704eed316fa
Author: Bryce Mecum <[email protected]>
AuthorDate: Sun Oct 4 16:21:52 2026 -0700
ci: run PostgreSQL tests on Windows x64 (#4849)
Enables testing the PostgreSQL driver on Windows x64, in both the conda
and vcpkg jobs. Previously we were just building the driver on Windows.
I opted to just use the runner's in-built PostgreSQL installation to
avoid having to use Docker which is slow. GitHub's windows-11-arm runner
doesn't have PostgreSQL so we're still not testing the driver there.
This PR discovered three latent issues which are also fixed here:
- The vendor version regex in `posgresql_test.cc` of `"[0-9]{6}"` fails
on Windows because apparently the GTest regex engine doesn't support it.
So we fall back to a less fancy regex as needed. I think I could've done
`s/__WIN32/_WIN32` also but GPT6.1-Sol suggested this and it looks more
portable.
- The fallback path Decimal writer was retaining extra zeroes:
https://github.com/apache/arrow-adbc/actions/runs/37050356083/job/110981936667#step:12:784
- A Windows-only bug in the interval tests due to Windows' 32-bit longs:
https://github.com/apache/arrow-adbc/actions/runs/37052275441/job/110988326667#step:12:454
GPT6.1-Sol was used in the creation of this PR.
---
.github/workflows/native-vcpkg.yml | 27 +++++++++++++++++++++++++
.github/workflows/native-windows.yml | 30 +++++++++++++++++++---------
c/driver/postgresql/copy/writer.h | 5 ++---
c/driver/postgresql/postgresql_test.cc | 36 ++++++++++++++++++----------------
4 files changed, 69 insertions(+), 29 deletions(-)
diff --git a/.github/workflows/native-vcpkg.yml
b/.github/workflows/native-vcpkg.yml
index 42c7faadf4..2a99875594 100644
--- a/.github/workflows/native-vcpkg.yml
+++ b/.github/workflows/native-vcpkg.yml
@@ -67,6 +67,7 @@ jobs:
VCPKG_DEFAULT_BINARY_CACHE: ${{ github.workspace }}/vcpkg-cache
VCPKG_DEFAULT_TRIPLET: ${{ matrix.triplet }}
VCPKG_ROOT: ${{ github.workspace }}/vcpkg
+ CTEST_CONFIGURATION_TYPE: ${{ matrix.config }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 #
v7.0.1
with:
@@ -123,6 +124,32 @@ jobs:
BUILD_DRIVER_SQLITE: "1"
run: .\ci\scripts\cpp_test.ps1 $pwd\build\${{ matrix.config }}
$pwd\local\${{ matrix.config }}
+ - name: Start PostgreSQL
+ # For now, we only test on x64-windows. As of 2026-10-02,
windows-latest
+ # ships with PostgreSQL but windows-11-arm does not. The code here is
+ # copied from java.yml just to be uniform.
+ if: matrix.arch == 'x64'
+ run: |
+ "root" | Set-Content "$env:RUNNER_TEMP\postgres_password"
+ & "$env:PGBIN\initdb.exe" `
+ --pgdata="$env:RUNNER_TEMP\pgdata" `
+ --username postgres `
+ --pwfile="$env:RUNNER_TEMP\postgres_password" `
+ --auth="scram-sha-256" `
+ --encoding="UTF-8" `
+ --locale="en_US.UTF-8" `
+ --no-instructions
+ if (-not $?) { throw "Failed to initialize PostgreSQL" }
+ & "$env:PGBIN\pg_ctl.exe" start --pgdata="$env:RUNNER_TEMP\pgdata"
+ if (-not $?) { throw "Failed to start PostgreSQL" }
+ - name: Test Driver PostgreSQL
+ if: matrix.arch == 'x64'
+ env:
+ BUILD_ALL: "0"
+ BUILD_DRIVER_POSTGRESQL: "1"
+ ADBC_POSTGRESQL_TEST_URI:
"postgresql://postgres:root@localhost:5432/postgres"
+ run: .\ci\scripts\cpp_test.ps1 $pwd\build\${{ matrix.config }}
$pwd\local\${{ matrix.config }}
+
- uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e #
v7.0.0
with:
check-latest: true
diff --git a/.github/workflows/native-windows.yml
b/.github/workflows/native-windows.yml
index 5c9ad07ffd..10e24abe1e 100644
--- a/.github/workflows/native-windows.yml
+++ b/.github/workflows/native-windows.yml
@@ -146,20 +146,12 @@ jobs:
# Force bundled gtest
mamba uninstall gtest
- - name: Build Driver Manager
+ - name: Build Drivers
env:
BUILD_ALL: "0"
BUILD_DRIVER_MANAGER: "1"
BUILD_DRIVER_MANAGER_USER_CONFIG_TEST: "1"
- run: .\ci\scripts\cpp_build.ps1 $pwd $pwd\build
- - name: Build Driver PostgreSQL
- env:
- BUILD_ALL: "0"
BUILD_DRIVER_POSTGRESQL: "1"
- run: .\ci\scripts\cpp_build.ps1 $pwd $pwd\build
- - name: Build Driver SQLite
- env:
- BUILD_ALL: "0"
BUILD_DRIVER_SQLITE: "1"
run: .\ci\scripts\cpp_build.ps1 $pwd $pwd\build
- name: Test Driver Manager
@@ -173,6 +165,26 @@ jobs:
BUILD_ALL: "0"
BUILD_DRIVER_SQLITE: "1"
run: .\ci\scripts\cpp_test.ps1 $pwd\build
+ - name: Start PostgreSQL
+ run: |
+ "root" | Set-Content "$env:RUNNER_TEMP\postgres_password"
+ & "$env:PGBIN\initdb.exe" `
+ --pgdata="$env:RUNNER_TEMP\pgdata" `
+ --username postgres `
+ --pwfile="$env:RUNNER_TEMP\postgres_password" `
+ --auth="scram-sha-256" `
+ --encoding="UTF-8" `
+ --locale="en_US.UTF-8" `
+ --no-instructions
+ if (-not $?) { throw "Failed to initialize PostgreSQL" }
+ & "$env:PGBIN\pg_ctl.exe" start --pgdata="$env:RUNNER_TEMP\pgdata"
+ if (-not $?) { throw "Failed to start PostgreSQL" }
+ - name: Test Driver PostgreSQL
+ env:
+ BUILD_ALL: "0"
+ BUILD_DRIVER_POSTGRESQL: "1"
+ ADBC_POSTGRESQL_TEST_URI:
"postgresql://postgres:root@localhost:5432/postgres"
+ run: .\ci\scripts\cpp_test.ps1 $pwd\build
# ------------------------------------------------------------
# Go build
diff --git a/c/driver/postgresql/copy/writer.h
b/c/driver/postgresql/copy/writer.h
index 4b38e710f7..eadbc528df 100644
--- a/c/driver/postgresql/copy/writer.h
+++ b/c/driver/postgresql/copy/writer.h
@@ -405,10 +405,9 @@ class PostgresCopyNumericFieldWriter : public
PostgresCopyFieldWriter {
int16_t dscale =
static_cast<int16_t>((std::max)(0, parts.effective_scale -
trailing_zeros));
- // Optimize: remove trailing zero digit groups from fractional part
+ // Optimize: remove trailing zero digit groups
int n_int_digit_groups = int_digits.size();
- while (static_cast<int>(all_digits.size()) > n_int_digit_groups &&
- all_digits.back() == 0) {
+ while (!all_digits.empty() && all_digits.back() == 0) {
all_digits.pop_back();
}
diff --git a/c/driver/postgresql/postgresql_test.cc
b/c/driver/postgresql/postgresql_test.cc
index c157091b7c..2e10be9b69 100644
--- a/c/driver/postgresql/postgresql_test.cc
+++ b/c/driver/postgresql/postgresql_test.cc
@@ -396,7 +396,9 @@ TEST_F(PostgresConnectionTest, GetInfoMetadata) {
}
case ADBC_INFO_VENDOR_VERSION: {
ArrowStringView val = ArrowArrayViewGetStringUnsafe(str_child,
offset);
-#ifdef __WIN32
+// Fall back to a simpler version regex. This only really impacts WIN32/MSVC
but
+// this is slightly more correct/portable.
+#if GTEST_USES_SIMPLE_RE
const char* pater = "\\d\\d\\d\\d\\d\\d";
#else
const char* pater = "[0-9]{6}";
@@ -2947,49 +2949,49 @@ static std::initializer_list<TypeTestCase>
kIntervalTypeCases = {
"INTERVAL",
"'P-1Y2M42DT1H1M1S'",
NANOARROW_TYPE_INTERVAL_MONTH_DAY_NANO,
- MonthDayNano(-10, 42, (1L * 60 * 60 + 60L + 1L) * 1'000'000'000),
+ MonthDayNano(-10, 42, (1LL * 60 * 60 + 60LL + 1LL) * 1'000'000'000),
},
{
"INTERVAL2",
"INTERVAL",
"'P0Y0M0DT0H0M0.1S'",
NANOARROW_TYPE_INTERVAL_MONTH_DAY_NANO,
- MonthDayNano(0, 0, 100L * 1'000'000),
+ MonthDayNano(0, 0, 100LL * 1'000'000),
},
{
"INTERVAL3",
"INTERVAL",
"'P0Y0M0DT0H0M0.01S'",
NANOARROW_TYPE_INTERVAL_MONTH_DAY_NANO,
- MonthDayNano(0, 0, 10L * 1'000'000),
+ MonthDayNano(0, 0, 10LL * 1'000'000),
},
{
"INTERVAL4",
"INTERVAL",
"'P0Y0M0DT0H0M0.001S'",
NANOARROW_TYPE_INTERVAL_MONTH_DAY_NANO,
- MonthDayNano(0, 0, 1L * 1'000'000),
+ MonthDayNano(0, 0, 1LL * 1'000'000),
},
{
"INTERVAL5",
"INTERVAL",
"'P0Y0M0DT0H0M0.0001S'",
NANOARROW_TYPE_INTERVAL_MONTH_DAY_NANO,
- MonthDayNano(0, 0, 100'000L),
+ MonthDayNano(0, 0, 100'000LL),
},
{
"INTERVAL6",
"INTERVAL",
"'P0Y0M0DT0H0M0.00001S'",
NANOARROW_TYPE_INTERVAL_MONTH_DAY_NANO,
- MonthDayNano(0, 0, 10'000L),
+ MonthDayNano(0, 0, 10'000LL),
},
{
"INTERVAL7",
"INTERVAL",
"'P0Y0M0DT0H0M0.000001S'",
NANOARROW_TYPE_INTERVAL_MONTH_DAY_NANO,
- MonthDayNano(0, 0, 1'000L),
+ MonthDayNano(0, 0, 1'000LL),
},
{
"INTERVAL_YEAR",
@@ -3017,21 +3019,21 @@ static std::initializer_list<TypeTestCase>
kIntervalTypeCases = {
"INTERVAL HOUR",
"'12H'",
NANOARROW_TYPE_INTERVAL_MONTH_DAY_NANO,
- MonthDayNano(0, 0, 12L * 60 * 60 * 1'000'000'000),
+ MonthDayNano(0, 0, 12LL * 60 * 60 * 1'000'000'000),
},
{
"INTERVAL_MINUTE",
"INTERVAL MINUTE",
"'P0Y0M0DT0H-5M0S'",
NANOARROW_TYPE_INTERVAL_MONTH_DAY_NANO,
- MonthDayNano(0, 0, -5L * 60 * 1'000'000'000),
+ MonthDayNano(0, 0, -5LL * 60 * 1'000'000'000),
},
{
"INTERVAL_SECOND",
"INTERVAL SECOND",
"'P0Y0M0DT0H0M42S'",
NANOARROW_TYPE_INTERVAL_MONTH_DAY_NANO,
- MonthDayNano(0, 0, 42L * 1'000'000'000),
+ MonthDayNano(0, 0, 42LL * 1'000'000'000),
},
{
"INTERVAL_YEAR_TO_MONTH",
@@ -3045,42 +3047,42 @@ static std::initializer_list<TypeTestCase>
kIntervalTypeCases = {
"INTERVAL DAY TO HOUR",
"'P0Y0M1DT-2H0M0S'",
NANOARROW_TYPE_INTERVAL_MONTH_DAY_NANO,
- MonthDayNano(0, 1, -2L * 60 * 60 * 1'000'000'000),
+ MonthDayNano(0, 1, -2LL * 60 * 60 * 1'000'000'000),
},
{
"INTERVAL_DAY_TO_MINUTE",
"INTERVAL DAY TO MINUTE",
"'P0Y0M1DT-2H1M0S'",
NANOARROW_TYPE_INTERVAL_MONTH_DAY_NANO,
- MonthDayNano(0, 1, (-2L * 60 + 1L) * 60 * 1'000'000'000),
+ MonthDayNano(0, 1, (-2LL * 60 + 1LL) * 60 * 1'000'000'000),
},
{
"INTERVAL_DAY_TO_SECOND",
"INTERVAL DAY TO SECOND",
"'P0Y0M1DT-2H1M-1S'",
NANOARROW_TYPE_INTERVAL_MONTH_DAY_NANO,
- MonthDayNano(0, 1, ((-2L * 60 + 1L) * 60 - 1L) * 1'000'000'000),
+ MonthDayNano(0, 1, ((-2LL * 60 + 1LL) * 60 - 1LL) * 1'000'000'000),
},
{
"INTERVAL_HOUR_TO_MINUTE",
"INTERVAL HOUR TO MINUTE",
"'P0Y0M0DT-2H1M0S'",
NANOARROW_TYPE_INTERVAL_MONTH_DAY_NANO,
- MonthDayNano(0, 0, (-2L * 60 + 1L) * 60 * 1'000'000'000),
+ MonthDayNano(0, 0, (-2LL * 60 + 1LL) * 60 * 1'000'000'000),
},
{
"INTERVAL_HOUR_TO_SECOND",
"INTERVAL HOUR TO SECOND",
"'P0Y0M0DT-2H1M-1S'",
NANOARROW_TYPE_INTERVAL_MONTH_DAY_NANO,
- MonthDayNano(0, 0, ((-2L * 60 + 1L) * 60 - 1L) * 1'000'000'000),
+ MonthDayNano(0, 0, ((-2LL * 60 + 1LL) * 60 - 1LL) * 1'000'000'000),
},
{
"INTERVAL_MINUTE_TO_SECOND",
"INTERVAL MINUTE TO SECOND",
"'P0Y0M0DT0H1M-1S'",
NANOARROW_TYPE_INTERVAL_MONTH_DAY_NANO,
- MonthDayNano(0, 0, 59L * 1'000'000'000),
+ MonthDayNano(0, 0, 59LL * 1'000'000'000),
},
};
static std::initializer_list<TypeTestCase> kTimeTypeCases = {