Apache DataFusion SQL Query Engine
MINOR: Add documentation for running integration tests (#2839)
Andy Grove06450e8c71f9
diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.ymlindex 2161231324..b534ed2240 100644--- a/.github/workflows/rust.yml+++ b/.github/workflows/rust.yml@@ -170,21 +170,7 @@ jobs:# make sure psql can access the serverecho "$POSTGRES_HOST:$POSTGRES_PORT:$POSTGRES_DB:$POSTGRES_USER:$POSTGRES_PASSWORD" | tee ~/.pgpasschmod 0600 ~/.pgpass- psql -d "$POSTGRES_DB" -h "$POSTGRES_HOST" -p "$POSTGRES_PORT" -U "$POSTGRES_USER" -c 'CREATE TABLE IF NOT EXISTS test (- c1 character varying NOT NULL,- c2 integer NOT NULL,- c3 smallint NOT NULL,- c4 smallint NOT NULL,- c5 integer NOT NULL,- c6 bigint NOT NULL,- c7 smallint NOT NULL,- c8 integer NOT NULL,- c9 bigint NOT NULL,- c10 character varying NOT NULL,- c11 double precision NOT NULL,- c12 double precision NOT NULL,- c13 character varying NOT NULL- );'+ psql -d "$POSTGRES_DB" -h "$POSTGRES_HOST" -p "$POSTGRES_PORT" -U "$POSTGRES_USER" -f integration-tests/create_test_table_postgres.sqlpsql -d "$POSTGRES_DB" -h "$POSTGRES_HOST" -p "$POSTGRES_PORT" -U "$POSTGRES_USER" -c "\copy test FROM '$(pwd)/testing/data/csv/aggregate_test_100.csv' WITH (FORMAT csv, HEADER true);"env:POSTGRES_HOST: localhostdiff --git a/integration-tests/README.md b/integration-tests/README.mdnew file mode 100644index 0000000000..b97c9ac615--- /dev/null+++ b/integration-tests/README.md@@ -0,0 +1,49 @@+<!---+ 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.+-->++# DataFusion Integration Tests++These test run SQL queries against both DataFusion and Postgres and compare the results for parity.++## Setup++Set the following environment variables as appropriate for your environment. They are all optional.++- `POSTGRES_DB`+- `POSTGRES_USER`+- `POSTGRES_HOST`+- `POSTGRES_PORT`++Create a Postgres database and then create the test table by running this script:++```bash+psql -d "$POSTGRES_DB" -h "$POSTGRES_HOST" -p "$POSTGRES_PORT" -U "$POSTGRES_USER" \+ -f create_test_table_postgres.sql+```++Populate the table by running this command:++```bash+psql -d "$POSTGRES_DB" -h "$POSTGRES_HOST" -p "$POSTGRES_PORT" -U "$POSTGRES_USER" \+ -c "\copy test FROM '$(pwd)/testing/data/csv/aggregate_test_100.csv' WITH (FORMAT csv, HEADER true);"+```++## Run Tests++Run `pytest` from the root of the repository.diff --git a/integration-tests/create_test_table_postgres.sql b/integration-tests/create_test_table_postgres.sqlnew file mode 100644index 0000000000..7cc154b1f8--- /dev/null+++ b/integration-tests/create_test_table_postgres.sql@@ -0,0 +1,15 @@+CREATE TABLE IF NOT EXISTS test (+c1 character varying NOT NULL,+c2 integer NOT NULL,+c3 smallint NOT NULL,+c4 smallint NOT NULL,+c5 integer NOT NULL,+c6 bigint NOT NULL,+c7 smallint NOT NULL,+c8 integer NOT NULL,+c9 bigint NOT NULL,+c10 character varying NOT NULL,+c11 double precision NOT NULL,+c12 double precision NOT NULL,+c13 character varying NOT NULL+);\ No newline at end of filediff --git a/integration-tests/test_psql_parity.py b/integration-tests/test_psql_parity.pyindex f1c6bf6a5d..506100bbc9 100644--- a/integration-tests/test_psql_parity.py+++ b/integration-tests/test_psql_parity.py@@ -52,24 +52,29 @@ def generate_csv_from_datafusion(fname: str):def generate_csv_from_psql(fname: str):- return subprocess.check_output(- [- "psql",- "-d",- pg_db,- "-h",- pg_host,- "-p",- pg_port,- "-U",- pg_user,- "-X",- "--csv",- "-f",- fname,- ]- )+ cmd = ["psql"]++ if pg_db is not None:+ cmd.extend(["-d", pg_db])++ if pg_user is not None:+ cmd.extend(["-U", pg_user])++ if pg_host is not None:+ cmd.extend(["-h", pg_host])++ if pg_port is not None:+ cmd.extend(["-p", pg_port])++ cmd.extend([+ "-X",+ "--csv",+ "-f",+ fname,+ ])++ return subprocess.check_output(cmd)root = Path(os.path.dirname(__file__)) / "sqls"test_files = set(root.glob("*.sql"))