|
1 | 1 | import os |
2 | 2 |
|
3 | | -from sqlmesh.core.config.common import VirtualEnvironmentMode |
| 3 | +from sqlmesh.core.config.common import VirtualEnvironmentMode, TableNamingConvention |
4 | 4 | from sqlmesh.core.config import ( |
5 | 5 | AutoCategorizationMode, |
6 | 6 | BigQueryConnectionConfig, |
|
27 | 27 | defaults = {"dialect": "duckdb"} |
28 | 28 | model_defaults = ModelDefaultsConfig(**defaults) |
29 | 29 | model_defaults_iceberg = ModelDefaultsConfig(**defaults, storage_format="iceberg") |
| 30 | +before_all = [ |
| 31 | + "CREATE SCHEMA IF NOT EXISTS raw", |
| 32 | + "DROP VIEW IF EXISTS raw.demographics", |
| 33 | + "CREATE VIEW raw.demographics AS (SELECT 1 AS customer_id, '00000' AS zip)", |
| 34 | +] |
30 | 35 |
|
31 | 36 |
|
32 | 37 | # A DuckDB config, in-memory by default. |
|
52 | 57 | "nomissingexternalmodels", |
53 | 58 | ], |
54 | 59 | ), |
| 60 | + before_all=before_all, |
55 | 61 | ) |
56 | 62 |
|
57 | 63 | bigquery_config = Config( |
|
63 | 69 | }, |
64 | 70 | default_gateway="bq", |
65 | 71 | model_defaults=model_defaults, |
| 72 | + before_all=before_all, |
66 | 73 | ) |
67 | 74 |
|
68 | 75 | # A configuration used for SQLMesh tests. |
|
75 | 82 | ) |
76 | 83 | ), |
77 | 84 | model_defaults=model_defaults, |
| 85 | + before_all=before_all, |
78 | 86 | ) |
79 | 87 |
|
80 | 88 | # A configuration used for SQLMesh tests with virtual environment mode set to DEV_ONLY. |
|
84 | 92 | "plan": PlanConfig( |
85 | 93 | auto_categorize_changes=CategorizerConfig.all_full(), |
86 | 94 | ), |
87 | | - } |
| 95 | + }, |
88 | 96 | ) |
89 | 97 |
|
90 | 98 | # A DuckDB config with a physical schema map. |
91 | 99 | map_config = Config( |
92 | 100 | default_connection=DuckDBConnectionConfig(), |
93 | 101 | physical_schema_mapping={"^sushi$": "company_internal"}, |
94 | 102 | model_defaults=model_defaults, |
| 103 | + before_all=before_all, |
95 | 104 | ) |
96 | 105 |
|
97 | 106 | # A config representing isolated systems with a gateway per system |
|
103 | 112 | }, |
104 | 113 | default_gateway="dev", |
105 | 114 | model_defaults=model_defaults, |
| 115 | + before_all=before_all, |
106 | 116 | ) |
107 | 117 |
|
108 | 118 | required_approvers_config = Config( |
|
137 | 147 | ), |
138 | 148 | ], |
139 | 149 | model_defaults=model_defaults, |
| 150 | + before_all=before_all, |
140 | 151 | ) |
141 | 152 |
|
142 | 153 |
|
143 | 154 | environment_suffix_table_config = Config( |
144 | 155 | default_connection=DuckDBConnectionConfig(), |
145 | 156 | model_defaults=model_defaults, |
146 | 157 | environment_suffix_target=EnvironmentSuffixTarget.TABLE, |
| 158 | + before_all=before_all, |
147 | 159 | ) |
148 | 160 |
|
149 | 161 | environment_suffix_catalog_config = environment_suffix_table_config.model_copy( |
150 | 162 | update={ |
151 | 163 | "environment_suffix_target": EnvironmentSuffixTarget.CATALOG, |
152 | | - } |
| 164 | + }, |
153 | 165 | ) |
154 | 166 |
|
155 | 167 | CATALOGS = { |
|
161 | 173 | default_connection=DuckDBConnectionConfig(catalogs=CATALOGS), |
162 | 174 | default_test_connection=DuckDBConnectionConfig(catalogs=CATALOGS), |
163 | 175 | model_defaults=model_defaults, |
| 176 | + before_all=before_all, |
164 | 177 | ) |
165 | 178 |
|
166 | 179 | environment_catalog_mapping_config = Config( |
|
177 | 190 | "^prod$": "prod_catalog", |
178 | 191 | ".*": "dev_catalog", |
179 | 192 | }, |
| 193 | + before_all=before_all, |
| 194 | +) |
| 195 | + |
| 196 | +hash_md5_naming_config = config.copy( |
| 197 | + update={"physical_table_naming_convention": TableNamingConvention.HASH_MD5} |
| 198 | +) |
| 199 | + |
| 200 | +table_only_naming_config = config.copy( |
| 201 | + update={"physical_table_naming_convention": TableNamingConvention.TABLE_ONLY} |
180 | 202 | ) |
0 commit comments