Favorita: dbt Macros for BQML Features

Three small dbt macros that keep the project DRY: one builds the BQML feature column list, one builds the prediction feature list, and one standardizes incremental staging. Change features in one place, not ten.

Primary Outcome

Reusable macros that centralize feature lists and incremental logic so changes happen once.

Solution

Macros that centralize feature lists and incremental logic, so a single edit propagates everywhere the next build runs.

Deliverables

  • get_bqml_feature_columns — assembles training feature columns

  • get_bqml_prediction_features — assembles prediction-time features

  • staging_incremental — standard incremental staging pattern

Strategic Context

Repetition is where data pipelines rot. The same column list copied into five models becomes five chances to introduce a mismatch. Macros are dbt's answer to that, and feature lists are the highest-value place to use them.

Technical Architecture

Repetition is where data pipelines rot. The same column list copied into five models becomes five chances to introduce a mismatch. Macros are dbt's answer to that, and feature lists are the highest-value place to use them.

Problem Statement

Feature column lists copied across train and predict models drift apart, causing models that fail or score on the wrong inputs.

Links

What's Included

The dbt/macros directory: the two BQML feature macros and the incremental staging macro, each documented inline.

FAQs

Are these macros Favorita-specific?

The feature macros encode this project's columns, but the pattern — centralizing feature lists in a macro — transfers to any project.

Do I need to know Jinja?

Basic Jinja helps, but you can adapt these by editing the column lists without writing macros from scratch.

Tech Stack

Tool 1

Tool 4

Tool 4

Tool 3

Tool 2

Tool 4

Primary Outcome

Reusable macros that centralize feature lists and incremental logic so changes happen once.

Problem Statement

Feature column lists copied across train and predict models drift apart, causing models that fail or score on the wrong inputs.

Solution

Macros that centralize feature lists and incremental logic, so a single edit propagates everywhere the next build runs.

Links

Deliverables

  • get_bqml_feature_columns — assembles training feature columns

  • get_bqml_prediction_features — assembles prediction-time features

  • staging_incremental — standard incremental staging pattern

What's Included

The dbt/macros directory: the two BQML feature macros and the incremental staging macro, each documented inline.

Strategic Context

Repetition is where data pipelines rot. The same column list copied into five models becomes five chances to introduce a mismatch. Macros are dbt's answer to that, and feature lists are the highest-value place to use them.

FAQs

Are these macros Favorita-specific?

The feature macros encode this project's columns, but the pattern — centralizing feature lists in a macro — transfers to any project.

Do I need to know Jinja?

Basic Jinja helps, but you can adapt these by editing the column lists without writing macros from scratch.

Technical Architecture

Repetition is where data pipelines rot. The same column list copied into five models becomes five chances to introduce a mismatch. Macros are dbt's answer to that, and feature lists are the highest-value place to use them.

Tech Stack

Tool 1

Tool 4

Tool 4

Tool 3

Tool 2

Tool 4