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

Source for specific tables #51

Merged
merged 7 commits into from
Jun 22, 2022

Conversation

rahulj51
Copy link
Contributor

@rahulj51 rahulj51 commented Nov 21, 2021

This is a:

  • bug fix PR with no breaking changes — please ensure the base branch is main
  • new functionality — please ensure the base branch is the latest dev/ branch
  • a breaking change — please ensure the base branch is the latest dev/ branch

Description & motivation

Resolves #50
By default, generate_source generates the source definitions for all tables in a schema. With very big schemas, sometimes, you only wish to generate the schema for a selected set of tables. This PR adds an optional arg called table_names to generate_source that takes a list of tables.

Note on Testing

The instructions for testing locally were not clear but with some trial and error, the following steps were performed to run the integration tests

  1. Created a bigquery profile called integration_tests
  2. Ran the create_source_table operation using run-operation from console.
  3. Ran dbt sed to create the ...raw_data schema and the data__a_relation table within.
  4. Ran all integration tests
  5. Added a new test to check the added feature

Also tested on a real-life dbt project by including the package locally and running the generate_source command.

Checklist

  • I have verified that these changes work locally
  • I have updated the README.md (if applicable)
  • I have added tests & descriptions to my models (and macros if applicable)
  • I have added an entry to CHANGELOG.md

@rahulj51 rahulj51 changed the base branch from main to dev/0.4.0 November 21, 2021 18:05
Copy link
Contributor

@dbeatty10 dbeatty10 left a comment

Choose a reason for hiding this comment

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

Thank you for putting this together @rahulj51 ! 💪

Nice work putting together the integration tests too.

I've left comments for some very small updates. They are small enough that I will try merging them. I'll reach out to you if I need your help on those.

README.md Outdated Show resolved Hide resolved
@@ -14,7 +14,7 @@


---
{% macro generate_source(schema_name, database_name=target.database, generate_columns=False, include_descriptions=False) %}
{% macro generate_source(schema_name, database_name=target.database, table_names=None, generate_columns=False, include_descriptions=False) %}
Copy link
Contributor

Choose a reason for hiding this comment

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

Sliding to the end of the signature so that it isn't a breaking change for anyone using positional arguments (rather than keyword arguments):

Suggested change
{% macro generate_source(schema_name, database_name=target.database, table_names=None, generate_columns=False, include_descriptions=False) %}
{% macro generate_source(schema_name, database_name=target.database, generate_columns=False, include_descriptions=False, table_names=none) %}

macros/generate_source.sql Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
@dbeatty10 dbeatty10 changed the base branch from dev/0.4.0 to main June 22, 2022 20:15
Copy link
Contributor

@dbeatty10 dbeatty10 left a comment

Choose a reason for hiding this comment

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

@rahulj51 thank you again for adding this feature 🏅

It all looks good, and it will be included in the next release.

@dbeatty10 dbeatty10 merged commit 1fb5c23 into dbt-labs:main Jun 22, 2022
jeremyholtzman pushed a commit that referenced this pull request Apr 10, 2023
* Addig another parameter to pass a list of tables to generate_source

* Addig another parameter to pass a list of tables to generate_source

* Updated README

* Updated changelog

* Apply suggestions from code review

* Update integration_tests/tests/test_generate_source_some_tables.sql

Co-authored-by: Doug Beatty <44704949+dbeatty10@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Pass an (optional) list of table-names to generate_source
2 participants