Skip to content

Commit ef62a3e

Browse files
committed
Add SQLMesh tests
1 parent bc8605d commit ef62a3e

File tree

2 files changed

+217
-0
lines changed

2 files changed

+217
-0
lines changed

sqlmesh/config.yaml

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
gateways:
2+
bq:
3+
connection:
4+
type: bigquery
5+
project: {{ env_var('PROJECT', 'project-to-update') }}
6+
execution_project: {{ env_var('EXECUTION_PROJECT', 'execution-project-to-update') }}
7+
location: {{ env_var('LOCATION', 'US') }}
8+
method: {{ env_var('METHOD', 'oauth') }}
9+
priority: {{ env_var('PRIORITY', 'interactive') }}
10+
keyfile: {{ env_var('GOOGLE_APPLICATION_CREDENTIALS', 'gcp_credentials.json') }}
11+
12+
state_connection:
13+
type: duckdb
14+
database: bq_local_state.db
15+
16+
local:
17+
connection:
18+
type: duckdb
19+
database: test.db
20+
21+
state_connection:
22+
type: duckdb
23+
database: duckdb_local_state.db
24+
25+
default_gateway: local
26+
27+
model_defaults:
28+
dialect: bigquery
29+
start: 2024-12-01

sqlmesh/tests/test_unused_tables.yaml

+188
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,188 @@
1+
test_unused_tables:
2+
model: dbt_cou.unused_tables
3+
inputs:
4+
dbt_cou.table_reference_incremental:
5+
rows:
6+
- project_id: "my-project"
7+
dataset_id: "my_dataset"
8+
table_id: "my_table"
9+
day: "2022-01-01"
10+
- project_id: "my-project"
11+
dataset_id: "my_dataset"
12+
table_id: "my_table"
13+
day: "2023-01-01"
14+
- project_id: "my-project"
15+
dataset_id: "my_dataset"
16+
table_id: "my_table_2"
17+
day: "2022-01-01"
18+
19+
dbt_cou.table_and_storage_with_cost:
20+
rows:
21+
- project_id: "my-project"
22+
dataset_id: "my_dataset"
23+
table_id: "my_table"
24+
is_insertable_into: "YES"
25+
is_typed: "NO"
26+
ddl: "CREATE TABLE my_table"
27+
default_collation_name: "utf8"
28+
project_number: 123456
29+
creation_time: "2022-01-01T00:00:00"
30+
deleted: false
31+
storage_last_modified_time: "2022-01-01T12:00:00"
32+
total_rows: 1000
33+
total_partitions: 1
34+
total_logical_bytes: 1073741824
35+
active_logical_bytes: 1073741824
36+
long_term_logical_bytes: 0
37+
total_physical_bytes: 536870912
38+
active_physical_bytes: 536870912
39+
long_term_physical_bytes: 0
40+
time_travel_physical_bytes: 53687091
41+
fail_safe_physical_bytes: 26843545
42+
table_type: "BASE TABLE"
43+
active_logical_bytes_cost: 0.02
44+
long_term_logical_bytes_cost: 0.0
45+
active_physical_bytes_cost: 0.04
46+
time_travel_physical_bytes_cost: 0.004
47+
fail_safe_physical_bytes_cost: 0.002
48+
long_term_physical_bytes_cost: 0.0
49+
factored_table_id: "my_table"
50+
total_logical_tb: 0.001
51+
total_physical_tb: 0.0005
52+
logical_cost_monthly_forecast: 0.02
53+
physical_cost_monthly_forecast: 0.04
54+
physical_cost_monthly_forecast_with_zero_time_travel_and_fail_safe: 0.034
55+
time_travel_per_active_byte_ratio: 0.1
56+
fail_safe_per_active_byte_ratio: 0.05
57+
active_compression_ratio: 2.0
58+
long_term_compression_ratio: null
59+
prefer_physical_pricing_model: false
60+
storage_pricing_model_difference: 0.02
61+
62+
- project_id: "my-project"
63+
dataset_id: "my_dataset"
64+
table_id: "my_table_2"
65+
is_insertable_into: "YES"
66+
is_typed: "NO"
67+
ddl: "CREATE TABLE my_table2"
68+
default_collation_name: "utf8"
69+
project_number: 123456
70+
creation_time: "2022-01-01T00:00:00"
71+
deleted: false
72+
storage_last_modified_time: "2022-01-01T12:00:00"
73+
total_rows: 1000
74+
total_partitions: 1
75+
total_logical_bytes: 1073741824
76+
active_logical_bytes: 1073741824
77+
long_term_logical_bytes: 0
78+
total_physical_bytes: 536870912
79+
active_physical_bytes: 536870912
80+
long_term_physical_bytes: 0
81+
time_travel_physical_bytes: 53687091
82+
fail_safe_physical_bytes: 26843545
83+
table_type: "BASE TABLE"
84+
active_logical_bytes_cost: 0.02
85+
long_term_logical_bytes_cost: 0.0
86+
active_physical_bytes_cost: 0.04
87+
time_travel_physical_bytes_cost: 0.004
88+
fail_safe_physical_bytes_cost: 0.002
89+
long_term_physical_bytes_cost: 0.0
90+
factored_table_id: "my_table"
91+
total_logical_tb: 0.001
92+
total_physical_tb: 0.0005
93+
logical_cost_monthly_forecast: 0.02
94+
physical_cost_monthly_forecast: 0.04
95+
physical_cost_monthly_forecast_with_zero_time_travel_and_fail_safe: 0.034
96+
time_travel_per_active_byte_ratio: 0.1
97+
fail_safe_per_active_byte_ratio: 0.05
98+
active_compression_ratio: 2.0
99+
long_term_compression_ratio: null
100+
prefer_physical_pricing_model: false
101+
storage_pricing_model_difference: 0.02
102+
103+
outputs:
104+
query:
105+
rows:
106+
- last_used_date: "2023-01-01"
107+
project_id: "my-project"
108+
dataset_id: "my_dataset"
109+
table_id: "my_table"
110+
is_insertable_into: "YES"
111+
is_typed: "NO"
112+
ddl: "CREATE TABLE my_table"
113+
default_collation_name: "utf8"
114+
project_number: 123456
115+
creation_time: "2022-01-01T00:00:00"
116+
deleted: false
117+
storage_last_modified_time: "2022-01-01T12:00:00"
118+
total_rows: 1000
119+
total_partitions: 1
120+
total_logical_bytes: 1073741824
121+
active_logical_bytes: 1073741824
122+
long_term_logical_bytes: 0
123+
total_physical_bytes: 536870912
124+
active_physical_bytes: 536870912
125+
long_term_physical_bytes: 0
126+
time_travel_physical_bytes: 53687091
127+
fail_safe_physical_bytes: 26843545
128+
table_type: "BASE TABLE"
129+
active_logical_bytes_cost: 0.02
130+
long_term_logical_bytes_cost: 0.0
131+
active_physical_bytes_cost: 0.04
132+
time_travel_physical_bytes_cost: 0.004
133+
fail_safe_physical_bytes_cost: 0.002
134+
long_term_physical_bytes_cost: 0.0
135+
factored_table_id: "my_table"
136+
total_logical_tb: 0.001
137+
total_physical_tb: 0.0005
138+
logical_cost_monthly_forecast: 0.02
139+
physical_cost_monthly_forecast: 0.04
140+
physical_cost_monthly_forecast_with_zero_time_travel_and_fail_safe: 0.034
141+
time_travel_per_active_byte_ratio: 0.1
142+
fail_safe_per_active_byte_ratio: 0.05
143+
active_compression_ratio: 2.0
144+
long_term_compression_ratio: null
145+
prefer_physical_pricing_model: false
146+
storage_pricing_model_difference: 0.02
147+
148+
- last_used_date: "2022-01-01"
149+
project_id: "my-project"
150+
dataset_id: "my_dataset"
151+
table_id: "my_table_2"
152+
is_insertable_into: "YES"
153+
is_typed: "NO"
154+
ddl: "CREATE TABLE my_table2"
155+
default_collation_name: "utf8"
156+
project_number: 123456
157+
creation_time: "2022-01-01T00:00:00"
158+
deleted: false
159+
storage_last_modified_time: "2022-01-01T12:00:00"
160+
total_rows: 1000
161+
total_partitions: 1
162+
total_logical_bytes: 1073741824
163+
active_logical_bytes: 1073741824
164+
long_term_logical_bytes: 0
165+
total_physical_bytes: 536870912
166+
active_physical_bytes: 536870912
167+
long_term_physical_bytes: 0
168+
time_travel_physical_bytes: 53687091
169+
fail_safe_physical_bytes: 26843545
170+
table_type: "BASE TABLE"
171+
active_logical_bytes_cost: 0.02
172+
long_term_logical_bytes_cost: 0.0
173+
active_physical_bytes_cost: 0.04
174+
time_travel_physical_bytes_cost: 0.004
175+
fail_safe_physical_bytes_cost: 0.002
176+
long_term_physical_bytes_cost: 0.0
177+
factored_table_id: "my_table"
178+
total_logical_tb: 0.001
179+
total_physical_tb: 0.0005
180+
logical_cost_monthly_forecast: 0.02
181+
physical_cost_monthly_forecast: 0.04
182+
physical_cost_monthly_forecast_with_zero_time_travel_and_fail_safe: 0.034
183+
time_travel_per_active_byte_ratio: 0.1
184+
fail_safe_per_active_byte_ratio: 0.05
185+
active_compression_ratio: 2.0
186+
long_term_compression_ratio: null
187+
prefer_physical_pricing_model: false
188+
storage_pricing_model_difference: 0.02

0 commit comments

Comments
 (0)