6 ms·
Pg_lake: Postgres with Iceberg and data lake access
- inglor 11mo agoThis is really nice though looking at the code - a lot of the postgres types are missing as well a lot of the newer parquet logical types - but this is a great start and a nice use of FDW.
- inglor 11mo agoAlso, any planned support for more catalogs?
- pgguru 11mo agoI think we have recently merged (or are getting ready to merge) REST catalog support, so that will open some things up in this department.
- pgguru 11mo agoHi, what types are you expecting to see that aren't supported? I believe we had support for most/all builtin postgres types.
- inglor 11mo agoPostgres has like 300+ types but mostly stuff like decimals should work the same way it does with Postgres (with the edge cases like NaN existing in Postgres but not parquets accordingly)
- mslot 11mo agoIn principle, Postgres has an infinite number of possible types :). pg_lake maps types into their Parquet equivalent and otherwise stores as text representation, there are a few limitations like very large numerics. https://github.com/Snowflake-Labs/pg_lake/blob/main/docs/iceberg-tables.md#iceberg-table-options https://github.com/Snowflake-Labs/pg_lake/blob/main/docs/ice...
- ozgune 11mo agoThis is huge! When people ask me what’s missing in the Postgres market, I used to tell them “open source Snowflake.” Crunchy’s Postgres extension is by far the most ahead solution in the market. Huge congrats to Snowflake and the Crunchy team on open sourcing this.
- gigatexal 11mo agoHonestly. Just pay snowflake for the amazing DB and ecosystem it is. And then go build cool stuff unless your value add to customers is infra let them handle all that.
- thejosh 11mo agoSounds great until you're locked into Snowflake - so glad iceberg is becoming the standard, anything is great. The trap you end up in is you have to pay snowflake to access your data, iceberg and other technology help with the walled garden. Not just snowflake, any pay on use provider. (Context - have spent 5+ years working with Snowflake, it's great, have built drivers for various languages, etc).
- gigatexal 11mo agoLocked in? I mean they’re your partner. As long as you’re deriving value from them the partnership is still valuable no?
- kortilla 11mo agoYes, don’t be obtuse. “Vendor lock-in” is not some foreign unheard of concept.
- repeekad 11mo agoTeams of the smartest people on earth make these kind of big vendor decisions, vendor lock-in is top of mind, I tell anyone who will listen to avoid databricks live tables and their sleezy sales reps pushing it over cheaper less locked in solutions
- ayhanfuat 11mo agoWith S3 Table Buckets, Cloudflare R2 Data Catalog and now this, Iceberg seems to be winning.
- dkdcio 11mo agoI was going to ask if you could then put DuckDB over Postgres for the OLAP query engine -- looks like that's already what it does! very interesting development in the data lake space alongside DuckLake and things
- pgguru 11mo agoYou create foreign tables in postgres using either the pg_lake_table wrapper or pg_lake_iceberg. Once those tables exist, queries against them are able to either push down entirely to the remote tables and uses a Custom Scan to execute and pull results back into postgres, or we transform/extract the pieces that can be executed remotely using a FDW and then treat it as a tuple source. In both cases, the user does not need to know any of the details and just runs queries inside postgres as they always have.
- spenczar5 11mo agoI think I don't understand postgres enough, so forgive this naive question, but what does pushing down to the remote tables mean? Does it allow parallelism? If I query a very large iceberg table, will this system fan the work out to multiple duckdb executors and gather the results back in?
- pgguru 11mo agoIn any query engine you can execute the same query in different ways. The more restrictions that you can apply on the DuckDB side the less data you need to return to Postgres. For instance, you could compute a `SELECT COUNT(*) FROM mytable WHERE first_name = 'David'` by querying all the rows from `mytable` on the DuckDB side, returning all the rows, and letting Postgres itself count the number of results, but this is extremely inefficient, since that same value can be computed remotely. In a simple query like this with well-defined semantics that match between Postgres and DuckDB, you can run the query entirely on the remote side, just using Postgres as a go-between. Not all functions and operators work in the same way between the two systems, so you cannot just push things down unconditionally; `pg_lake` does some analysis to see what can run on the DuckDB side and what needs to stick around on the Postgres side. There is only a single "executor" from the perspective of pg_lake, but the pgduck_server embeds a multi-threaded duckdb instance. How DuckDB executes the portion of the query it gets is up to it; it often will involve parallelism, and it can use metadata about the files it is querying to speed up its own processing without even needing to visit every file. For instance, it can look at the `first_name` in the incoming query and just skip any files which do not have a min_value/max_value that would contain that.
- beoberha 11mo agoCurious why pgduck_server is a totally separate process?
- dkdcio 11mo agofrom the README: > This separation also avoids the threading and memory-safety limitations that would arise from embedding DuckDB directly inside the Postgres process, which is designed around process isolation rather than multi-threaded execution. Moreover, it lets us interact with the query engine directly by connecting to it using standard Postgres clients.
- beoberha 11mo agoThanks! Didn’t scroll down far enough
- rmnclmnt 11mo agoThe README explains it: > This separation also avoids the threading and memory-safety limitations that would arise from embedding DuckDB directly inside the Postgres process, which is designed around process isolation rather than multi-threaded execution. Moreover, it lets us interact with the query engine directly by connecting to it using standard Postgres clients.
- pgguru 11mo agoWhat has been pointed out from the README; also: - Separation of concerns, since with a single external process we can share object store caches without complicated locking dances between multiple processes. - Memory limits are easier to reason about with a single external process. - Postgres backends end up being more robust, as you can restart the pgduck_server process separately.
- dharbin 11mo agoWhy would Snowflake develop and release this? Doesn't this cannibalize their main product?
- kentm 11mo agoIt's not going to scale as well as Snowflake, but it gets you into an Iceberg ecosystem which Snowflake can ingest and process at scale. Analytical data systems are typically trending to heterogenous compute with a shared storage backend -- you have large, autoscaling systems to process the raw data down to something that is usable by a smaller, cheaper query engine supporting UIs/services.
- hobs 11mo agoBut if you are used to this type of compute per dollar what on earth would make you want to move to Snowflake?
- kentm 11mo agoDifferent parts of the analytical stack have different performance requirements and characteristics. Maybe none of your stack needs it and so you never need Snowflake at all. More likely, you don't need Snowflake to process queries from your BI tools (Mode, Tableau, Superset, etc), but you do need it to prepare data for those BI tools. Its entirely possible that you have hundreds of terabytes, if not petabytes, of input data that you want to pare down to < 1 TB datasets for querying, and Snowflake can chew through those datasets. There's also third party integrations and things like ML tooling that you need to consider. You shouldn't really consider analytical systems the same as a database backing a service. Analytical systems are designed to funnel large datasets that cover the entire business (cross cutting services and any sharding you've done) into subsequently smaller datasets that are cheaper and faster to query. And you may be using different compute engines for different parts of these pipelines; there's a good chance you're not using only Snowflake but Snowflake and a bunch of different tools.
- barrrrald 11mo agoOne thing I admire about Snowflake is a real commitment to self-cannibalization. They were super out front with Iceberg even though it could disrupt them, because that's what customers were asking for and they're willing to bet they'll figure out how to make money in that new world Video of their SVP of Product talking about it here: https://youtu.be/PERZMGLhnF8?si=DjS_OgbNeDpvLA04&t=1195 https://youtu.be/PERZMGLhnF8?si=DjS_OgbNeDpvLA04&t=1195
- mberning 11mo agoDoes anyone know how access control works to the underlying s3 objects? I didn’t see anything regarding grants in the docs.
- pgguru 11mo agoHi, one of the developers here. You define credentials that can access the S3 buckets and use those as DuckDB secrets, usually in an init script for pgduck_server. (You can see some examples of this in the testing framework.) I'll see if we can improve the docs or highlight that part better, if it is already documented—we did move some things around prior to release.
- onderkalaci 11mo agoMaybe this could help: https://github.com/Snowflake-Labs/pg_lake?tab=readme-ov-file#connecting-pg_lake-to-s3-or-compatible https://github.com/Snowflake-Labs/pg_lake?tab=readme-ov-file...
- mberning 11mo agoInteresting. I am working on a project to integrate access management to iceberg/parquet files for sagemaker. Controlling what users logged into sagemaker studio have access to in s3. It’s fine using static policies for mvp, but eventually it needs to be dynamic and integrated into enterprise iam tools. Those tools generally have great support for managing sql grants. Not so much for s3 bucket policies.
- pgguru 11mo agoDuckDB secrets management supports custom IAM roles and the like; at this point we are basically treating the pgduck_server external system as a black box. For the postgres grants themselves, we provide privs to allow read/write to the remote tables, which is done via granting the `pg_lake_read`, `pg_lake_write` or `pg_lake_read_write` grants. This is a blanket all-or-nothing grant, however, so would need some design work/patching to support per-relation grants, say. (You could probably get away with making roles in postgres that have the appropriate read/write grant, then only granting those specific roles to a given relation, so it's probably doable though a little clunky at the moment.)
- chaps 11mo agoI love postgres and have created my own "data lake" sorta systems -- what would this add to my workflows?
- gajus 11mo agoMan, we are living in the golden era of PostgreSQL.
- deleted 11mo ago[deleted]
- anentropic 11mo agoWhen Snowflake bought Crunchy Data I was hoping they were going to offer a managed version of this It's great that I can run this locally in a Docker container, I'd love to be able to run a managed instance on AWS billed through our existing Snowflake account
- oulipo2 11mo agoInteresting! How does it compare with ducklake?
- mslot 11mo agoYou could say With DuckLake, the query frontend and query engine are DuckDB, and Postgres is used as a catalog in the background. With pg_lake, the query frontend and catalog are Postgres, and DuckDB is used as a query engine in the background. Of course, they also use different table formats (though similar in data layer) with different pros and cons, and the query frontends differ in significant ways. An interesting thing about pg_lake is that it is effectively standalone, no external catalog required. You can point Spark et al. directly to Postgres with pg_lake by using the Iceberg JDBC driver.
- iamcreasy 11mo agoVery cool! Was there any inherent limitation with postgresql or its extension system that forced pg_lake to use duckdb as query engine?
- mslot 11mo agoI gave a talk on that at Data Council, then still discussing the pg_lake extensions as part of Crunchy Data Warehouse. https://youtu.be/HZArjlMB6W4?si=BWEfGjMaeVytW8M1 https://youtu.be/HZArjlMB6W4?si=BWEfGjMaeVytW8M1 Also, nicer recording from POSETTE: https://youtu.be/tpq4nfEoioE?si=Qkmj8o990vkeRkUa https://youtu.be/tpq4nfEoioE?si=Qkmj8o990vkeRkUa It comes down to the trade-offs made by operational and analytical query engines being fundamentally different at every level.
- pgguru 11mo agoDuckDB provided a lot of infrastructure for reading/writing parquet files and other common formats here. It also was inherently multi-threaded and supported being embedded in a larger program (similar to sqllite), so made it a good basis for something that could work outside of the traditional process model of Postgres. Additionally, the postgres extension system supports most of the current project, so wouldn't say it was forced in this case, it was a design decision. :)
- spenczar5 11mo agoVery cool. One question that comes up for me is whether pg_lake expects to control the Iceberg metadata, or whether it can be used purely as a read layer. If I make schema updates and partition changes to iceberg directly, without going through pg_lake, will pg_lake's catalog correctly reflect things right away?
- pgguru 11mo agoWe have some level of external iceberg table read-only support, but it is limited at the moment. See this example/caveat: https://github.com/Snowflake-Labs/pg_lake/blob/main/docs/file-formats-reference.md#external-iceberg-format https://github.com/Snowflake-Labs/pg_lake/blob/main/docs/fil...
- mslot 11mo agoYou can use it as a read layer for for specific metadata JSON URL or a table in a REST catalog. The latter got merged quite recently, not yet in docs.
- boshomi 11mo agoWhy not just use Ducklake?[1] That reduces complexity[2] since only DuckDB and PostgreSQL with pg_duckdb are required. [1] https://ducklake.select/ https://ducklake.select/ [2] DuckLake - The SQL-Powered Lakehouse Format for the Rest of Us by Prof. Hannes Mühleisen: https://www.youtube.com/watch?v=YQEUkFWa69o https://www.youtube.com/watch?v=YQEUkFWa69o
- pgguru 11mo agoBoils down to design decisions; see: https://news.ycombinator.com/item?id=45813631 https://news.ycombinator.com/item?id=45813631
- mslot 11mo agoDuckLake is pretty cool, and we obviously love everything the DuckDB is doing. It's what made pg_lake possible, and what motivated part of our team to step away from Microsoft/Citus. DuckLake can do things that pg_lake cannot do with Iceberg, and DuckDB can do things Postgres absolutely can't (e.g. query data frames). On the other hand, Postgres can do a lot of things that DuckDB cannot do. For instance, it can handle >100k single row inserts/sec. Transactions don't come for free. Embedding the engine in the catalog rather than the catalog in the engine enables transactions across analytical and operational tables. That way you can do a very high rate of writes in a heap table, and transactionally move data into an Iceberg table. Postgres also has a more natural persistence & continuous processing story, so you can set up pg_cron jobs and use PL/pgSQL (with heap tables for bookkeeping) to do orchestration. There's also the interoperability aspect of Iceberg being supported by other query engines.
- jabr 11mo agoHow does this compare to https://www.mooncake.dev/pgmooncake https://www.mooncake.dev/pgmooncake? It seems there are several projects like this now, with each taking a slightly different approach optimized for different use cases?
- j_kao 11mo agoFYI the mooncake team was acquired by Databricks so it's basically vendors trying to compete on features now :)
- darth_avocado 11mo agoThis is so cool! We have files in Iceberg that we then move data to/from to a PG db using a custom utility. It always felt more like a workaround that didn’t fully use the capabilities of both the technologies. Can’t wait to try this out.
- fridder 11mo agoI love this. There are definitely shops where the data is a bit too much for postgres but something like Snowflake would be overkill. Wish this was around a couple years ago lol
- drchaim 11mo agoMore integrations are great. Anyway, the "this is awesome" moment (for me) will be when you could mix row- and column-oriented tables in Postgres, a bit like Timescale but native Postgres and well done. Hopefully one day.
- pgguru 11mo agoHypertables definitely had the arrays columns auto-expanding with the custom node type. Not sure what else it would look like for what you describe. That said, don't sleep on the "this is awesome" parts in this project... my personal favorite is the automatic schema detection: ``` CREATE TABLE my_iceberg_table () USING iceberg WITH (definition_from = 's3://bucket/source_data.parquet'); ```
- deleted 11mo ago[deleted]
- gregw2 11mo agoI want MPP HTAP where SQL inserts/COPYs store data in three(!) formats: - row-based (low latency insert, fast row-based indexed query for single-row OLTP) - columnar-based (slow inserts/updates, fast aggregates/projections) - iceberg-columnar-based (better OLAP price/performance and less lockin than native columnar) And for SELECTs the query engine picks which storage engine satisfies the query using some SQL extension like DB2 "WAITFORDATA" or TiDB @@tidb_read_staleness or MemSQL columnstore_latency and/or similar signalling for performance-vs-cost preference. And a common permissioning/datasharing layer so I can share data to external and internal parties who can in turn bring their own compute to make their own latency choices.
- harisund1990 11mo agoThis is cool to see! Looks like a compete against pg_mooncake which Databricks acquired. But how is this different from pg_duckdb?
- hamonrye 11mo ago[dead]
- apexalpha 11mo agoI’m not super into the Data sphere but my company relies heavily on Snowflake which is becoming an issue. This announcement seems huge to me, no?! Is this really an open source Snowflake covering most use cases?
- taude 11mo agothere's also plenty of other options for warehouse/compute processing of iceberg data storage. I think this is a pretty big deal, though. Snowflake does a lot more, though, especially around sharing data across company boundaries.
- lysecret 11mo agoNice does this also allow me to write to parquet from my Postgres table?
- claudeomusic 11mo agoCan someone dumb this down a bit for a non data-engineer? Hard to fully wrap my head around who this is/isn’t best suited for.
- lysecret 11mo agoOne usecase we have (we built it ourselves) is to periodically offload data from Postgres to lake house partitioned data on GCS. The way I see it this can now be done with a single query. Another one is the other way around to use posters as a query engine or to merge offloaded data with your live data.
- claudeomusic 11mo agoWhat services do people primarily use to accomplish these tasks today? All custom work?
- scirob 11mo agoCrunchydata did it first :) but nice to get more options
- iamcreasy 11mo agoIf anyone from Supabase is reading, it would be awesome to have this extension!
- pjd7 11mo agoThis is awesome, I will be trying this out in the coming months. Its just made it to the top of my R&D shortlist for things that could massively simplify our data stack for a b2b saas.
- rizky05 11mo ago[dead]
- NeutralCrane 11mo agoI’m not a data engineer but work in an adjacent role. Is there anyone here who could dumb the use case down? Maybe an example of a problem this solves. I am struggling to understand the value proposition here.
- ggregoire 11mo ago> Maybe an example of a problem this solves. Some service writes a lot of data in parquet files stored on S3 (e.g. logs), and now you want that data to be queryable from your application as if it was in postgres (e.g. near real-time analytics dashboard). pg_lake allows you to load these parquet files into postgres and query the data. You can also join that data with existing tables in postgres.
- smithclay 11mo agoBeen experimenting with OpenTelemetry->Parquet conversion lately for logs, metrics, and traces. Lots of related projects popping up in this area. It's powerful and cheap. - https://github.com/smithclay/otlp2parquet https://github.com/smithclay/otlp2parquet (shameless plug, based on Clickhouse's Otel schema) - https://github.com/Mooncake-Labs/moonlink https://github.com/Mooncake-Labs/moonlink (also has OTLP support) - https://github.com/open-telemetry/otel-arrow https://github.com/open-telemetry/otel-arrow (official community project under early dev)
- NeutralCrane 11mo agoI guess my confusion is that there already are ways to query this data with DuckDB or something like that. So is the magic here that it’s Postgres? What makes being able to query something in Postgres special? And when we say it’s now queryable by Postgres, does this mean that it takes that data and stores it in your PG db? Or it remains in S3 and this is a translation layer for querying with PG?
- ch71r22 11mo agoNot sure if I have this right but this is how I understand it > So is the magic here that it's Postgres? What makes being able to query something in Postgres special? There are a bunch of pros and cons to using Postgres vs. DuckDB. The basic difference is OLTP vs. OLAP. It seems pg_lake aims to give you the best of both. You can combine analytics queries with transactional queries. pg_lake also stores and manages the Iceberg catalog. If you use DuckDB you'll need to have an external catalog to get the same guarantees. I think if you're someone who was happy using Postgres, but had to explore alternatives like DuckDB because Postgres couldn't meet your OLAP needs, a solution like pg_lake would make your life a lot simpler. Instead of deploying a whole new OLAP system, you basically just install this extension and create the tables you want OLAP performance from with `create table ... using iceberg` > when we say it’s now queryable by Postgres, does this mean that it takes that data and stores it in your PG db? Postgres basically stores pointers to the data in S3. These pointers are in the Iceberg catalog that pg_lake manages. The tables managed by pg_lake are special tables defined with `create table ... using iceberg` which stores the data in Iceberg/Parquet files on S3 and executes queries partially with the DuckDB engine and partially with the Postgres engine. It looks like there is good support for copying between the Iceberg/DuckDB/Parquet world and the traditional Postgres world. > Or it remains in S3 and this is a translation layer for querying with PG? Yes I think that's right -- things stay in S3 and there is a translation layer so Postgres can use DuckDB to interact with the Iceberg tables on S3. If you're updating a table created with `create table ... using iceberg`, I think all the data remains in S3 and is stored in Parquet files, safely/transactionally managed via the Iceberg format. https://github.com/Snowflake-Labs/pg_lake/blob/main/docs/iceberg-tables.md#loading-data-into-an-iceberg-table https://github.com/Snowflake-Labs/pg_lake/blob/main/docs/ice...
- whalesalad 11mo agoRDS really needs to make it easy to install your own PG modules.
- anentropic 11mo ago110% this!
- fifilura 11mo agoHow do you use your data lake? For me it is much more than just storing data, it is just as much for crunching numbers in unpredictable ways. And this is where postgres does not cut it. You need some more CPU and RAM than what you pay for in your postgres instance. I.e. a distributed engine where you don't have to worry about how big your database instance is today.
- wodenokoto 11mo agoThe point about a datalake is to separate computer and storage. Postgres isn’t a compute layer it’s an access layer. Your compute asks Postgres “what is the current data for these keys?” Or “what was the current data as of two weeks ago for these keys?” And your compute will then download and aggregate your analytics query directly from the parquet files.
- fifilura 11mo agoSounds more like you need postgres as a backend than vice versa.
- enether 10mo agobut most serious compute engines already speak Iceberg, what do they gain from interfacing with PG now? My understanding is the opposite - PG cuts it as a compute layer for small amounts of data, and this is where it excels. I also assume `pg_lake` was built mainly with the intention of creating/writing tables, and the ability to read comes "for free" as an extra, since Iceberg integration is already written.
- logicartisan 11mo agoIt’s amazing to see Postgres growing into something this powerful
- lysecret 11mo agoA usecase I see for this personally I have encountered a lot of “hot cache for some time then offload for historical queries” usecases which I have built by hand multiple times. This should be a great fit. E.g. write to Postgres then periodically offload to lakehouse and even query together (if needed). Very cool!
- hamasho 11mo agoI like data lakes and their SQL-like query languages. They feel like an advanced version of the "Everything is a file" philosophy. Under "Everything is a file", you can read or manipulate a wide variety of information via simple, open/read/write() APIs. Linux provides APIs to modify system settings via filesystem. Get the screen brightness setting? `cat /sys/class/backlight/device0/brightness`. Update? `echo 500 > /sys/class/backlight/device0/brightness`. No need for special APIs, just generic file operations and the kernel handles everything. FUSE (Filesystem in Userspace) provides even more flexibility by allowing user space programs to build their own drivers that handle any data operation via the filesystem. You can mount remote systems (via SSH) and google drive, and copying files is as easy as `cp /mnt/remote/data/origin /mnt/googledrive/data/`. Or using unique FUSE like pgfuse and redisfs, updating redis value by postgres DB data is just `cat /mnt/postgres/users/100/full_name > /mnt/redis/user_100_full_name`. But filesystems are only good for hierarchical data while a lot of real world data is relational. Many FUSE software tries hard to represent inherently non-hierarchical data in a filesystem. Data lake allows to use SQL, the elegant abstraction for relational data, across different underlying data sources. They can be physically distant and have different structures. A lot of real world applications are just CRUD on relational data. You can accomplish much more much easier if those data are just a big single database.
- flarco 11mo agoFor anyone looking to easily ingest data into a Postgres Wire compatible database, check out https://github.com/slingdata-io/sling-cli https://github.com/slingdata-io/sling-cli. Use CLI, YAML or Python to run etl jobs.
- max_streese 11mo agoTwo questions: (1) Are there any plans to make this compatible with the ducklake specification? Meaning: Instead of using Iceberg in the background, you would use ducklake with its SQL tables? My knowledge is very limited but to me, besides leveraging duckdb, another big point of ducklake is that it's using SQL for the catalog stuff instead of a confusing mixture of files, thereby offering a bunch of advantages like not having to care about number of snapshots and better concurrent writes. (2) Might it be possible that pg_duckdb will achieve the same thing in some time or do things not work like that?
- mslot 11mo ago(1) We've thought about it, no current plans. We'd ideally reimplement DuckLake in Postgres directly such that we can preserve Postgres transaction boundaries, rather than reuse the Ducklake implementation that would run in a separate process. The double-edged sword is that there's a bunch of complexity around things like inlined data and passing the inlined data into DuckDB at query time, though if we can do that then you can get pretty high transaction performance. (2) In principle, it's a bit easier for pg_duckdb to reuse the existing Ducklake implementation because DuckDB sits in every Postgres process and they can call into each other, but we feel that architecture is less appropriate in terms resource management and stability.
- hexo 11mo agoOh datalakes. The most ridiculous idea in data processing, right after data frames in python. We've had this discussion like a week ago about how stupid is to use filesystem for this kind of data storage and here we go again. Actually i had to implement this "idea" in practice. What a nonsense.
- patokkuyak 11mo ago[dead]
- CJlll 11mo ago[dead]
- enether 10mo agoDo I understand it correctly that DuckDB would run embedded on the machine running Postgres (i.e through the extension), and this limits query processing ability to whatever that machine can comfortably handle? What are the deployment implications if one wants to integrate this in production? Surely they'd need a much larger Postgres machine at a minimum. Is there concern re: "hot neighbour" problems if the DuckDB queries get too heavy? How is that sort of issue potentially handled? I understood from another query that DuckDB is ran in a separate process, so there is room to potentially throttle it