Package: dbt-generator
dbt-generatorThis package helps in generating the base models and transform them in bulk. For sources with 10+ models, this package will save you a lot of time by generating base models in bulk and transform them for common fields. Using this package is a great way to start your modeling or onboarding new sources.InstallationTo use this package, you need dbt installed with a profile configured. You will also need to install the code-gen package from dbt Hub. Add the following to the packages.yml file in your dbt repo and rundbt depsto install dependencies.packages:
  - package: dbt-labs/codegen
    version: 0.4.0Install the package in the same environment with your dbt installation by running:pipinstalldbt-generatorThis package should be executed inside your dbt repo.Generate base modelsTo generate base models, use thedbt-generator generatecommand. This is a wrapper around thecodegencommand that will generate the base models. This is especially useful when you have a lot of models, and you want to generate them all at once.Usage: dbt-generator generate [OPTIONS]

  Gennerate base models based on a .yml source

Options:
  -s, --source-yml PATH   Source .yml file to be used
  -o, --output-path PATH  Path to write generated models
  -m, --model STRING      Model name
  -c, --custom_prefix.    Enter a Custom String Prefix for Model Filename
  --model-prefix BOOLEAN  optional prefix of source_name + "_" to the resulting modelname.sql to avoid model name collisions across sources 
  --source-index INTEGER  Index of the source to generate base models for
  --help                  Show this message and exit.Exampledbt-generatorgenerate-s./models/source.yml-o./models/staging/source_name/This will read in thesource.ymlfile and generate the base models in thestaging/source_namefolder. If you have multiple sources defined in yourymlfile, use the--source-indexflag to specify which source you want to generate base models for.Transform base models using a custom YAML fileFor the same source, you often have consistent naming conventions between tables. For example, thecreated_atandmodified_atfields are often named the same for all tables. Changing all these fields to common values across different sources is a best practice. However, doing that for all the date columns in 10+ tables is a pain.With this package, you can write atransforms.ymlfile that will be read in (the.ymlfile can be named anything). This file will contain the transforms that you want to apply to all the base models. You can just rename the fields in the base models or apply a custom SQL select to the transformed fields.Usage: dbt-generator transform [OPTIONS]

  Transform base models in a directory using a transforms.yml file

Options:
  -m, --model-path PATH       The path to models
  -t, --transforms-path PATH  Path to a .yml file containing transformations
  -o, --output-path PATH      Path to write transformed models to
  --drop-metadata BOOLEAN     (default=False) optionally drop source columns prefixed with "_" if that designates metadata columns not needed in target
  --case-sensitive BOOLEAN    (default=False) treat column names as case-sensitive - otherwise force all to lower
  --help                      Show this message and exit.Transform base models using pre-built configsSupported data warehouse:BigQuery: bq_transformSnowflake: sf_transformUsage: dbt-generator bq-transform/sf-transform [OPTIONS]

  Transform base models in a directory for BigQuery source

Options:
  -m, --model-path PATH        The path to models
  -o, --output-path PATH       Path to write transformed models to
  --drop-metadata BOOLEAN      (default=False) optionally drop source columns prefixed with "_" if that designates metadata columns not needed in target
  --case-sensitive BOOLEAN     (default=False) treat column names as case-sensitive - otherwise force all to lower
  --split-columns BOOLEAN      Split column names. E.g. currencycode =>
                               currency_code
  --id-as-int BOOLEAN          Convert id to int
  --convert-timestamp BOOLEAN  Convert timestamp to datetime
  --help                       Show this message and exit.ExampleID:name:IDsql:CAST(ID as INT64)CREATED_TIME:name:CREATED_ATUPDATED_TIME:name:MODIFIED_ATDATE_START:name:START_ATDATE_STOP:name:STOP_ATThis.ymlfile when applied to all models in thestaging/source_namefolder will cast allIDfield to INT64 and rename all the date columns to a value in thenamekey. For example,CREATED_TIMEwill be renamed toCREATED_ATandDATE_STARTwill be renamed toSTART_AT. If nosqlis provided, the package will just rename the field. If asqlis provided, the package will execute the SQL and rename the field using thenamekey.dbt-generatortransform-m./models/staging/source_name/-t./transforms.ymlThis will transform all models in thestaging/source_namefolder using thetransforms.ymlfile. You can also drop the metadata by setting thedrop-metadataflag totrue(dropping columns start with_). The--case-sensitiveflag will determine if the transforms will use case-sensitive names or not.LimitationsHere are some of the limitations of the current release. If you want to contribute, please open an issue or a pull request.Transforms only works with model generated with the code-gen package.You cannot transform a model that has already been transformed- transformation logic assumes base model contains just a list of column names with no aliases or SQL logic addedYou cannot use wild card in fields selection for transforms (e.g.*_id)Limited test coverageNo error handling yet