Skip to content

Commit cbab32c

Browse files
authored
Chore: make .sqlmesh location configurable (#5474)
1 parent 858f432 commit cbab32c

File tree

5 files changed

+10
-6
lines changed

5 files changed

+10
-6
lines changed

docs/guides/configuration.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ The sources have the following order of precedence:
2121
2. `config.yaml` or `config.py` in the `~/.sqlmesh` folder.
2222
3. `config.yaml` or `config.py` in a project folder. [LOWEST PRECEDENCE]
2323

24+
!!! note
25+
To relocate the `.sqlmesh` folder, set the `SQLMESH_HOME` environment variable to your preferred directory path.
26+
2427
### File type
2528

2629
You can specify a SQLMesh configuration in either YAML or Python.

sqlmesh/core/constants.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
SQLMESH = "sqlmesh"
1010
SQLMESH_MANAGED = "sqlmesh_managed"
11-
SQLMESH_PATH = Path.home() / ".sqlmesh"
11+
SQLMESH_PATH = Path(os.getenv("SQLMESH_HOME") or Path.home() / ".sqlmesh")
1212

1313
PROD = "prod"
1414
"""Prod"""

tests/core/engine_adapter/integration/conftest.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010

1111
from sqlmesh import Config, EngineAdapter
12+
from sqlmesh.core.constants import SQLMESH_PATH
1213
from sqlmesh.core.config.connection import (
1314
ConnectionConfig,
1415
AthenaConnectionConfig,
@@ -34,7 +35,7 @@ def config(tmp_path: pathlib.Path) -> Config:
3435
project_paths=[
3536
pathlib.Path(os.path.join(os.path.dirname(__file__), "config.yaml")),
3637
],
37-
personal_paths=[pathlib.Path("~/.sqlmesh/config.yaml").expanduser()],
38+
personal_paths=[(SQLMESH_PATH / "config.yaml").expanduser()],
3839
variables={"tmp_path": str(tmp_path)},
3940
)
4041

tests/core/engine_adapter/test_trino.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -669,7 +669,7 @@ def test_replace_table_catalog_support(
669669

670670
adapter.replace_query(
671671
table_name=".".join([catalog_name, "schema", "test_table"]),
672-
query_or_df=parse_one("SELECT 1 AS col"),
672+
query_or_df=t.cast(exp.Query, parse_one("SELECT 1 AS col")),
673673
)
674674

675675
sql_calls = to_sql_calls(adapter)
@@ -705,7 +705,7 @@ def test_insert_overwrite_time_partition_hive(
705705

706706
adapter.insert_overwrite_by_time_partition(
707707
table_name=".".join(["my_catalog", "schema", "test_table"]),
708-
query_or_df=parse_one("SELECT a, b FROM tbl"),
708+
query_or_df=t.cast(exp.Query, parse_one("SELECT a, b FROM tbl")),
709709
start="2022-01-01",
710710
end="2022-01-02",
711711
time_column="b",
@@ -743,7 +743,7 @@ def test_insert_overwrite_time_partition_iceberg(
743743

744744
adapter.insert_overwrite_by_time_partition(
745745
table_name=".".join(["my_catalog", "schema", "test_table"]),
746-
query_or_df=parse_one("SELECT a, b FROM tbl"),
746+
query_or_df=t.cast(exp.Query, parse_one("SELECT a, b FROM tbl")),
747747
start="2022-01-01",
748748
end="2022-01-02",
749749
time_column="b",

tests/dbt/test_adapter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def test_adapter_relation(sushi_test_project: Project, runtime_renderer: t.Calla
3939
table_name="foo.another", target_columns_to_types={"col": exp.DataType.build("int")}
4040
)
4141
engine_adapter.create_view(
42-
view_name="foo.bar_view", query_or_df=parse_one("select * from foo.bar")
42+
view_name="foo.bar_view", query_or_df=t.cast(exp.Query, parse_one("select * from foo.bar"))
4343
)
4444
engine_adapter.create_table(
4545
table_name="ignored.ignore", target_columns_to_types={"col": exp.DataType.build("int")}

0 commit comments

Comments
 (0)