Repository: TobikoData/sqlmesh
Pull request #2685 (2024-05-27 12:42:01)

Chore: update docs for ui formatter option
updating the SQLMesh UI settings in the docs to match the code [here](
https://github.com/TobikoData/sqlmesh/blob/0639bf892ae9218dd7216d2afdda7eb07efedc7e/sqlmesh/core/config/ui.py#L13)




CLAassistant: [![CLA assistant check](https://cla-assistant.io/pull/badge/not_signed)](https://cla-assistant.io/TobikoData/sqlmesh?pullRequest=2685) <br/>Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our [Contributor License Agreement](https://cla-assistant.io/TobikoData/sqlmesh?pullRequest=2685) before we can accept your contribution.<br/><hr/>**Simon Prydden** seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please [add the email address used for this commit to your account](https://help.github.com/articles/why-are-my-commits-linked-to-the-wrong-user/#commits-are-not-linked-to-any-user).<br/><sub>You have signed the CLA already but the status is still pending? Let us [recheck](https://cla-assistant.io/check/TobikoData/sqlmesh?pullRequest=2685) it.</sub>

Patch:
diff --git a/docs/reference/configuration.md b/docs/reference/configuration.md
index 71e7f8e3..2da2cfad 100644
--- a/docs/reference/configuration.md
+++ b/docs/reference/configuration.md
@@ -96,9 +96,9 @@ Formatting settings for the `sqlmesh format` command and UI.
 
 SQLMesh UI settings.
 
-| Option   | Description                                                                                   |  Type   | Required |
-| -------- | --------------------------------------------------------------------------------------------- | :-----: | :------: |
-| `format` | Whether to automatically format model definitions upon saving them to a file (Default: False) | boolean |    N     |
+| Option           | Description                                                                                   |  Type   | Required |
+| ---------------- | --------------------------------------------------------------------------------------------- | :-----: | :------: |
+| `format_on_save` | Whether to automatically format model definitions upon saving them to a file (Default: False) | boolean |    N     |
 
 ## Gateways
 
diff --git a/sqlmesh/core/dialect.py b/sqlmesh/core/dialect.py
index d98f4824..39ac5d9e 100644
--- a/sqlmesh/core/dialect.py
+++ b/sqlmesh/core/dialect.py
@@ -878,7 +878,7 @@ def select_from_values_for_batch_range(
     alias: str = "t",
 ) -> exp.Select:
     casted_columns = [
-        exp.alias_(exp.cast(column, to=kind), column, copy=False)
+        exp.alias_(exp.cast(exp.column(column), to=kind), column, copy=False)
         for column, kind in columns_to_types.items()
     ]
 


Test patch:
diff --git a/tests/core/test_model.py b/tests/core/test_model.py
index 5a9683e2..928aa84c 100644
--- a/tests/core/test_model.py
+++ b/tests/core/test_model.py
@@ -909,6 +909,23 @@ def test_seed_model_custom_types(tmp_path):
     assert df["i_str"].iloc[0] == "321"
 
 
+def test_seed_with_special_characters_in_column(tmp_path, assert_exp_eq):
+    config = Config(model_defaults=ModelDefaultsConfig(dialect="duckdb"))
+    context = Context(config=config)
+
+    model_csv_path = (tmp_path / "model.csv").absolute()
+    with open(model_csv_path, "w", encoding="utf-8") as fd:
+        fd.write("col.\n123")
+
+    model = create_seed_model("memory.test_db.test_model", SeedKind(path=str(model_csv_path)))
+    context.upsert_model(model)
+
+    assert_exp_eq(
+        context.render("memory.test_db.test_model").sql(),
+        'SELECT CAST("col." AS BIGINT) AS "col." FROM (VALUES (123)) AS t("col.")',
+    )
+
+
 def test_audits():
     expressions = d.parse(
         """