A dbt package to SELECT * without SELECT *!
🎯 Selective Column Inclusion:
Generate exhaustive SELECT expressions for models and sources removing your old SELECT * from your queries, improving readability when compiled.
🚫 Configurable:
Use the optional except argument to tailor the output by excluding specific columns.
Enhance query clarity with the alias argument, especially useful for multiple model instances.
🌐 Cross-Platform Compatibility: Supports all data platforms, ensuring flexibility in your data stack.
dbt-star currently supports dbt 1.7.x or higher.
Check dbt github package for the latest installation instructions, or read the docs for more information on installing packages.
Include in packages.yml
packages:
- git: https://github.com/AxelThevenot/dbt-star.git
revision: 0.1.0
# <see https://github.com/AxelThevenot/dbt-star/releases/latest> for the latest version tagThis package supports all data platforms:
- AllowDB
- BigQuery
- Databricks
- Dremio
- Postgres
- Redshift
- Snowflake
- Spark
- Starbust/Trino
- Microsoft Fabric
- Azure Synapse
- Teradata
- ...
For latest release, see https://github.com/AxelThevenot/dbt-star/releases
This package do not have dependencies.
This package do not have variables.
You can see the basic star example here.
For even more basic. This package is made to remove SELECT * from your queries.
-- Old query
SELECT
*
FROM {{ ref('my_model') }}
-- Reworked query
SELECT
{{ dbt_star.star('my_model') | indent(4) }} -- reads from the `.yml` configuration
FROM {{ ref('my_model') }}
-- Compiled query
SELECT
column_1,
column_2,
column_3
FROM {{ ref('my_model') }}star() generates a list of column names for a given model as your SELECT expression.
It is callable the same way you call the native dbt ref(). (version argument is not supported yet)
WITH
final AS (
SELECT
{{ dbt_star.star('my_model') }},
CURRENT_TIMESTAMP() AS ingested_at
FROM {{ ref('my_model') }}
)
SELECT
*
FROM finalYou can call star() macro without providing model name and package. It will consider the current model configuration.
WITH
final AS (
SELECT
{{ dbt_star.star('my_model') }},
CURRENT_TIMESTAMP() AS ingested_at
FROM {{ ref('my_model') }}
)
SELECT
{{ dbt_star.star() }}
FROM finalIt supports optional except and alias arguments.
star_source() generates a list of column names for a given source as your SELECT expression.
It is callable the same way you call the native dbt source().
WITH
final AS (
SELECT
{{ dbt_star.star_source('source_name', 'table_name') }},
CURRENT_TIMESTAMP() AS ingested_at
FROM {{ source('source_name', 'table_name') }}
)
SELECT
*
FROM finalIt supports optional except and alias arguments.
except (optional[list[str]]) argument is compatible with star() and [star_source()] macros.
If provided, it contains the list of columns to exclude from the generated SELECT expressions.
SELECT
{{ dbt_star.star('my_model', except=['i_dont_want_you', 'you_neither']) }}
FROM {{ ref('my_model') }}alias (optional[str]) argument is compatible with star() and [star_source()] macros.
If provided, it prefixes the list of columns from the generated SELECT expressions.
SELECT
{{ dbt_star.star('my_model', alias='model_1') | indent(4) }},
model_2.column_a,
model_2.column_b,
model_2.column_c
FROM {{ ref('my_model') }} AS model_1
LEFT JOIN {{ ref('my_model') }} AS model_2
ON model_1.column_1 = model_2.column_1Is compiled as
SELECT
model_1.column_1,
model_1.column_2,
model_1.column_3,
...
model_2.column_a,
model_2.column_b,
model_2.column_c
FROM {{ ref('my_model') }} AS model_1
LEFT JOIN {{ ref('my_model') }} AS model_2
ON model_1.column_1 = model_2.column_1If you want to contribute, please open a Pull Request or an Issue on this repo. Feel free to reach me Linkedin.
If you have any question, please open a new Issue or feel free to reach out to Linkedin
Happy coding with dbt-star!
