Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
20 changes: 17 additions & 3 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -232,9 +232,21 @@ jobs:
name: "Run sqllogictest with Postgres runner"
needs: [linux-build-lib]
runs-on: ubuntu-latest
services:
postgres:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this starts the container using the code from integration-tests (above in this file) rather than running docker from within the harness

image: postgres:15
env:
POSTGRES_PASSWORD: postgres
POSTGRES_DB: db_test
POSTGRES_INITDB_ARGS: --encoding=UTF-8 --lc-collate=C --lc-ctype=C
ports:
- 5432/tcp
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- name: Check docker
run: docker ps
- uses: actions/checkout@v3
with:
submodules: true
Expand All @@ -243,7 +255,9 @@ jobs:
rustup toolchain install stable
rustup default stable
- name: Run sqllogictest
run: PG_COMPAT=true cargo test -p datafusion --test sqllogictests
run: PG_COMPAT=true PG_URI="postgresql://postgres:postgres@localhost:$POSTGRES_PORT/db_test" cargo test -p datafusion --test sqllogictests
env:
POSTGRES_PORT: ${{ job.services.postgres.ports[5432] }}

windows:
name: cargo test (win64)
Expand Down
1 change: 0 additions & 1 deletion datafusion/core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ rstest = "0.16.0"
rust_decimal = { version = "1.27.0", features = ["tokio-pg"] }
sqllogictest = "0.11.1"
test-utils = { path = "../../test-utils" }
testcontainers = "0.14.0"
thiserror = "1.0.37"
tokio-postgres = "0.7.7"
[target.'cfg(not(target_os = "windows"))'.dev-dependencies]
Expand Down
27 changes: 22 additions & 5 deletions datafusion/core/tests/sqllogictests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,33 @@ cargo test -p datafusion --test sqllogictests -- information

#### Running tests: Postgres compatibility

Test files that start with prefix `pg_compat_` verify compatibility with Postgres.
Datafusion runs these test files during normal sqllogictest runs.
Test files that start with prefix `pg_compat_` verify compatibility
with Postgres by running the same script files both with DataFusion and with Posgres

In order to run sqllogictests with Postgres execute:
In order to run the sqllogictests running against a previously running Postgres instance, do:

```shell
PG_COMPAT=true cargo test -p datafusion --test sqllogictests
PG_COMPAT=true PG_URI="postgresql://postgres@127.0.0.1/postgres" cargo test -p datafusion --test sqllogictests
```

This command requires a docker binary. Check that docker is properly installed with `which docker`.
The environemnt variables:

1. `PG_COMPAT` instructs sqllogictest to run against Postgres (not DataFusion)
2. `PG_URI` contains a `libpq` style connection string, whose format is described in
[the docs](https://docs.rs/tokio-postgres/latest/tokio_postgres/config/struct.Config.html#url)

One way to create a suitable a posgres container in docker is to use
the [Official Image](https://hub.docker.com/_/postgres) with a command
such as the following. Note the collation **must** be set to `C` otherwise
`ORDER BY` will not match DataFusion and the tests will diff.

```shell
docker run \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
docker run \
docker run --rm \

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think --rm removes the container. I normally prefer to leave them around for debugging

-p5432:5432 \
-e POSTGRES_INITDB_ARGS="--encoding=UTF-8 --lc-collate=C --lc-ctype=C" \
-e POSTGRES_HOST_AUTH_METHOD=trust \
postgres
```

#### Updating tests: Completion Mode

Expand Down

This file was deleted.

57 changes: 0 additions & 57 deletions datafusion/core/tests/sqllogictests/src/engines/postgres/image.rs

This file was deleted.

Loading