导入
Jinja 简介
了解 Jinja 这一模板语言的基本原理。
product_list_template.html
1{% for product in products %} 2 <div> 3 <img src={{ product.img_link }}> 4 <p> {{ product.name }} </p> 5 </div> 6{% endfor %}
1case 2 when lifetime_orders = 1 then "One-shot" 3 when lifetime_orders <= 5 then "Retained" 4 when lifetime_orders <= 10 then "Loyal" 5 else "VIP" 6end as customer_segment
1{% macro customer_segment() %} 2case 3 when lifetime_orders = 1 then "One-shot" 4 when lifetime_orders <= 5 then "Retained" 5 when lifetime_orders <= 10 then "Loyal" 6 else "VIP" 7end as customer_segment 8{% endmacro %}
1select * 2from shop_dev.raw_data.orders
1select * 2from shop_prod.raw_data.orders
1select * 2from {{ ref("orders") }}
1{% if is_incremental() %} 2 WHERE order_id > (SELECT MAX(order_id) FROM {{this}}) 3{% endif %}
1{% for i in range(5) %} 2 field_{{i}}, 3{% endfor %}
1Hello {{ first_name }}!
1Hello Emily!
1{# first_name is a variable that contains the first name of the recipient #} 2Hello {{ first_name }}!
1Hello Emily!
1SELECT * 2FROM {{ ref("this_model") }}
1SELECT * 2FROM {{ source("this_source_name", "this_source_table") }}