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

SELECT文内で assertを手軽にする #46

Open
takegue opened this issue Nov 6, 2022 · 0 comments
Open

SELECT文内で assertを手軽にする #46

takegue opened this issue Nov 6, 2022 · 0 comments
Assignees

Comments

@takegue
Copy link
Owner

takegue commented Nov 6, 2022

値の比較を行いたい時にassertのような関数が一つあると便利である。
BigQueryにはerror関数があるがこれをラップすることで次のようなassertを用意すると便利である

create temp function `assert`(expected ANY TYPE, actual ANY TYPE)
as (
  if(expected = actual, null, error(format("Expected %T: %T", expected, actual)))
);

select assert('hoge', 'hoge')

関数をひとつはさむことで、タイプチェックにもなる

@takegue takegue self-assigned this Nov 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant