DuckDB as the New jq
pgrs.net
DuckDB as the New jq
1–10 of 74 posts
Re: DuckDB as the New jq
#2I am also a big fan of jq.
And I think using DuckDB and SQL probably makes a lot of sense in a lot of cases.
But I think the examples are very geared towards being better solved in SQL.
The ideal jq examples are combinations of filter (select), map (map) and concat (.[]).
For example, finding the right download link:
$ curl -s https://api.github.com/repos/go-gitea/gitea/releases/latest \
| jq -r '.assets[]
| .browser_download_url
| select(endswith("linux-amd64"))'
https://github.com/go-gitea/gitea/releases/download/v1.15.7/gitea-1.15.7-linux-amd64
Or extracting the KUBE_CONFIG of a DigitalOcean Kubernetes cluster from Terraform state: $ jq -r '.resources[]
| select(.type == "digitalocean_kubernetes_cluster")
| .instances[].attributes.kube_config[].raw_config' \
terraform.tfstate
apiVersion: v1
kind: Config
clusters:
- cluster:
certificate-authority-data: ...
server: https://...k8s.ondigitalocean.com
...Re: DuckDB as the New jq
#3Re: DuckDB as the New jq
#4Re: DuckDB as the New jq
#5Very cool! I am also a big fan of jq. And I think using DuckDB and SQL probably makes a lot of sense in a lot of cases. But I think the examples are very geared towards being better solved in SQL. The ideal jq examples are combinations of filter (select), map (map) and concat (.[]). For example, finding the right download link: $ curl -s https://api.github.com/repos/go-gitea/gitea/releases/latest \ | jq -r '.assets[]…
duckdb -c \
"select * from ( \
select unnest(assets)->>'browser_download_url' as url \
from read_json('https://api.github.com/repos/go-gitea/gitea/releases/latest') \
) \
where url like '%linux-amd64'"Re: DuckDB as the New jq
#6Re: DuckDB as the New jq
#7Re: DuckDB as the New jq
#8Re: DuckDB as the New jq
#9Example: trying to pick one field out of 20000 large JSON files that represent local property records.
% duckdb -json -c "select apn.apnNumber from read_json('*')" Invalid Input Error: JSON transform error in file "052136400500", in record/value 1: Could not convert string 'fb1b1e68-89ee-11ea-bc55-0242ad1302303' to INT128
Well, I didn't want that converted. I just want to ignore it. This has been my experience overall. DuckDB is great if there is a logical schema, not as good as jq when the corpus is just data soup.
Re: DuckDB as the New jq
#10- "The world’s fastest tool for querying JSON files" https://clickhouse.com/blog/worlds-fastest-json-querying-too...
- "Show HN: ClickHouse-local – a small tool for serverless data analytics" https://news.ycombinator.com/item?id=34265206