Data Engineering with dbt by Roberto Zagni
Author:Roberto Zagni
Language: eng
Format: epub
Publisher: Packt Publishing Pvt. Ltd.
Published: 2023-06-29T00:00:00+00:00
How to write a macro
Writing a macro is as simple as writing your SQL inside a macro declaration in a SQL file inside the macro folder, and it would look like the following:
{% macro this_with_filter(arg1, arg2='XXXX') %} SELECT * FROM {{this}} {% if arg1 %} WHERE {{arg1}} = {{arg2}} {% endif %} {% endmacro %}
In the preceding piece of code, we have the following:
A macro named this_with_filter declared with two arguments.
An arg1 argument, which is mandatory, as it does not have a default value.
An arg2 argument, which is optional, as it does have the default value of the string XXXX.
The body of the macro, which is made of four lines that mix normal SQL and Jinja code, which looks very much like Python.
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Access | Data Mining |
Data Modeling & Design | Data Processing |
Data Warehousing | MySQL |
Oracle | Other Databases |
Relational Databases | SQL |
Algorithms of the Intelligent Web by Haralambos Marmanis;Dmitry Babenko(8252)
Azure Data and AI Architect Handbook by Olivier Mertens & Breght Van Baelen(6396)
Building Statistical Models in Python by Huy Hoang Nguyen & Paul N Adams & Stuart J Miller(6354)
Serverless Machine Learning with Amazon Redshift ML by Debu Panda & Phil Bates & Bhanu Pittampally & Sumeet Joshi(6241)
Data Wrangling on AWS by Navnit Shukla | Sankar M | Sam Palani(6020)
Driving Data Quality with Data Contracts by Andrew Jones(5983)
Learning SQL by Alan Beaulieu(5953)
Machine Learning Model Serving Patterns and Best Practices by Md Johirul Islam(5751)
Weapons of Math Destruction by Cathy O'Neil(5716)
Big Data Analysis with Python by Ivan Marin(5166)
Data Engineering with dbt by Roberto Zagni(4187)
Solidity Programming Essentials by Ritesh Modi(3829)
Time Series Analysis with Python Cookbook by Tarek A. Atwan(3681)
Pandas Cookbook by Theodore Petrou(3395)
Blockchain Basics by Daniel Drescher(3267)
Hands-On Machine Learning for Algorithmic Trading by Stefan Jansen(2880)
Feature Store for Machine Learning by Jayanth Kumar M J(2792)
Learn T-SQL Querying by Pam Lahoud & Pedro Lopes(2773)
Mastering Python for Finance by Unknown(2726)
