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

Make expected result string in unit tests more readable #2413

Merged
merged 1 commit into from
May 2, 2022

Conversation

WinkerDu
Copy link
Contributor

@WinkerDu WinkerDu commented May 2, 2022

Which issue does this PR close?

Closes #2412 .

Rationale for this change

Some unit tests in DataFusion organize expected result string vector in one line, like sql::union::union_distinct do

#[tokio::test]
async fn union_distinct() -> Result<()> {
    let ctx = SessionContext::new();
    let sql = "SELECT 1 as x UNION SELECT 1 as x";
    let actual = execute_to_batches(&ctx, sql).await;
    let expected = vec!["+---+", "| x |", "+---+", "| 1 |", "+---+"];
    assert_batches_eq!(expected, &actual);
    Ok(())
}

We can separate the expected result string vector into multiple line to make it more readable and easier to follow, by adding a #[rustfmt::skip] tag to skip fmt check as following code

#[tokio::test]
async fn union_distinct() -> Result<()> {
    let ctx = SessionContext::new();
    let sql = "SELECT 1 as x UNION SELECT 1 as x";
    let actual = execute_to_batches(&ctx, sql).await;
    #[rustfmt::skip]
    let expected = vec![
        "+---+",
        "| x |",
        "+---+",
        "| 1 |",
        "+---+"
    ];
    assert_batches_eq!(expected, &actual);
    Ok(())
}

What changes are included in this PR?

  • Separates the expected result string vector into multiple line
  • adds a #[rustfmt::skip] tag to skip fmt check

Are there any user-facing changes?

No.

@github-actions github-actions bot added the datafusion Changes in the datafusion crate label May 2, 2022
Copy link
Member

@andygrove andygrove left a comment

Choose a reason for hiding this comment

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

That is much easier to comprehend, especially when doing PR reviews. Thanks @WinkerDu.

@andygrove andygrove mentioned this pull request May 2, 2022
@andygrove andygrove merged commit 6da4bf2 into apache:master May 2, 2022
@WinkerDu WinkerDu deleted the master-result-readable branch May 2, 2022 14:55
gandronchik pushed a commit to cube-js/arrow-datafusion that referenced this pull request Aug 30, 2022
gandronchik pushed a commit to cube-js/arrow-datafusion that referenced this pull request Aug 31, 2022
gandronchik pushed a commit to cube-js/arrow-datafusion that referenced this pull request Sep 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
datafusion Changes in the datafusion crate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make expected result string in unit tests more readable
2 participants