You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ossie.apache.org by "michellepellon (via GitHub)" <gi...@apache.org> on 2026/07/18 15:55:38 UTC
[PR] feat: add DUCKDB dialect and bidirectional DuckDB converter [ossie]
michellepellon opened a new pull request, #229:
URL: https://github.com/apache/ossie/pull/229
# Add DUCKDB dialect and a bidirectional DuckDB converter
## What
This PR adds DuckDB as a supported expression dialect and contributes a reference converter for it, in three parts:
1. **Dialect registration** — adds `DUCKDB` to the `Dialect` enum in `core-spec/osi-schema.json`, `core-spec/spec.yaml`, the dialect table in `core-spec/spec.md`, and the `OSIDialect` / `OSIVendor` enums in `python/src/ossie/models.py`.
2. **Validation support** — maps `DUCKDB` to sqlglot's `duckdb` dialect in `validation/validate.py`, so DuckDB expressions get full syntax validation (sqlglot's DuckDB support is first-class; no skip-list entry needed).
3. **Converter** — `converters/duckdb/`, a bidirectional Ossie ↔ DuckDB converter following the hub-and-spoke pattern in `converters/README.md`:
- **Export**: Ossie model → DuckDB SQL (one view per dataset with field expressions, `COMMENT ON` from descriptions, one view per metric with joins derived from declared relationships). Dialect selection prefers `DUCKDB`, falls back to `ANSI_SQL` with a warning.
- **Import**: DuckDB database → Ossie YAML via `information_schema` and `duckdb_constraints()` (primary keys, unique keys, and foreign keys → relationships; table/column comments → descriptions).
- CLI (`ossie-duckdb export|import`), pytest suite with round-trip tests executing generated SQL against in-memory DuckDB, and schema validation of imported models against `osi-schema.json`.
## Why
DuckDB (and MotherDuck, its managed cloud service) is widely used as an analytics engine in lakehouse and embedded-analytics stacks, and is a common substrate for the AI-agent workloads that `ai_context` targets. Because DuckDB connections are passed through, the converter works against MotherDuck databases (`md:` connection strings) unchanged.
## Notes
- No changes to existing converters; unknown-dialect handling elsewhere is unaffected (existing fallback chains ignore dialects they don't target).
- The example models in `examples/` are untouched and still validate.
- Aware of #52 (single dialect per document); the enum addition is orthogonal — whichever way that lands, DuckDB needs to be a valid dialect value.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@ossie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] feat: add DUCKDB dialect and bidirectional DuckDB converter [ossie]
Posted by "jbonofre (via GitHub)" <gi...@apache.org>.
jbonofre commented on PR #229:
URL: https://github.com/apache/ossie/pull/229#issuecomment-5777133495
@michellepellon do you mind to rebase and resolve conflicts?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@ossie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] feat: add DUCKDB dialect and bidirectional DuckDB converter [ossie]
Posted by "vigneshc (via GitHub)" <gi...@apache.org>.
vigneshc commented on code in PR #229:
URL: https://github.com/apache/ossie/pull/229#discussion_r4244729301
##########
converters/duckdb/README.md:
##########
@@ -0,0 +1,98 @@
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+
+# Apache Ossie ↔ DuckDB Converter
+
+Bidirectional converter between DuckDB databases and the Apache Ossie
+semantic model.
+
+- **Export** (Ossie → DuckDB): renders a semantic model as a DuckDB SQL
+ script — one view per dataset, one `metric_<name>` view per metric (with
+ joins derived from the declared relationships), and `COMMENT ON`
+ statements carrying the descriptions into the DuckDB catalog.
+- **Import** (DuckDB → Ossie): reads a database's tables, views, columns,
+ constraints, and comments and emits a valid Ossie YAML document.
+
+## Usage
+
+```bash
+# Ossie model -> DuckDB SQL script
+ossie-duckdb export -i model.yaml -o model.sql
+ossie-duckdb export -i model.yaml --view-schema semantic # views in their own schema
+
+# DuckDB database -> Ossie model
+ossie-duckdb import -i analytics.duckdb -o model.yaml
+ossie-duckdb import -i md:my_database --schema gold --name gold_model
+```
+
+Or from Python:
+
+```python
+from ossie_duckdb import convert_osi_to_duckdb, convert_duckdb_to_osi_yaml
+
+sql = convert_osi_to_duckdb(open("model.yaml").read(), view_schema="semantic")
+
+import duckdb
+conn = duckdb.connect("analytics.duckdb")
+osi_yaml = convert_duckdb_to_osi_yaml(conn, schema="main")
+```
+
+## Mapping
+
+| Ossie construct | DuckDB construct |
+|-----------------|------------------|
+| Dataset | `CREATE OR REPLACE VIEW <name>` over the dataset `source` |
+| Field | View column (`<expression> AS <name>`) |
+| Field / dataset / metric `description` | `COMMENT ON COLUMN` / `COMMENT ON VIEW` |
+| Metric | `CREATE OR REPLACE VIEW metric_<name>`, joins derived from relationships |
+| Relationship | `LEFT JOIN` in metric views (export); `FOREIGN KEY` constraint (import) |
Review Comment:
can you share more details on this is inferred for DuckDB --> Ossie conversion?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@ossie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] feat: add DUCKDB dialect and bidirectional DuckDB converter [ossie]
Posted by "christianeu-db (via GitHub)" <gi...@apache.org>.
christianeu-db commented on PR #229:
URL: https://github.com/apache/ossie/pull/229#issuecomment-6460221477
@michellepellon converters have moved to the ossie-converters repo. closing this pr but feel free to create a dialect registration prhere & converter pr in that repo
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@ossie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] feat: add DUCKDB dialect and bidirectional DuckDB converter [ossie]
Posted by "vigneshc (via GitHub)" <gi...@apache.org>.
vigneshc commented on code in PR #229:
URL: https://github.com/apache/ossie/pull/229#discussion_r4244718427
##########
converters/duckdb/README.md:
##########
@@ -0,0 +1,98 @@
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+
+# Apache Ossie ↔ DuckDB Converter
+
+Bidirectional converter between DuckDB databases and the Apache Ossie
+semantic model.
+
+- **Export** (Ossie → DuckDB): renders a semantic model as a DuckDB SQL
+ script — one view per dataset, one `metric_<name>` view per metric (with
+ joins derived from the declared relationships), and `COMMENT ON`
+ statements carrying the descriptions into the DuckDB catalog.
+- **Import** (DuckDB → Ossie): reads a database's tables, views, columns,
+ constraints, and comments and emits a valid Ossie YAML document.
+
+## Usage
+
+```bash
+# Ossie model -> DuckDB SQL script
+ossie-duckdb export -i model.yaml -o model.sql
+ossie-duckdb export -i model.yaml --view-schema semantic # views in their own schema
+
+# DuckDB database -> Ossie model
+ossie-duckdb import -i analytics.duckdb -o model.yaml
+ossie-duckdb import -i md:my_database --schema gold --name gold_model
+```
+
+Or from Python:
+
+```python
+from ossie_duckdb import convert_osi_to_duckdb, convert_duckdb_to_osi_yaml
+
+sql = convert_osi_to_duckdb(open("model.yaml").read(), view_schema="semantic")
+
+import duckdb
+conn = duckdb.connect("analytics.duckdb")
+osi_yaml = convert_duckdb_to_osi_yaml(conn, schema="main")
+```
+
+## Mapping
+
+| Ossie construct | DuckDB construct |
+|-----------------|------------------|
+| Dataset | `CREATE OR REPLACE VIEW <name>` over the dataset `source` |
+| Field | View column (`<expression> AS <name>`) |
+| Field / dataset / metric `description` | `COMMENT ON COLUMN` / `COMMENT ON VIEW` |
+| Metric | `CREATE OR REPLACE VIEW metric_<name>`, joins derived from relationships |
Review Comment:
can you share more details on how this works for DuckDB -> Ossie conversion? How are the measure definitions inferred from DuckDB definitions?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@ossie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] feat: add DUCKDB dialect and bidirectional DuckDB converter [ossie]
Posted by "christianeu-db (via GitHub)" <gi...@apache.org>.
christianeu-db closed pull request #229: feat: add DUCKDB dialect and bidirectional DuckDB converter
URL: https://github.com/apache/ossie/pull/229
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@ossie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org