Repository navigation
Replies: 2 comments 1 reply
|
Hey @mbkranz, thanks for the question! looks like duckdb is in the water 🦆 There are a couple interesting threads here, but I'm going to focus on your questions 1-3, and suggest we push the portability questions (4 and 5) to a separate discussion. Your approach here of putting duckdb behind pandas would definitely be the leaner diff, but implementing the whole ExecutionEngine to support duckdb natively looks cleaner architecturally. If we take that approach, I'd like to see equal support for dataframes, files, and a local duckdb database, but suggest we exclude duckdb as a client to a remote SQL database as well as reading files off of remote object storage (at least for the first pass). #12084 is a POC to derisk the work. @dataders implemented the aggregates and map metrics; that's not quite half the metrics we would need to ship this. That PR doesn't look like it supports dataframes yet, but support is already there at the ExecutionEngine level, and only the data source API would need to be plugged in. Notably, that PR is missing all query metrics, so your UnexpectedRowsExpectation example would not yet work. Would a first class duckdb data source/execution engine work for you? Or was part of the value specifically getting SQL expectations to work against Pandas data sources? Sounds like you might be interested in making this happen - I'm happy work through an RFC with you, and get this on the roadmap. Prior art: there was interest in duckdb support in #10738 and #11579, and relevant to the portability discussion, a user on discourse asked about validating an UnexpectedRowsExpectation against Pandas. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Today, the query metrics used by
UnexpectedRowsExpectationsupport SQL execution throughSqlAlchemyExecutionEngineand Spark SQL throughSparkDFExecutionEngine. However, the same SQL-oriented pattern is not available when a Batch is a pandas DataFrame usingPandasExecutionEngine.I'm curious whether there would be interest in using DuckDB as an embedded SQL execution layer for pandas-backed Batches. I’ve been trying this, it seems useful, I may be missing existing context, and I’d like to understand how this fits GX’s architecture.
Conceptually:
The DataFrame could be registered with an in-memory DuckDB connection as a relation representing
{batch}, allowing SQL query Expectations to work against pandas data without requiring users to first persist or expose the data through a SQLAlchemy Data Source.For example:
could potentially work against a pandas DataFrame in essentially the same way it already works against SQL- and Spark-backed Batches.
I see a few potential benefits:
Note, this is different then the SQLAlchemy engine. The idea here would be to use DuckDB primarily as an implementation detail or embedded query engine for a pandas-backed Batch, rather than requiring users to model their data as a DuckDB SQL Data Source.
This also relates to a separate discussion I opened around constraint-oriented SQL Expectations built on
UnexpectedRowsExpectation, where the user-facing rule is expressed as a constraint that should hold rather than directly as a query returning violating rows see hereA related architectural question is SQL dialect portability. I've also been experimenting with SQLGlot for representing predicates and queries as an AST rather than manipulating SQL strings directly. In principle, an AST/transpilation layer could make it possible for a logical constraint to be rendered for DuckDB, Spark SQL, or the SQL dialect used by a SQLAlchemy-backed Data Source.
Conceptually:
I see SQL parsing/transpilation as a separate concern from the basic DuckDB/Pandas integration, and I wouldn't necessarily expect GX to adopt SQLGlot specifically. But if query-based Expectations are intended to become more portable across execution engines, it seems worth considering whether a SQL AST or transpilation layer should be part of that architecture rather than relying entirely on dialect-specific SQL strings.
I'm interested in how the GX maintainers/community would think about this direction:
PandasExecutionEnginefit GX's execution engine architecture?DuckDBExecutionEnginebe more appropriate?I've been prototyping this pattern locally and would be interested in contributing either an implementation or a recipe if it aligns with the direction of the project.
All reactions