Skip to content

create a bigquery template#1502

Merged
karakanb merged 2 commits intomainfrom
bigquery-template
Apr 3, 2026
Merged

create a bigquery template#1502
karakanb merged 2 commits intomainfrom
bigquery-template

Conversation

@karakanb
Copy link
Copy Markdown
Contributor

@karakanb karakanb commented Jan 9, 2026

No description provided.

turtleDev
turtleDev previously approved these changes Jan 9, 2026
terzioglub
terzioglub previously approved these changes Jan 9, 2026
Copy link
Copy Markdown
Contributor

@greptile-apps greptile-apps Bot left a comment

Choose a reason for hiding this comment

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

Greptile Summary

This PR introduces a new BigQuery template for the Bruin project. The template includes:

  • A basic pipeline configuration with BigQuery-specific settings
  • Example SQL assets demonstrating table creation with schema constraints
  • A seed asset for loading CSV data into BigQuery
  • Reusable Jinja macros organized into three categories:
    • Aggregations (count_by, sum_by, top_n)
    • Filters (date_range, recent_records, filter_null, in_list)
    • Transformations (pivot_sum, deduplicate, generate_surrogate_key, safe_divide)
  • Comprehensive README with setup instructions and macro usage examples

The template follows the same structure as the existing DuckDB template, adapted for BigQuery-specific SQL syntax and functions. The macros use BigQuery-native functions like SAFE_DIVIDE, DATE_SUB, and TO_HEX(MD5()) where appropriate.

Comment on lines +35 to +37
{% macro safe_divide(numerator, denominator, default=0) -%}
SAFE_DIVIDE({{ numerator }}, {{ denominator }})
{%- endmacro %}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[P3] The default parameter is unused. BigQuery's SAFE_DIVIDE returns NULL on division by zero, not a configurable default. Either remove the parameter or use IFNULL(SAFE_DIVIDE(...), {{ default }}).

Prompt To Fix With AI
This is a comment left during a code review.
Path: templates/bigquery/macros/transformations.sql
Line: 35:37

Comment:
[P3] The `default` parameter is unused. BigQuery's `SAFE_DIVIDE` returns NULL on division by zero, not a configurable default. Either remove the parameter or use `IFNULL(SAFE_DIVIDE(...), {{ default }})`.

How can I resolve this? If you propose a fix, please make it concise.

@@ -0,0 +1,3 @@
name,networking_through,position,contact_date
Y,LinkedIn,SDE,2024-01-01
B,LinkedIn,SDE 2,2024-01-01
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[P3] CSV file should end with a newline for better compatibility with some parsers.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Prompt To Fix With AI
This is a comment left during a code review.
Path: templates/bigquery/assets/seed.csv
Line: 3:3

Comment:
[P3] CSV file should end with a newline for better compatibility with some parsers.

<sub>Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!</sub>

How can I resolve this? If you propose a fix, please make it concise.

Copy link
Copy Markdown
Contributor

@arsalann arsalann left a comment

Choose a reason for hiding this comment

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

nothing major, just some minor comments

Comment thread templates/bigquery/assets/example.sql Outdated

columns:
- name: id
type: int64
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

if i remember correctly, int64 is not correct and it should be integer instead

Comment thread templates/bigquery/assets/example.sql Outdated
- name: name
type: string
description: Just a name
update_on_merge: true
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

is this necessary if there's no merge strategy? I don't think it would break but it might be confusing

/* @bruin

materialization:
type: table
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

would be nice to also demonstrate cluster and partition

Comment on lines +19 to +20
checks:
- name: not_null
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

already demonstrated not_null check above, would be nice to demonstrate nullable tag

Comment on lines +19 to +20
description: Number of people per country

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

should we demonstrate a custom check here?

{{ group_column }},
SUM({{ sum_column }}) as total
FROM {{ table }}
GROUP BY {{ group_column }}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

can also just be group by all 😅 sorry just being picky

@karakanb karakanb dismissed stale reviews from terzioglub and turtleDev via 3f3a5e3 January 9, 2026 21:08
@karakanb karakanb merged commit 53aac60 into main Apr 3, 2026
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.

4 participants