update projects to packages
This commit is contained in:
0
transform/sqlmesh_materia/README.md
Normal file
0
transform/sqlmesh_materia/README.md
Normal file
0
transform/sqlmesh_materia/audits/.gitkeep
Normal file
0
transform/sqlmesh_materia/audits/.gitkeep
Normal file
@@ -0,0 +1,9 @@
|
||||
AUDIT (
|
||||
name assert_positive_order_ids,
|
||||
);
|
||||
|
||||
SELECT *
|
||||
FROM @this_model
|
||||
WHERE
|
||||
item_id < 0
|
||||
|
||||
59
transform/sqlmesh_materia/config.yaml
Normal file
59
transform/sqlmesh_materia/config.yaml
Normal file
@@ -0,0 +1,59 @@
|
||||
# --- Gateway Connection ---
|
||||
gateways:
|
||||
duckdb:
|
||||
connection:
|
||||
# For more information on configuring the connection to your execution engine, visit:
|
||||
# https://sqlmesh.readthedocs.io/en/stable/reference/configuration/#connection
|
||||
# https://sqlmesh.readthedocs.io/en/stable/integrations/engines/duckdb/#connection-options
|
||||
type: duckdb
|
||||
database: db.db
|
||||
# concurrent_tasks: 1
|
||||
# register_comments: True
|
||||
# pre_ping: False
|
||||
# pretty_sql: False
|
||||
# catalogs:
|
||||
# extensions:
|
||||
# connector_config:
|
||||
# secrets:
|
||||
# filesystems:
|
||||
# token:
|
||||
|
||||
default_gateway: duckdb
|
||||
|
||||
# --- Model Defaults ---
|
||||
# https://sqlmesh.readthedocs.io/en/stable/reference/model_configuration/#model-defaults
|
||||
|
||||
model_defaults:
|
||||
dialect: duckdb
|
||||
start: 2025-07-07 # Start date for backfill history
|
||||
cron: '@daily' # Run models daily at 12am UTC (can override per model)
|
||||
|
||||
# --- Linting Rules ---
|
||||
# Enforce standards for your team
|
||||
# https://sqlmesh.readthedocs.io/en/stable/guides/linter/
|
||||
|
||||
linter:
|
||||
enabled: true
|
||||
rules:
|
||||
- ambiguousorinvalidcolumn
|
||||
- invalidselectstarexpansion
|
||||
|
||||
# FLOW: Minimal prompts, automatic changes, summary output
|
||||
# https://sqlmesh.readthedocs.io/en/stable/reference/configuration/#plan
|
||||
|
||||
plan:
|
||||
no_diff: true # Hide detailed text differences for changed models
|
||||
no_prompts: true # No interactive prompts
|
||||
auto_apply: true # Apply changes automatically
|
||||
|
||||
# --- Optional: Set a default target environment ---
|
||||
# This is intended for local development to prevent users from accidentally applying plans to the prod environment.
|
||||
# It is a development only config and should NOT be committed to your git repo.
|
||||
# https://sqlmesh.readthedocs.io/en/stable/guides/configuration/#default-target-environment
|
||||
|
||||
# Uncomment the following line to use a default target environment derived from the logged in user's name.
|
||||
# default_target_environment: dev_{{ user() }}
|
||||
|
||||
# Example usage:
|
||||
# sqlmesh plan # Automatically resolves to: sqlmesh plan dev_yourname
|
||||
# sqlmesh plan prod # Specify `prod` to apply changes to production
|
||||
BIN
transform/sqlmesh_materia/db.db
Normal file
BIN
transform/sqlmesh_materia/db.db
Normal file
Binary file not shown.
0
transform/sqlmesh_materia/macros/.gitkeep
Normal file
0
transform/sqlmesh_materia/macros/.gitkeep
Normal file
0
transform/sqlmesh_materia/macros/__init__.py
Normal file
0
transform/sqlmesh_materia/macros/__init__.py
Normal file
0
transform/sqlmesh_materia/models/.gitkeep
Normal file
0
transform/sqlmesh_materia/models/.gitkeep
Normal file
15
transform/sqlmesh_materia/models/example/full_model.sql
Normal file
15
transform/sqlmesh_materia/models/example/full_model.sql
Normal file
@@ -0,0 +1,15 @@
|
||||
MODEL (
|
||||
name sqlmesh_example.full_model,
|
||||
kind FULL,
|
||||
cron '@daily',
|
||||
grain item_id,
|
||||
audits (assert_positive_order_ids),
|
||||
);
|
||||
|
||||
SELECT
|
||||
item_id,
|
||||
COUNT(DISTINCT id) AS num_orders,
|
||||
FROM
|
||||
sqlmesh_example.incremental_model
|
||||
GROUP BY item_id
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
MODEL (
|
||||
name sqlmesh_example.incremental_model,
|
||||
kind INCREMENTAL_BY_TIME_RANGE (
|
||||
time_column event_date
|
||||
),
|
||||
start '2020-01-01',
|
||||
cron '@daily',
|
||||
grain (id, event_date)
|
||||
);
|
||||
|
||||
SELECT
|
||||
id,
|
||||
item_id,
|
||||
event_date,
|
||||
FROM
|
||||
sqlmesh_example.seed_model
|
||||
WHERE
|
||||
event_date BETWEEN @start_date AND @end_date
|
||||
|
||||
13
transform/sqlmesh_materia/models/example/seed_model.sql
Normal file
13
transform/sqlmesh_materia/models/example/seed_model.sql
Normal file
@@ -0,0 +1,13 @@
|
||||
MODEL (
|
||||
name sqlmesh_example.seed_model,
|
||||
kind SEED (
|
||||
path '../seeds/seed_data.csv'
|
||||
),
|
||||
columns (
|
||||
id INTEGER,
|
||||
item_id INTEGER,
|
||||
event_date DATE
|
||||
),
|
||||
grain (id, event_date)
|
||||
);
|
||||
|
||||
22
transform/sqlmesh_materia/pyproject.toml
Normal file
22
transform/sqlmesh_materia/pyproject.toml
Normal file
@@ -0,0 +1,22 @@
|
||||
[project]
|
||||
name = "sqlmesh-materia"
|
||||
version = "0.1.0"
|
||||
description = "Add your description here"
|
||||
readme = "README.md"
|
||||
authors = [
|
||||
{ name = "Deeman", email = "hendriknote@gmail.com" }
|
||||
]
|
||||
requires-python = ">=3.13"
|
||||
dependencies = [
|
||||
"sqlmesh>=0.200.0",
|
||||
]
|
||||
|
||||
[project.scripts]
|
||||
plan = "sqlmesh plan"
|
||||
|
||||
[build-system]
|
||||
requires = ["hatchling"]
|
||||
build-backend = "hatchling.build"
|
||||
|
||||
[tool.hatch.build.targets.wheel]
|
||||
packages = ["sqlmesh_materia"]
|
||||
0
transform/sqlmesh_materia/seeds/.gitkeep
Normal file
0
transform/sqlmesh_materia/seeds/.gitkeep
Normal file
8
transform/sqlmesh_materia/seeds/seed_data.csv
Normal file
8
transform/sqlmesh_materia/seeds/seed_data.csv
Normal file
@@ -0,0 +1,8 @@
|
||||
id,item_id,event_date
|
||||
1,2,2020-01-01
|
||||
2,1,2020-01-01
|
||||
3,3,2020-01-03
|
||||
4,1,2020-01-04
|
||||
5,1,2020-01-05
|
||||
6,1,2020-01-06
|
||||
7,1,2020-01-07
|
||||
|
0
transform/sqlmesh_materia/tests/.gitkeep
Normal file
0
transform/sqlmesh_materia/tests/.gitkeep
Normal file
19
transform/sqlmesh_materia/tests/test_full_model.yaml
Normal file
19
transform/sqlmesh_materia/tests/test_full_model.yaml
Normal file
@@ -0,0 +1,19 @@
|
||||
test_example_full_model:
|
||||
model: sqlmesh_example.full_model
|
||||
inputs:
|
||||
sqlmesh_example.incremental_model:
|
||||
rows:
|
||||
- id: 1
|
||||
item_id: 1
|
||||
- id: 2
|
||||
item_id: 1
|
||||
- id: 3
|
||||
item_id: 2
|
||||
outputs:
|
||||
query:
|
||||
rows:
|
||||
- item_id: 1
|
||||
num_orders: 2
|
||||
- item_id: 2
|
||||
num_orders: 1
|
||||
|
||||
Reference in New Issue
Block a user