-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
implement type_boolean macro #5875
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
kind: Features | ||
body: add type_boolean as a data type macro | ||
time: 2022-09-19T23:14:14.9871+01:00 | ||
custom: | ||
Author: jpmmcneill | ||
Issue: "5739" | ||
PR: "5875" |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,24 @@ | ||||||||||||||||||||||||||||||||||||
import pytest | ||||||||||||||||||||||||||||||||||||
from dbt.tests.adapter.utils.data_types.base_data_type_macro import BaseDataTypeMacro | ||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||
seeds__expected_csv = """boolean_col | ||||||||||||||||||||||||||||||||||||
True | ||||||||||||||||||||||||||||||||||||
""".lstrip() | ||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||
models__actual_sql = """ | ||||||||||||||||||||||||||||||||||||
select cast('True' as {{ type_boolean() }}) as boolean_col | ||||||||||||||||||||||||||||||||||||
""" | ||||||||||||||||||||||||||||||||||||
Comment on lines
+4
to
+10
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. Probably want to cover both boolean options at the very least.
Suggested change
Even betterBut test cases covering the truth tables for conjunction, disjunction, and negation would be even better. That way, we are verifying that everything is acting like booleans. Something like the following untested code:
Best? 🤷Even though If we are feeling extra magnanimous, we could change all the True/False values in the seeds to be I'm hoping it wouldn't be necessary, but we could update the
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. Update: The "Even better" example I gave above didn't actually test the Something like this should fix that situation:
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. Cheers @dbeatty10. I'll take a second pass at this later today :) |
||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||
class BaseTypeBoolean(BaseDataTypeMacro): | ||||||||||||||||||||||||||||||||||||
@pytest.fixture(scope="class") | ||||||||||||||||||||||||||||||||||||
def seeds(self): | ||||||||||||||||||||||||||||||||||||
return {"expected.csv": seeds__expected_csv} | ||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||
@pytest.fixture(scope="class") | ||||||||||||||||||||||||||||||||||||
def models(self): | ||||||||||||||||||||||||||||||||||||
return {"actual.sql": self.interpolate_macro_namespace(models__actual_sql, "type_boolean")} | ||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||
class TestTypeBoolean(BaseTypeBoolean): | ||||||||||||||||||||||||||||||||||||
pass |
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.
every other comment had this many dashes 🙃