Skip to content

Add SqlGlot dialect for LegendQL with DuckDB integration#47

Open
neema2 wants to merge 1 commit intomainfrom
devin/1747581994-sqlglot-dialect
Open

Add SqlGlot dialect for LegendQL with DuckDB integration#47
neema2 wants to merge 1 commit intomainfrom
devin/1747581994-sqlglot-dialect

Conversation

@neema2
Copy link
Copy Markdown
Collaborator

@neema2 neema2 commented May 24, 2025

Add SqlGlot dialect for LegendQL with DuckDB integration

This PR adds a new SqlGlot backend/dialect to translate the LegendQL metamodel to SQL using the sqlglot library in Python. The implementation focuses on the FROM and SELECT operations, enabling LegendQL to query DuckDB tables through SqlGlot SQL translation.

Features

  • Implemented SqlGlotRuntime and SqlGlotExpressionVisitor classes to translate LegendQL metamodel to SqlGlot expressions
  • Added DuckDBSqlGlotRuntime for executing SqlGlot-generated SQL against DuckDB
  • Created comprehensive test cases for simple SELECT and filtered SELECT queries
  • Mapped metamodel concepts (from, select, filter) to SqlGlot expressions

Testing

  • Added unit tests that verify SQL generation and query execution
  • Tests confirm correct translation of LegendQL queries to SQL
  • Verified execution against a test DuckDB database

Implementation Details

  • Created new directory structure for SqlGlot dialect implementation
  • Fixed connection handling in DuckDB implementation
  • Ensured proper type handling for SQL literals

Requested by: neema.raphael@gs.com
Link to Devin run: https://app.devin.ai/sessions/7ae3797bce3648ef8df9704fecc4ff01

Co-Authored-By: neema.raphael@gs.com <Neema.Raphael@gs.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant