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

feat: validate input references are consistent with the input schema #7193

Merged
merged 6 commits into from
Jan 5, 2023

Conversation

xxchan
Copy link
Member

@xxchan xxchan commented Jan 4, 2023

I hereby agree to the terms of the Singularity Data, Inc. Contributor License Agreement.

What's changed and what's your intention?

So that bugs like #7158 can be found earlier in frontend instead of backend.

@codecov
Copy link

codecov bot commented Jan 4, 2023

Codecov Report

Merging #7193 (487a5dd) into main (af29351) will increase coverage by 0.01%.
The diff coverage is 84.93%.

@@            Coverage Diff             @@
##             main    #7193      +/-   ##
==========================================
+ Coverage   73.12%   73.14%   +0.01%     
==========================================
  Files        1055     1056       +1     
  Lines      168949   169022      +73     
==========================================
+ Hits       123545   123625      +80     
+ Misses      45404    45397       -7     
Flag Coverage Δ
rust 73.14% <84.93%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
src/frontend/src/optimizer/plan_visitor/mod.rs 93.02% <ø> (+2.32%) ⬆️
.../src/optimizer/plan_visitor/input_ref_validator.rs 81.96% <81.96%> (ø)
src/frontend/src/optimizer/mod.rs 96.49% <100.00%> (+0.04%) ⬆️
.../frontend/src/optimizer/plan_node/batch_project.rs 97.77% <100.00%> (+0.15%) ⬆️
...frontend/src/optimizer/plan_node/stream_project.rs 91.11% <100.00%> (+0.63%) ⬆️
src/meta/src/manager/cluster.rs 76.86% <0.00%> (-0.25%) ⬇️
src/common/src/cache.rs 97.31% <0.00%> (-0.23%) ⬇️
src/stream/src/executor/aggregation/minput.rs 96.49% <0.00%> (+0.10%) ⬆️
src/storage/src/hummock/compactor/mod.rs 83.41% <0.00%> (+0.15%) ⬆️
src/common/src/types/ordered_float.rs 31.25% <0.00%> (+0.19%) ⬆️
... and 3 more

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@xxchan xxchan force-pushed the xxchan/cautious-gopher branch from 699cccc to 120cfbb Compare January 4, 2023 22:42
Copy link
Contributor

@chenzl25 chenzl25 left a comment

Choose a reason for hiding this comment

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

LGTM. Should we only enable these checks in debug mode?

@xxchan
Copy link
Member Author

xxchan commented Jan 5, 2023

Should we only enable these checks in debug mode?

I was also thinking about this problem and was not sure whether to add cfg!(debug_assertions). Are you mainly worried about performance or safety or other things?

IMHO:

  • Overhead is acceptable.
  • Violation of the assertion causes bugs. And frontend panic is better than backend panic.

BTW there are already many other assertions and we havn't systematically considered how to use assertions 🤔

@chenzl25
Copy link
Contributor

chenzl25 commented Jan 5, 2023

IMHO

My concern is about performance, because we need to visit the entire plan exprs several times. Most of our CI tests run in debug mode and once some bugs are found we can still catch them.

@xxchan
Copy link
Member Author

xxchan commented Jan 5, 2023

My concern is about performance, because we need to visit the entire plan exprs several times.

If so do we also change these to debug_assert 🫣:

        assert!(*plan.distribution() == Distribution::Single, "{}", plan);
        assert!(!has_batch_exchange(plan.clone()), "{}", plan);

Oh the first one should be cheap. The validation in this PR visits all expressions and thus is also more expensive than the second one. 🤔

Yes it's expensive. Let's ban it

@mergify mergify bot merged commit aac8357 into main Jan 5, 2023
@mergify mergify bot deleted the xxchan/cautious-gopher branch January 5, 2023 19:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants