Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,16 @@ jobs:
./ci/scripts/cpp_test.sh "$(pwd)/build"
./ci/scripts/python_test.sh "$(pwd)" "$(pwd)/build"
docker compose down
- name: Install pixi
uses: prefix-dev/setup-pixi@ba3bb36eb2066252b2363392b7739741bb777659 # v0.8.1
with:
pixi-version: v0.62.1
- name: Run PostgreSQL Validation Suite
run: |
env POSTGRES_VERSION=15 docker compose up --wait --detach postgres-test
cd c/driver/postgresql/validation
pixi run validate
docker compose down
- name: Test PostgreSQL Driver - postgres 16
env:
BUILD_ALL: "0"
Expand Down
10 changes: 6 additions & 4 deletions c/driver/postgresql/result_helper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -143,14 +143,16 @@ Status PqResultHelper::ResolveParamTypes(PostgresTypeResolver& type_resolver,
const Oid pg_oid = PQparamtype(result_, i);
PostgresType pg_type;
if (type_resolver.Find(pg_oid, &pg_type, &na_error) != NANOARROW_OK) {
Status status = Status::NotImplemented("[libpq] Parameter #", i + 1, " (\"",
PQfname(result_, i),
"\") has unknown type code ", pg_oid);
std::string param_name = "$" + std::to_string(i + 1);
Status status =
Status::NotImplemented("[libpq] Parameter #", i + 1, " (\"", param_name,
"\") has unknown type code ", pg_oid);
ClearResult();
return status;
}

root_type.AppendChild(PQfname(result_, i), pg_type);
std::string param_name = "$" + std::to_string(i + 1);
root_type.AppendChild(param_name.c_str(), pg_type);
}

*param_types = root_type;
Expand Down
18 changes: 18 additions & 0 deletions c/driver/postgresql/validation/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

validation-report.xml
59 changes: 59 additions & 0 deletions c/driver/postgresql/validation/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->

# PostgreSQL ADBC Driver Validation Suite

This directory contains a Python-based validation suite for the PostgreSQL ADBC driver.

## Testing

A running instance of PostgreSQL is required. For example, using Docker:

```shell
$ docker run -it --rm \
-e POSTGRES_PASSWORD=password \
-e POSTGRES_DB=postgres \
-p 5432:5432 \
postgres
```

Alternatively use the `docker compose` provided by ADBC to manage the test
database container.

```shell
$ docker compose up postgres-test
# When finished:
# docker compose down postgres-test
```

Then, to run the tests, set the environment variable specifying the
PostgreSQL URI before running tests:

```shell
$ export ADBC_POSTGRESQL_TEST_URI=postgresql://localhost:5432/postgres?user=postgres&password=password
```

### 5. Run Tests

#### Using pixi:

```bash
cd c/driver/postgresql/validation
pixi run validate
```
1,629 changes: 1,629 additions & 0 deletions c/driver/postgresql/validation/pixi.lock

Large diffs are not rendered by default.

34 changes: 34 additions & 0 deletions c/driver/postgresql/validation/pixi.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

[workspace]
authors = ["Arrow ADBC Contributors"]
channels = ["conda-forge"]
name = "postgresql-validation"
platforms = ["linux-64", "osx-arm64", "win-64", "linux-aarch64"]
version = "0.1.0"

[tasks]
validate = "pytest -vvs --junit-xml=validation-report.xml -rfEsxX tests/"

[dependencies]
python = ">=3.13.5,<3.14"
pytest-lazy-fixtures = ">=1.3.2,<2"

[pypi-dependencies]
adbc-drivers-dev = { git = "https://github.com/adbc-drivers/dev" }
adbc-drivers-validation = { git = "https://github.com/adbc-drivers/validation" }
24 changes: 24 additions & 0 deletions c/driver/postgresql/validation/pytest.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

[pytest]
junit_suite_name = validation
junit_duration_report = call
xfail_strict = true

markers =
feature: test for a driver-specific feature
15 changes: 15 additions & 0 deletions c/driver/postgresql/validation/queries/ingest/decimal.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright (c) 2025 ADBC Drivers Contributors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

skip = "decimal ingest code has a bug and fix has not been merged in yet. https://github.com/apache/arrow-adbc/pull/3787"
17 changes: 17 additions & 0 deletions c/driver/postgresql/validation/queries/ingest/time_ms.txtcase
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Copyright (c) 2025 ADBC Drivers Contributors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

// part: metadata

skip = "COPY Writer not implemented"
17 changes: 17 additions & 0 deletions c/driver/postgresql/validation/queries/ingest/time_ns.txtcase
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Copyright (c) 2025 ADBC Drivers Contributors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

// part: metadata

skip = "COPY Writer not implemented"
17 changes: 17 additions & 0 deletions c/driver/postgresql/validation/queries/ingest/time_s.txtcase
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Copyright (c) 2025 ADBC Drivers Contributors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

// part: metadata

skip = "COPY Writer not implemented"
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// Copyright (c) 2025 ADBC Drivers Contributors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

// part: expected_schema

{
"format": "+s",
"children": [
{
"name": "idx",
"format": "l",
"flags": ["nullable"]
},
{
"name": "value",
"format": "tsu:",
"flags": ["nullable"]
}
]
}

// part: expected

{"idx": 0, "value": null}
{"idx": 1, "value": 0}
{"idx": 2, "value": 946684800123000}
{"idx": 3, "value": 1684158330123000}
{"idx": 4, "value": -62135596800000000}
{"idx": 5, "value": 253402300799999000}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// Copyright (c) 2025 ADBC Drivers Contributors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

// part: expected_schema

{
"format": "+s",
"children": [
{
"name": "idx",
"format": "l",
"flags": ["nullable"]
},
{
"name": "value",
"format": "tsu:",
"flags": ["nullable"]
}
]
}

// part: expected

{"idx": 0, "value": null}
{"idx": 1, "value": 0}
{"idx": 2, "value": -9223372036854775}
{"idx": 3, "value": 946684800000000}
{"idx": 4, "value": 1684158330000000}
{"idx": 5, "value": 9223372036854775}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// Copyright (c) 2025 ADBC Drivers Contributors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

// part: expected_schema

{
"format": "+s",
"children": [
{
"name": "idx",
"format": "l",
"flags": ["nullable"]
},
{
"name": "value",
"format": "tsu:",
"flags": ["nullable"]
}
]
}

// part: expected

{"idx": 0, "value": null}
{"idx": 1, "value": 0}
{"idx": 2, "value": 946684800000000}
{"idx": 3, "value": 1684158330000000}
{"idx": 4, "value": -62135596800000000}
{"idx": 5, "value": 253402300799000000}
Loading
Loading