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

Add supported languages to materializations #5695

Merged
merged 5 commits into from
Aug 24, 2022
Merged

Conversation

stu-k
Copy link
Contributor

@stu-k stu-k commented Aug 22, 2022

resolves #5569

Description

Adds support for materializations to have supported languages. If not set, this default to sql.

Checklist

@stu-k stu-k requested a review from a team August 22, 2022 15:37
@stu-k stu-k requested review from a team as code owners August 22, 2022 15:37
@stu-k stu-k requested review from ChenyuLInx and emmyoop August 22, 2022 15:37
@cla-bot cla-bot bot added the cla:yes label Aug 22, 2022
@github-actions
Copy link
Contributor

Thank you for your pull request! We could not find a changelog entry for this change. For details on how to document a change, see the contributing guide.

@stu-k stu-k removed request for a team, emmyoop and ChenyuLInx August 22, 2022 17:11
Copy link
Contributor

@ChenyuLInx ChenyuLInx left a comment

Choose a reason for hiding this comment

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

Looks great!
Just some minor questions regarding get_supported_languages.



def get_supported_languages(node: jinja2.nodes.Macro) -> List[ModelLanguage]:
no_args = not node.args or not node.defaults
Copy link
Contributor

Choose a reason for hiding this comment

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

I am assuming the length of args is always gonna be longer than defaults(contain both args and kwargs)? So node.defaults doesn't need to be checked here?


def get_supported_languages(node: jinja2.nodes.Macro) -> List[ModelLanguage]:
no_args = not node.args or not node.defaults
dif_args_and_defaults = len(node.args) != len(node.defaults)
Copy link
Contributor

Choose a reason for hiding this comment

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

This could be causing issue if we decided to add an arg to materialization Macro in the future. Since kwargs are always going to be after args, we can use the index to end to get things.

node.args = ["arg1", "supported_language", "another_key_for_kwarg"]
node.defaults = [['sql'], {"something_else": 1}]

you can get supported language by node.defaults[-(len(node.args) - lang_idx)]

@ChenyuLInx ChenyuLInx requested a review from gshank August 24, 2022 18:19
Copy link
Contributor

@gshank gshank left a comment

Choose a reason for hiding this comment

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

Looks good!

@ChenyuLInx
Copy link
Contributor

Screen Shot 2022-08-24 at 12 07 54 PM

Also tested with a view model locally

@ChenyuLInx ChenyuLInx merged commit 5466fa5 into main Aug 24, 2022
@ChenyuLInx ChenyuLInx deleted the stu/mat-lang-support branch August 24, 2022 19:08
VersusFacit pushed a commit that referenced this pull request Sep 5, 2022
* Add supported languages to materializations

* Add changie entry

* Linting

* add more error and only get supported language for materialization macro, update schema

* fix test and add more check

Co-authored-by: Chenyu Li <chenyu.li@dbtlabs.com>
agoblet pushed a commit to BigDataRepublic/dbt-core that referenced this pull request Sep 16, 2022
* Add supported languages to materializations

* Add changie entry

* Linting

* add more error and only get supported language for materialization macro, update schema

* fix test and add more check

Co-authored-by: Chenyu Li <chenyu.li@dbtlabs.com>
josephberni pushed a commit to Gousto/dbt-core that referenced this pull request Sep 16, 2022
* Add supported languages to materializations

* Add changie entry

* Linting

* add more error and only get supported language for materialization macro, update schema

* fix test and add more check

Co-authored-by: Chenyu Li <chenyu.li@dbtlabs.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[CT-968] [Feature] Disallow “view” materialization if Python
3 participants