Created
January 31, 2025 01:57
-
-
Save yoshiokatsuneo/84c8a490d27f4d5d60cc78153e3f0b8c to your computer and use it in GitHub Desktop.
This file contains hidden or 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
create or replace procedure yoshioka_test1.assert_table_count_equal(table_name1 string, table_name2 string) | |
begin | |
execute immediate ''' | |
with | |
results as ( | |
select | |
(select count(*) from ''' || table_name1 || ''') as expected, | |
(select count(*) from ''' || table_name2 || ''') as actual, | |
) | |
select * from results | |
where | |
if(expected = actual, true, error('Not equal row counts. ''' || table_name1 || ''': ' || expected || ' rows. ''' || table_name2 || ''': ' || actual || ' rows.')) | |
'''; | |
end; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment