-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Source rowcount generic test #3279
Merged
jeff-dude
merged 8 commits into
duneanalytics:main
from
0xRobin:source_rowcount_generic_test
May 4, 2023
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
6fbe5dd
generic test for rowcount with multiple event sources
0xRobin 70b5971
fix nesting
0xRobin e513d40
fix naming
0xRobin 039f7fb
fix test
0xRobin abd0122
fix test
0xRobin 57105be
fix test
0xRobin 3a6ce94
fix test
0xRobin 139cab9
remove older tests
0xRobin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
{% test equal_rowcount_with_sources(model, evt_sources=[]) %} | ||
|
||
WITH | ||
model_count as ( | ||
select count(*) as count_a from {{ model }} | ||
) | ||
,sources_count as ( | ||
select sum(count_b) as count_b | ||
from ( | ||
{% for source in evt_sources %} | ||
select count(*) as count_b | ||
from {{ source }} | ||
where evt_block_time <= (select max(block_time) from {{ model }}) | ||
{% if not loop.last %} UNION ALL {% endif %} | ||
{% endfor %} | ||
) b | ||
) | ||
|
||
,unit_test as ( | ||
select count_a, count_b, (count_a - count_b) as diff_count | ||
from model_count | ||
full outer join sources_count | ||
on 1=1 | ||
) | ||
|
||
select * from unit_test where diff_count > 0 | ||
Comment on lines
+20
to
+26
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we need to write There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. good idea! |
||
{% endtest %} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, so this part can test the sum of events from multiple event sources.