mirror of
https://github.com/lancedb/lancedb.git
synced 2026-11-13 14:16:54 +00:00
fix: accept defining queries in Python materialized views (#4980)
Python materialized-view creation now accepts a complete defining SQL
query across sync, async, remote, and namespace connections, including
creation jobs:
```python
view = db.create_materialized_view(
"events_by_kind",
query="SELECT kind, count(*) AS n FROM events GROUP BY kind",
)
```
`query` is mutually exclusive with `source`, `select`, `where`, and
`limit`. Existing source-based calls remain supported.
Adds Rust `Connection::create_materialized_view_from_query`: embedded
connections plan through `MaterializedViewDefinition::from_sql`, while
remote connections submit the full query for server-side parsing.
Includes regression coverage for grouping, UNNEST, query forwarding,
creation jobs, and argument validation.
This commit is contained in:
@@ -627,6 +627,20 @@ remain available, as do LanceDB Enterprise operations. The same feature
|
||||
requirement applies to LanceDB Embedded SQL computed-column declaration and refresh; ordinary
|
||||
eager `add_columns` transforms remain available.
|
||||
|
||||
Pass a complete defining SQL query with `query=` to use grouping, Functions
|
||||
in `FROM`, or `UNNEST`:
|
||||
|
||||
```python
|
||||
view = db.create_materialized_view(
|
||||
"events_by_kind",
|
||||
query="SELECT kind, count(*) AS n FROM events GROUP BY kind",
|
||||
)
|
||||
```
|
||||
|
||||
`query` is mutually exclusive with `source`, `select`, `where`, and `limit`.
|
||||
It is also accepted by asynchronous connections and `create_materialized_view_async`.
|
||||
The backend SQL parser determines which query shapes are supported.
|
||||
|
||||
In LanceDB Enterprise, creation accepts `auto_refresh_enabled` and
|
||||
`auto_refresh_interval_seconds`:
|
||||
|
||||
|
||||
Reference in New Issue
Block a user