Skip to content

Commit a97d710

Browse files
committed
docs: clarify physical property reference syntax
Signed-off-by: mday-io <mdaytn@gmail.com>
1 parent e56fec4 commit a97d710

2 files changed

Lines changed: 9 additions & 15 deletions

File tree

‎docs/integrations/engines/starrocks.md‎

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -517,9 +517,9 @@ SELECT user_id, COUNT(*) AS event_count FROM user_events GROUP BY user_id;
517517
* `excluded_trigger_tables`: base tables whose data changes should **not** automatically trigger a refresh of this MV.
518518
* `excluded_refresh_tables`: base tables that should **not** be scanned when the MV refreshes.
519519

520-
Both properties accept a single table reference, a comma-separated string of table references, or a tuple or array of table references.
520+
Both properties accept a single reference, a comma-separated string, a tuple, or an array. References can be bare identifiers or quoted strings.
521521

522-
StarRocks requires the **physical** base table name for these properties, not the logical view name that SQLMesh normally exposes. SQLMesh handles this automatically: when a reference matches a managed SQLMesh model, the logical name is resolved to its physical table name before the `CREATE MATERIALIZED VIEW` statement is issued. References that do not match any managed model are passed through unchanged.
522+
StarRocks requires physical base table names in these properties. SQLMesh replaces references to managed models with physical table names and passes other references through unchanged. It sends the resulting names to StarRocks as a comma-separated string.
523523

524524
```sql
525525
MODEL (
@@ -529,7 +529,6 @@ MODEL (
529529
),
530530
physical_properties (
531531
refresh_scheme = 'ASYNC',
532-
-- SQLMesh resolves mydb.orders and mydb.order_items to their physical table names
533532
excluded_trigger_tables = 'mydb.orders,mydb.order_items',
534533
excluded_refresh_tables = mydb.orders
535534
)
@@ -538,18 +537,16 @@ MODEL (
538537
SELECT order_id, SUM(amount) AS total FROM mydb.orders GROUP BY order_id;
539538
```
540539

541-
A single reference can be written as a bare identifier (`mydb.orders`) or as a quoted string. Multiple references can be provided as a quoted, comma-separated string (`'mydb.orders,mydb.order_items'`), a tuple, or an array. Tuple and array elements can be bare identifiers, quoted strings, or a mix of both:
540+
Tuple and array elements can mix bare identifiers and quoted strings:
542541

543542
```sql
544543
physical_properties (
545-
refresh_scheme = 'ASYNC',
546-
excluded_trigger_tables = (mydb.orders, 'mydb.order_items'),
547-
excluded_refresh_tables = ['mydb.orders', mydb.order_items]
544+
refresh_scheme = 'ASYNC',
545+
excluded_trigger_tables = (mydb.orders, 'mydb.order_items'),
546+
excluded_refresh_tables = ['mydb.orders', mydb.order_items]
548547
)
549548
```
550549

551-
SQLMesh resolves each reference individually and passes the result to StarRocks as a comma-separated string of table names, regardless of the input form.
552-
553550
**Other properties:**
554551

555552
You can specify `partitioning`, `distribution`, `order by` and `properties` the same as normal table properties. But notice that only supported MV properties are useful, Refer to StarRocks' doc for MV creation.

‎sqlmesh/core/model/definition.py‎

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2832,13 +2832,10 @@ def _split_sql_model_statements(
28322832
def _resolve_model_refs_to_physical_tables(
28332833
value: exp.Expr, table_mapping: t.Dict[str, str], dialect: DialectType
28342834
) -> exp.Literal:
2835-
"""Resolve managed-model references in a property value to their physical table names.
2835+
"""Resolve managed-model references in a property value to physical table names.
28362836
2837-
The value is a single table reference, a comma-separated string, or a tuple/array of
2838-
table references. Each reference that matches a managed model (via ``table_mapping``) is
2839-
swapped for its physical ``db.table`` name;
2840-
anything else (e.g. a raw source) is kept as written. Returns a single string literal so the
2841-
property renders just like a hand-written value.
2837+
Unmatched references keep their table names. The function returns the names as one
2838+
comma-separated string literal.
28422839
"""
28432840
if isinstance(value, exp.Literal) and value.is_string:
28442841
refs = value.this.split(",")

0 commit comments

Comments
 (0)