Live data from Hacker News

DuckDB: Querying JSON files as if they were tables

duckdb.org

41–50 of 81 posts

Re: DuckDB: Querying JSON files as if they were tables

#41
this looks preddy cool. i was using the json datatype in mysql at the beginning of my project and we ended up yanking it out because of the way you query data within the json. it just started getting kludgey and i felt like i was trying to turn mysql into mongo, but suffering because its not.

will follow duckdb.

Re: DuckDB: Querying JSON files as if they were tables

#42
Running into a couple issues right out of the gate:

1) Needed to increase maximum_object_size 2) Unexpected yyjson tag in ValTypeToString

Couldn't find a reference anywhere to that error. Loads into Snowflake without a hitch - which is where I normally query large JSON files.

Re: DuckDB: Querying JSON files as if they were tables

#43

This is really cool! With their Postgres scanner[0] you can now easily query multiple datasources using SQL and join between them (i.e. Postgres table with JSON file). Something I previously strived to build with OctoSQL[1]. There's even predicate push-down to the underlying databases (for Postgres)! It's amazing to see how quickly DuckDB is adding new features. Not a huge fan of C++, which is right now used for auth…

Consider polars for rust. Much, much faster with fewer resources than Duckdb or datafusion in my experience.

Re: DuckDB: Querying JSON files as if they were tables

#44

I think I write this under every article about DuckDB, but it's become an indispensable tool for me. I used to abuse Excel because going from Excel to a script to process some data was too much friction, but with DuckDB the friction is gone: loading CSV and Parquet (and now JSON) files is a snap, you can create and persist any tables you want, the SQL dialect has lots of useful sugar.

You can also do this with AlaSQL.js which apart from being able to run SQL against JSON and also works with CSV and XSLS, just include it using a script tag or import it as a node module.

Re: DuckDB: Querying JSON files as if they were tables

#45

Earlier quoted context omitted.

Any chance you’ve tried clickhouse local? I was thinking it might be a good fit but haven’t used duckdb at all so I might be missing out on big differences.

No, I haven't, but it looks like it's a standalone console application, while DuckDB is in-process, like SQLite, and lives inside its JDBC driver. This means I can use it inside any compatible GUI and get stuff like schema browsing and IntelliSense out of the box. Since I have DBeaver open all day anyway, DuckDB is always a tab away.

Clickhouse local is very fast and good for many purposes but DuckDB is equally fast (or faster in some cases but this is a moving target) and supports a wider range of SQL that people like me often use.

DuckDB is great for data scientists and people who need to run complex analytic queries in their Jupyter notebooks and their Python prod code on local or S3 hosted data.

Re: DuckDB: Querying JSON files as if they were tables

#46

Running into a couple issues right out of the gate: 1) Needed to increase maximum_object_size 2) Unexpected yyjson tag in ValTypeToString Couldn't find a reference anywhere to that error. Loads into Snowflake without a hitch - which is where I normally query large JSON files.

Thanks for trying it out!

Could you perhaps open an issue [1] or share the file with us so we could investigate the problem?

[1] https://github.com/duckdb/duckdb/issues

Re: DuckDB: Querying JSON files as if they were tables

#47

I think I write this under every article about DuckDB, but it's become an indispensable tool for me. I used to abuse Excel because going from Excel to a script to process some data was too much friction, but with DuckDB the friction is gone: loading CSV and Parquet (and now JSON) files is a snap, you can create and persist any tables you want, the SQL dialect has lots of useful sugar.

The benefit of “in process” isn’t really clicking for me. We had Pandas or similar if we wanted to load and transform some data in memory. SQL is nicer than Pandas APIs but not sure that’s a killer feature? If we have a lot of data and multiple people working with it then it makes sense to centralise it in a database or warehouse where it’s then easy to access via SQL anyway. We can query files on S3 with it and have…

Just to agree with @orthozerox, it's not a 'killer feature' but about lowering the friction.

Lots of users: (a) mentally align better with SQL than pandas APIs, regardless of whether they know both or not (b) want decent performance on their analyses, which they aren't getting from pandas, and won't get from many OLTP-databases they're using over-the-wire (c) want ease of accessing parquet and csv locally and remotely with minimal development overhead. it's super simple with duckdb.

Nonetheless, some of the other things you pointed out are some tradeoffs. We're building a serverless cloud capability at motherduck on top of duckdb in order to address some of these and optimize compute and storage based on data locality, bandwidth and the need for collaboration amongst multiple people.

Re: DuckDB: Querying JSON files as if they were tables

#48

Mind you this isn’t appropriate for most cases. But I love the idea of “you start with text file. You end with text file. All the database stuff, indexes, etc. are just a detail.” Often I find that the database wants to be the authority and that makes working with different formats a bit uncomfortable.

We’re currently building real-time apis backed by terabytes of compressed parquet… hundreds of billions of ‘rows’… in exactly this fashion using polars. It amazes us at every turn.

Join us and help!

Re: DuckDB: Querying JSON files as if they were tables

#50
post #49

> If your JSON file is newline-delimited, DuckDB can parallelize reading. I'd like to understand more about what that means. Does it use multiple threads each reading from a different position in the file?

DuckDB will use multiple threads for reading the same file. Each thread will read different parts of the file, but the output will be in the order that the file came in due to DuckDB’s order preserving parallelism.
Post reply on HN