r/SQL • u/agh_murad • 25m ago
Discussion Trying to build custom Data Orchestration and Federation engine from scratch
Hello everyone!
For past few years I am interested in Data Engineering and Data Science. While practicing I have encountered some bottlenecks and I am trying to resolve them and want to discuss it with you.
The most frustrating part for me is scattered data/data sources. Personally I believe that scattered data shouldn't be that much of pain to work with, however, it is. I really dont understand why to depend on huge pipelines just answer a question that has to read 2 distinct sources.
After some research I discovered DuckDB, which is awesome in reading part, however, cant write back the "fixes" to destinations, so I have to do them "by myself" again.
So I thought maybe I can build the engine I need by myself (couple of weeks in it, building with Rust currently). Here is the propositions and how would it work:
- Each source runs its own SQL. You say which server each part of the query goes to, and that part reaches the server as written, in its own dialect. The engine only joins and filters what comes back.
- Exact values or an error. Values keep the type the source declared. An INT in MySQL and a NUMBER in Oracle are equal when their values are, and text is compared byte for byte, not under whatever collation a server happens to use. If the engine can't do something exactly (comparing a float with a decimal, say), it refuses and tells you why instead of guessing.
- Nothing gets copied. No staging tables, nothing written to disk. Every query reads the sources fresh, under a memory limit, and joins too big for memory stream sorted rows from both sides.
- Fixes go back with a preview. Before anything is written, you see the rows that would be inserted, updated or deleted, with old and new values. Each change goes by primary key and is checked against the old values, so if someone changed the row in the meantime, the write stops. The old values are kept so you can undo it.
- Comparing two sources. Prod against a replica, or a table against the spreadsheet finance sent you, row by row by key. A row that changes while the comparison runs gets flagged instead of reported as a difference.
Reading across dbs, files and comparisons already work now. Writing "fixes" back is still on the roadmap.
A few questions I would like to hear your opinions on:
- How do you handle this workflow today? A pipline, dbt, Trino, Presto, or custom scripts?
- Would you trust a an engine capable of writing back to dbs, or does every fix go through a reviewed script anyway?
- What would make you refuse to use such and engine?
Thanks in advance for sharing your thoughts!
