Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move sqllogictests to sqllogictests crate to break cyclic dependency #7284

Merged
merged 12 commits into from
Aug 15, 2023

Conversation

alamb
Copy link
Contributor

@alamb alamb commented Aug 14, 2023

Which issue does this PR close?

Closes #7281

Rationale for this change

  1. feat: add sqllogictests crate #7134 introduced a circular dependency which means we can't publish to crates.io
  2. Elevating the sqllogictests into a less deep directory hierarchy will make it more discoverable

What changes are included in this PR?

  1. Move sqllogictest drivers from datafusion/core/tests/sqlloictest to datafusion/sqllogictest
  2. Update TestContext and include it in the datafusion_sqllogictest module
  3. Update CI jobs that use sqllogictest to use the new module
  4. Update readme
  5. Leave backwards compatibility MOVED.md

Are these changes tested?

Yes, both manually and via CI

Are there any user-facing changes?

No, but this likely will affect developer tests

New Command

sqllogictest, is now run like this:

cargo test --test sqllogictest

The old command was like this

cargo test -p datafusion --test sqllogictest

Bonus it also fixes the error called out by @Dandandan in the mailing list thread: https://lists.apache.org/thread/mbm8smv4rombbbsnfgll922768b103z6

   Compiling datafusion-sqllogictest v29.0.0 (/Users/alamb/Software/arrow-datafusion2/datafusion/sqllogictest)
warning: function `decimal_to_str` is never used
  --> datafusion/sqllogictest/src/engines/conversion.rs:85:15
   |
85 | pub(crate) fn decimal_to_str(value: Decimal) -> String {
   |               ^^^^^^^^^^^^^^
   |
   = note: `#[warn(dead_code)]` on by default


@github-actions github-actions bot added the sqllogictest SQL Logic Tests (.slt) label Aug 15, 2023
@@ -47,4 +47,4 @@ substrait:
- datafusion/substrait/**/*

sqllogictest:
- datafusion/core/tests/sqllogictests/**/*
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 illustrates that the sqllogictest code is no longer so deeply nested in the tree, which I think is a good change overall

@@ -270,7 +270,7 @@ jobs:
rustup toolchain install stable
rustup default stable
- name: Run sqllogictest
run: PG_COMPAT=true PG_URI="postgresql://postgres:postgres@localhost:$POSTGRES_PORT/db_test" cargo test -p datafusion --test sqllogictests
run: PG_COMPAT=true PG_URI="postgresql://postgres:postgres@localhost:$POSTGRES_PORT/db_test" cargo test --features=postgres --test sqllogictests
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Now running the posgres compatibility tests requires a feature flag, which I think is a good thing and will speed up normal developer workflows

cargo test serde_q --profile release-nonlto --features=ci -- --test-threads=1
INCLUDE_TPCH=true cargo test -p datafusion --test sqllogictests
INCLUDE_TPCH=true cargo test --test sqllogictests
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Arguable it is easier to run these tests now

@@ -102,7 +102,6 @@ bigdecimal = "0.4.1"
criterion = { version = "0.5", features = ["async_tokio"] }
csv = "1.1.6"
ctor = "0.2.0"
datafusion-sqllogictest = { path = "../sqllogictest", version = "29.0.0", features = ["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.

Removing this line to remove the circular dependency is the entire reason for this PR

thiserror = "1.0.44"
tokio = {version = "1.0"}
bytes = {version = "1.4.0", optional = true}
futures = {version = "0.3.28", optional = true}
futures = {version = "0.3.28"}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

datafusion depends on futures anyways so this is not a new dependency

@@ -121,7 +117,7 @@ async fn run_test_file(test_file: TestFile) -> Result<()> {
relative_path,
} = test_file;
info!("Running with DataFusion runner: {}", path.display());
let Some(test_ctx) = context_for_test_file(&relative_path).await else {
let Some(test_ctx) = TestContext::try_new_for_test_file(&relative_path).await else {
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 moved the logic for creating TestContext into the datafusion_sqllogictest library (and out of the runner) to avoid making the runner even longer

@@ -250,96 +254,6 @@ fn read_dir_recursive<P: AsRef<Path>>(path: P) -> Box<dyn Iterator<Item = PathBu
)
}

/// Create a SessionContext, configured for the specific test, if
Copy link
Contributor Author

Choose a reason for hiding this comment

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

moved to test_context.rs

@@ -2289,7 +2289,7 @@ select make_array(1.0, '2', null)
### FixedSizeListArray

statement ok
CREATE EXTERNAL TABLE fixed_size_list_array STORED AS PARQUET LOCATION 'tests/data/fixed_size_list_array.parquet';
CREATE EXTERNAL TABLE fixed_size_list_array STORED AS PARQUET LOCATION '../core/tests/data/fixed_size_list_array.parquet';
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Eventually it might make sense to move the data files, but for now I just updated the test paths

@alamb alamb requested a review from andygrove August 15, 2023 11:36
@alamb
Copy link
Contributor Author

alamb commented Aug 15, 2023

cc @melgenek

@alamb alamb marked this pull request as ready for review August 15, 2023 11:36
@alamb alamb changed the title Move sqllogictests to sqllogictests crate Move sqllogictests to sqllogictests crate to break cyclic dependency Aug 15, 2023
Copy link
Contributor

@melgenek melgenek left a comment

Choose a reason for hiding this comment

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

I only briefly skimmed through the change. Removing the cyclic dependency looks sane to me.

@alamb
Copy link
Contributor Author

alamb commented Aug 15, 2023

Thank you @melgenek

@yjshen yjshen merged commit 90484bb into apache:main Aug 15, 2023
@alamb alamb deleted the alamb/move_sqllogic_test branch August 15, 2023 17:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Core DataFusion crate sqllogictest SQL Logic Tests (.slt)
Projects
None yet
3 participants