Skip to content

Conversation

lifan-ake
Copy link
Contributor

Which issue does this PR close?

Rationale for this change

What changes are included in this PR?

migrate logical_plan tests to insta

Are these changes tested?

Are there any user-facing changes?

@github-actions github-actions bot added the logical-expr Logical plan and expressions label May 25, 2025
@lifan-ake
Copy link
Contributor Author

Hi @alamb and @blaginin , I'am trying to solve this issue #15792 .

This PR is ready to review, please take a look once you have time.

In my opinion, the doc should be easily readable by others. With normal assert expression, we can easily understand the doc. But if we use insta, there will be a learning curve for the doc. So I keep the doc unchanged.

Copy link
Contributor

@blaginin blaginin left a comment

Choose a reason for hiding this comment

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

thanks, overall looks good - left a few comments

@blaginin
Copy link
Contributor

Also can you please check the CI? Some tests are failing

@lifan-ake lifan-ake requested a review from blaginin May 26, 2025 03:24
Copy link
Contributor

@blaginin blaginin left a comment

Choose a reason for hiding this comment

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

Thank you for the quick response! Just a few minor things and this PR will be good to go

Comment on lines +2591 to +2602
let DataFusionError::Internal(desc) = err else {
return plan_err!("Plan should have returned an DataFusionError::Internal");
};

let desc = desc
.split(DataFusionError::BACK_TRACE_SEP)
.collect::<Vec<&str>>()
.first()
.unwrap_or(&"")
.to_string();

assert_snapshot!(desc, @"trying to unnest on invalid data type UInt32");
Copy link
Contributor

Choose a reason for hiding this comment

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

what do you think about

Suggested change
let DataFusionError::Internal(desc) = err else {
return plan_err!("Plan should have returned an DataFusionError::Internal");
};
let desc = desc
.split(DataFusionError::BACK_TRACE_SEP)
.collect::<Vec<&str>>()
.first()
.unwrap_or(&"")
.to_string();
assert_snapshot!(desc, @"trying to unnest on invalid data type UInt32");
assert_snapshot!(err.strip_backtrace(), @r"
Internal error: trying to unnest on invalid data type UInt32.
This was likely caused by a bug in DataFusion's code and we would welcome that you file an bug report in our issue tracker
");

that way, we won't have to manually split on the string

Copy link
Contributor Author

@lifan-ake lifan-ake May 26, 2025

Choose a reason for hiding this comment

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

I tried this. When I run the test locally, the snapshot will contain the "This was likey cuased" sentence. But when I submit the code and run the CI, it will failed because the snapshot will not contain the last sentence. I am wondering why.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

image

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for the screenshot! This may be happening because locally you run tests without the backtrace feature.

As a result, when you run it without the feature, you get:

Internal error: trying to unnest on invalid data type UInt32.
This was likely caused by a bug in DataFusion's code and we would welcome that you file an bug report in our issue tracker

However, with backtrace, we get:

Internal error: trying to unnest on invalid data type UInt32.
-- (backtrace) --
This was likely caused by a bug in DataFusion's code and we would welcome that you file an bug report in our issue tracker

I think a robust solution would be adding a redaction to eliminate the backtrace and adding a dev note somewhere to apply that redaction to all tests that rely on error formatting. That said, your solution is fine too - up to you if you want to leave it as is or change.

Copy link
Contributor Author

@lifan-ake lifan-ake May 27, 2025

Choose a reason for hiding this comment

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

Thank you for the explanation. And apart from redaction, how about we change the backtrace appending logic for errors? Maybe we can append the backtrace behind the output error message instead of the original error message? In that case, we may need another issue to track it.

@lifan-ake lifan-ake requested a review from blaginin May 26, 2025 11:45
Copy link
Contributor

@blaginin blaginin left a comment

Choose a reason for hiding this comment

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

Well done! I'll keep the PR open for a bit in case you want to respond to my point or if someone else wants to review.

Comment on lines +2591 to +2602
let DataFusionError::Internal(desc) = err else {
return plan_err!("Plan should have returned an DataFusionError::Internal");
};

let desc = desc
.split(DataFusionError::BACK_TRACE_SEP)
.collect::<Vec<&str>>()
.first()
.unwrap_or(&"")
.to_string();

assert_snapshot!(desc, @"trying to unnest on invalid data type UInt32");
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for the screenshot! This may be happening because locally you run tests without the backtrace feature.

As a result, when you run it without the feature, you get:

Internal error: trying to unnest on invalid data type UInt32.
This was likely caused by a bug in DataFusion's code and we would welcome that you file an bug report in our issue tracker

However, with backtrace, we get:

Internal error: trying to unnest on invalid data type UInt32.
-- (backtrace) --
This was likely caused by a bug in DataFusion's code and we would welcome that you file an bug report in our issue tracker

I think a robust solution would be adding a redaction to eliminate the backtrace and adding a dev note somewhere to apply that redaction to all tests that rely on error formatting. That said, your solution is fine too - up to you if you want to leave it as is or change.

@blaginin
Copy link
Contributor

Also, welcome to the project 🎉

@lifan-ake
Copy link
Contributor Author

lifan-ake commented May 27, 2025

Hi @alamb , I think this PR is ready to merge.

@alamb alamb merged commit 68e26f1 into apache:main May 27, 2025
29 checks passed
@alamb
Copy link
Contributor

alamb commented May 27, 2025

Thank you @lifan-ake and @blaginin

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

logical-expr Logical plan and expressions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Migrate logical_plan tests to insta

3 participants