Battam's picture
add viewer subsets for the new layout: enron-spreadsheets-emails, lichess
c7f01b5 verified
|
Raw History Blame
25.2 kB

Selecting rows

Every table in this repository is Parquet. One row of data/<source>/<batch>/part-*.parquet is one downloadable item: a file, an archive member, a WARC record, a byte range or an API response. The tables under meta/ are small and say which rows are worth using.

Row fields

Field Meaning
source Source name (see meta/sources.json).
batch Batch inside the source (one snapshot or collection run).
collection Collection name inside the source.
ext File extension without the dot, as found at the source.
uri Address to download from (HTTPS where the source offers it).
range_offset, range_length Byte range inside the file at uri, for records stored inside a larger file.
member_path, parent_pointer_id Path of a member inside an archive, and the archive's pointer.
zip_local_header_offset, zip_compression_method, zip_compressed_size Where a zip member's bytes sit, so it can be read with range requests.
size_bytes Size of the item in bytes (empty when the source does not say).
media_type Media type when the source states one.
sha256, sha1, md5, crc32 Hashes as raw bytes; use lower(hex(sha256)) for the hex form.
origin_url, origin_time The page the item was found on and when it was captured.
truncated Why stored content was cut short (empty when it was not).
license_spdx, license_training_ok, license_redistribution_ok, license_notes The row's own license when it differs from the batch license.
extra Anything else the full pointer carries, as JSON; fetch.py rebuilds the full pointer from it.
row_file, row_index Where the row sits: the data file (source/batch/part file) and the row number in it, counting from 0. Not stored in the data files; tools/fetch.py adds them when reading, the starter files carry them. meta/duplicates.parquet names rows by them.

Tables under meta/

  • meta/batches.parquet: one row per source and batch: license tiers (training_ok, redistribution_ok), reachability from the last link check, the overall size cap used by tools/fetch.py (max_size_bytes), content categories, and the constants and rules used to rebuild full pointers.
  • meta/duplicates.parquet: rows the default filter removes as duplicates, each named by its place in the data files (batch, row_file, row_index), with the reason and the copy that is kept (keep_*): natural_key, another row with the same source, uri, range_offset and member_path was kept (the one from the latest batch; within one batch the first in file order), and that kept row has natural_key_conflict true in tools/fetch.py output; superseded, the row belongs to a snapshot replaced by a newer batch (keep_batch); same_sha256, same_sha1, same_md5, another row with the same hash was kept.
  • meta/bench_overlap.parquet: rows found in public benchmark tasks: scope row matches one row, scope container matches a whole collection; hit_class says how the match was made.
  • meta/tags.parquet: use tags (for example data-processing or help-requests) for each source, batch, collection, extension, metadata value and content category, with row counts and the reference size cap of the tag's content class (max_size_bytes).
  • meta/size_caps.json: reference size caps: for each content class the typical size of benchmark task files of that class, and the overall cap over all benchmark task files; how each was derived (sample count, percentile, value) and how it is recalibrated; provisional. They do not remove rows: tools/fetch.py uses the overall cap when downloading, or the class caps with --cap per-class.
  • meta/sources.json: per-source details, including the layout used to rebuild full pointers.
  • meta/coverage.json: totals by license tier, source, unit, size and tag.

starter/<tag>.parquet holds a sample of about ten thousand rows per tag that pass the default filter, spread over sources (at most 30% from one source), extensions and size classes.

The default filter

The default subset is every row of the index except copies of benchmark data and duplicate copies of the same file. License tiers, sizes and versions do not remove rows; the queries below choose by them. Truncated rows, empty files and rows of batches whose link check was partial stay in; the reference counts below count them. A row passes when all of these hold:

  • not_duplicate: the row is not listed in meta/duplicates.parquet (one copy of each duplicated file is kept; of rows that share a natural key only the latest is kept).
  • not_in_benchmark_row / not_in_benchmark_container: the row and its collection are not in meta/bench_overlap.parquet with hit class benchmark_copy, task_file, data_address (copies of benchmark data, including collections derived from a benchmark).

tools/fetch.py applies it unless you pass --no-default-filter. Size caps apply only when downloading: by default the overall cap of meta/size_caps.json (the 99th percentile of all benchmark task files) guards against huge files; --cap per-class uses the reference cap of the row's content class and --max-size N uses N bytes. A row above its cap is recorded as too_large and not downloaded; a row of unknown size is downloaded up to the cap.

Rows per source

Every row of the index is counted once: either it is in the default subset or it is removed by the first rule of the default filter it fails (duplicate copies first, then copies of benchmark data). Rows equals Default subset plus In a benchmark plus Duplicate copy.

Source Rows Default subset In a benchmark Duplicate copy
enron-spreadsheets-emails 14 14 0 0
lichess 1,369 1,369 0 0
all 1,383 1,383 0 0

Reference counts over the rows of the default subset (none of them removes a row): Size unknown, rows whose size the source does not state; Over class cap, rows larger than the reference cap of their content class (the largest max_size_bytes among their tags in meta/tags.parquet, otherwise the overall cap), which tools/fetch.py --cap per-class would not download; Truncated, rows whose stored content was cut short (field truncated); Empty file, rows whose stated size is 0 bytes; Link check partial, rows of batches whose last link check reached only part of the sample (reachability partial in meta/batches.parquet); and the rows in each license tier for training and for redistribution (the row's own tier when it has one, otherwise the batch tier).

Source Size unknown Over class cap Truncated Empty file Link check partial Training yes Training conditional Training no Training unknown Redistribution yes Redistribution conditional Redistribution no Redistribution unknown
enron-spreadsheets-emails 0 14 0 0 0 14 0 0 0 14 0 0 0
lichess 0 390 0 0 0 1,369 0 0 0 1,289 80 0 0
all 0 404 0 0 0 1,383 0 0 0 1,303 80 0 0

Querying with DuckDB

Run these statements once (DuckDB 1.1 or newer reads hf:// paths; set HF_TOKEN for higher rate limits). They define the views used below: p rows, b batches, d duplicates, o benchmark overlap, t tags.

CREATE OR REPLACE VIEW p AS SELECT * EXCLUDE (filename, file_row_number), regexp_extract(replace(filename, '\', '/'), '[^/]+/[^/]+/[^/]+$') AS row_file, file_row_number AS row_index FROM read_parquet('hf://datasets/Battam/agentic-env-index/data/*/*/*.parquet', union_by_name = true, filename = true, file_row_number = true);
CREATE OR REPLACE VIEW b AS SELECT * FROM read_parquet('hf://datasets/Battam/agentic-env-index/meta/batches.parquet');
CREATE OR REPLACE VIEW d AS SELECT * FROM read_parquet('hf://datasets/Battam/agentic-env-index/meta/duplicates.parquet');
CREATE OR REPLACE VIEW o AS SELECT * FROM read_parquet('hf://datasets/Battam/agentic-env-index/meta/bench_overlap.parquet');
CREATE OR REPLACE VIEW t AS SELECT * FROM read_parquet('hf://datasets/Battam/agentic-env-index/meta/tags.parquet');
CREATE OR REPLACE VIEW selected AS
SELECT p.*, (CASE WHEN starts_with(coalesce(p.extra, ''), '{"_row":') THEN json_extract_string(p.extra, '$._row.pointer_id') WHEN coalesce(json_contains(json_extract(p.extra, '$._absent'), '"pointer_id"'), false) THEN NULL WHEN json_type(p.extra, '$.pointer_id') IS NOT NULL THEN json_extract_string(p.extra, '$.pointer_id') WHEN json_type(p.extra, '$.pid') IS NOT NULL THEN p.source || ':' || p.collection || ':' || json_extract_string(p.extra, '$.pid') WHEN p.parent_pointer_id IS NOT NULL AND p.member_path IS NOT NULL THEN CASE WHEN length(p.parent_pointer_id) - length(replace(p.parent_pointer_id, ':', '')) >= 2 THEN p.source || ':' || p.collection || ':' || substr(p.parent_pointer_id, strpos(p.parent_pointer_id, ':') + strpos(substr(p.parent_pointer_id, strpos(p.parent_pointer_id, ':') + 1), ':') + 1) || '!/' || p.member_path END WHEN b.pid_segments IS NOT NULL THEN p.source || ':' || p.collection || ':' || array_to_string(list_slice(string_split((CASE WHEN b.uri_swap_to IS NOT NULL AND json_extract_string(p.extra, '$._uri_orig') IS NULL THEN CASE WHEN starts_with(p.uri, b.uri_swap_to) AND ends_with(p.uri, b.uri_swap_suffix) AND length(p.uri) >= length(b.uri_swap_to) + length(b.uri_swap_suffix) THEN b.uri_swap_from || substr(p.uri, length(b.uri_swap_to) + 1, length(p.uri) - length(b.uri_swap_to) - length(b.uri_swap_suffix)) END ELSE p.uri END), '/'), -b.pid_segments, -1), '/') || CASE WHEN b.pid_at_offset THEN '@' || CAST(p.range_offset AS VARCHAR) ELSE '' END END) AS pointer_id, p.size_bytes IS NULL AS size_unknown,
  (CASE WHEN coalesce(nullif(CASE WHEN starts_with(coalesce(p.extra, ''), '{"_row":') THEN json_extract_string(p.extra, '$._row.license_override.training_ok') WHEN json_type(p.extra, '$.license_override') IS NOT NULL THEN json_extract_string(p.extra, '$.license_override.training_ok') WHEN (p.license_spdx IS NOT NULL OR p.license_training_ok IS NOT NULL OR p.license_redistribution_ok IS NOT NULL OR p.license_notes IS NOT NULL) THEN p.license_training_ok WHEN NOT coalesce(json_contains(json_extract(p.extra, '$._absent'), '"license_override"'), false) THEN b.const_training_ok END, ''), b.training_ok) IN ('yes', 'conditional', 'no') THEN coalesce(nullif(CASE WHEN starts_with(coalesce(p.extra, ''), '{"_row":') THEN json_extract_string(p.extra, '$._row.license_override.training_ok') WHEN json_type(p.extra, '$.license_override') IS NOT NULL THEN json_extract_string(p.extra, '$.license_override.training_ok') WHEN (p.license_spdx IS NOT NULL OR p.license_training_ok IS NOT NULL OR p.license_redistribution_ok IS NOT NULL OR p.license_notes IS NOT NULL) THEN p.license_training_ok WHEN NOT coalesce(json_contains(json_extract(p.extra, '$._absent'), '"license_override"'), false) THEN b.const_training_ok END, ''), b.training_ok) ELSE 'unknown' END) AS training_tier,
  (CASE WHEN coalesce(nullif(CASE WHEN starts_with(coalesce(p.extra, ''), '{"_row":') THEN json_extract_string(p.extra, '$._row.license_override.redistribution_ok') WHEN json_type(p.extra, '$.license_override') IS NOT NULL THEN json_extract_string(p.extra, '$.license_override.redistribution_ok') WHEN (p.license_spdx IS NOT NULL OR p.license_training_ok IS NOT NULL OR p.license_redistribution_ok IS NOT NULL OR p.license_notes IS NOT NULL) THEN p.license_redistribution_ok WHEN NOT coalesce(json_contains(json_extract(p.extra, '$._absent'), '"license_override"'), false) THEN b.const_redistribution_ok END, ''), b.redistribution_ok) IN ('yes', 'conditional', 'no') THEN coalesce(nullif(CASE WHEN starts_with(coalesce(p.extra, ''), '{"_row":') THEN json_extract_string(p.extra, '$._row.license_override.redistribution_ok') WHEN json_type(p.extra, '$.license_override') IS NOT NULL THEN json_extract_string(p.extra, '$.license_override.redistribution_ok') WHEN (p.license_spdx IS NOT NULL OR p.license_training_ok IS NOT NULL OR p.license_redistribution_ok IS NOT NULL OR p.license_notes IS NOT NULL) THEN p.license_redistribution_ok WHEN NOT coalesce(json_contains(json_extract(p.extra, '$._absent'), '"license_override"'), false) THEN b.const_redistribution_ok END, ''), b.redistribution_ok) ELSE 'unknown' END) AS redistribution_tier,
  coalesce((SELECT max(t.max_size_bytes) FROM t WHERE t.source = p.source AND t.batch = p.batch AND t.collection IS NOT DISTINCT FROM p.collection AND t.ext IS NOT DISTINCT FROM p.ext AND t.meta_value IS NOT DISTINCT FROM (CASE WHEN b.meta_key IS NOT NULL THEN (CASE WHEN starts_with(coalesce(p.extra, ''), '{"_row":') THEN json_extract_string(p.extra, '$._row.source_meta.' || b.meta_key) WHEN json_type(p.extra, '$.source_meta') IS NOT NULL THEN json_extract_string(p.extra, '$.source_meta.' || b.meta_key) WHEN NOT coalesce(json_contains(json_extract(p.extra, '$._absent'), '"source_meta"'), false) THEN json_extract_string(b.const_source_meta, '$.' || b.meta_key) END) END) AND t.content IS NOT DISTINCT FROM CAST((CASE WHEN starts_with(coalesce(p.extra, ''), '{"_row":') THEN json_extract(p.extra, '$._row.content') WHEN json_type(p.extra, '$.content') IS NOT NULL THEN json_extract(p.extra, '$.content') WHEN NOT coalesce(json_contains(json_extract(p.extra, '$._absent'), '"content"'), false) THEN b.const_content END) AS VARCHAR)), b.max_size_bytes) AS class_cap_bytes,
  EXISTS (SELECT 1 FROM d WHERE d.reason = 'natural_key' AND d.keep_source = p.source AND d.keep_batch = p.batch AND d.keep_row_file = p.row_file AND d.keep_row_index = p.row_index) AS natural_key_conflict
FROM p JOIN b ON b.source = p.source AND b.batch = p.batch
WHERE NOT EXISTS (SELECT 1 FROM d WHERE d.source = p.source AND d.uri = p.uri AND d.range_offset IS NOT DISTINCT FROM p.range_offset AND d.member_path IS NOT DISTINCT FROM p.member_path AND d.batch = p.batch AND d.row_file = p.row_file AND d.row_index = p.row_index)
  AND NOT EXISTS (SELECT 1 FROM o WHERE o.scope = 'row' AND o.hit_class IN ('benchmark_copy', 'task_file', 'data_address') AND o.source = p.source AND o.uri = p.uri AND o.range_offset IS NOT DISTINCT FROM p.range_offset AND o.member_path IS NOT DISTINCT FROM p.member_path)
  AND NOT EXISTS (SELECT 1 FROM o WHERE o.scope = 'container' AND o.hit_class IN ('benchmark_copy', 'task_file', 'data_address') AND o.source = p.source AND o.collection = split_part(p.collection, '@', 1));

The query reads the row tables remotely and only the columns it needs; a full pass over every source moves a few gigabytes. Add p.source IN (...) or read data/<source>/*/*.parquet to stay small. The view adds training_tier and redistribution_tier (yes, conditional, no or unknown) and class_cap_bytes (the reference size cap of the row's content class) and natural_key_conflict (true when other rows with the same natural key were removed as duplicates and this one, from the latest batch, was kept).

Ready-made queries

Each query runs on the selected view above.

  1. Only rows that may be used for training (training tier yes or conditional):
SELECT p.source, p.uri, p.size_bytes, p.training_tier FROM selected p
WHERE p.training_tier IN ('yes', 'conditional') LIMIT 20;

python tools/fetch.py --tier yes,conditional --limit 20 --dry-run

  1. Only the latest version of each package. Latest means the version released last (by release time, so a fix released later for an older line counts as the latest); all files of that version are kept, and rows without a version or a release time are left out. Package ecosystems and the release time used:
Source Release time
pypi source_meta.upload_time
npm source_meta.published
crates-io source_meta.created_at
cran none (the snapshot lists only the current version of each package)
conda-forge-packages source_meta.timestamp
ansible-galaxy-collections source_meta.published
artifact-hub-helm-charts source_meta.created
go-module-proxy-zips source_meta.index_timestamp
hackage-packages source_meta.uploaded

Not ordered by this query:

  • debian-sources: rows carry no release time, and Debian versions need the dpkg ordering rules, which plain SQL does not have; each suite lists one version per source package, so choose a suite with source_meta.suite instead.
  • nuget, rubygems: no release-time field is defined for these rows yet; every version is kept.
CREATE OR REPLACE VIEW latest_version AS
WITH v AS (
  SELECT p.*, concat_ws('/', p.collection, (CASE WHEN starts_with(coalesce(p.extra, ''), '{"_row":') THEN json_extract_string(p.extra, '$._row.source_meta.' || 'chart') WHEN json_type(p.extra, '$.source_meta') IS NOT NULL THEN json_extract_string(p.extra, '$.source_meta.' || 'chart') WHEN NOT coalesce(json_contains(json_extract(p.extra, '$._absent'), '"source_meta"'), false) THEN json_extract_string(b.const_source_meta, '$.' || 'chart') END)) AS package, (CASE WHEN starts_with(coalesce(p.extra, ''), '{"_row":') THEN json_extract_string(p.extra, '$._row.source_meta.' || 'version') WHEN json_type(p.extra, '$.source_meta') IS NOT NULL THEN json_extract_string(p.extra, '$.source_meta.' || 'version') WHEN NOT coalesce(json_contains(json_extract(p.extra, '$._absent'), '"source_meta"'), false) THEN json_extract_string(b.const_source_meta, '$.' || 'version') END) AS version,
    try_cast(CASE p.source WHEN 'pypi' THEN (CASE WHEN starts_with(coalesce(p.extra, ''), '{"_row":') THEN json_extract_string(p.extra, '$._row.source_meta.' || 'upload_time') WHEN json_type(p.extra, '$.source_meta') IS NOT NULL THEN json_extract_string(p.extra, '$.source_meta.' || 'upload_time') WHEN NOT coalesce(json_contains(json_extract(p.extra, '$._absent'), '"source_meta"'), false) THEN json_extract_string(b.const_source_meta, '$.' || 'upload_time') END) WHEN 'npm' THEN (CASE WHEN starts_with(coalesce(p.extra, ''), '{"_row":') THEN json_extract_string(p.extra, '$._row.source_meta.' || 'published') WHEN json_type(p.extra, '$.source_meta') IS NOT NULL THEN json_extract_string(p.extra, '$.source_meta.' || 'published') WHEN NOT coalesce(json_contains(json_extract(p.extra, '$._absent'), '"source_meta"'), false) THEN json_extract_string(b.const_source_meta, '$.' || 'published') END) WHEN 'crates-io' THEN (CASE WHEN starts_with(coalesce(p.extra, ''), '{"_row":') THEN json_extract_string(p.extra, '$._row.source_meta.' || 'created_at') WHEN json_type(p.extra, '$.source_meta') IS NOT NULL THEN json_extract_string(p.extra, '$.source_meta.' || 'created_at') WHEN NOT coalesce(json_contains(json_extract(p.extra, '$._absent'), '"source_meta"'), false) THEN json_extract_string(b.const_source_meta, '$.' || 'created_at') END) WHEN 'cran' THEN '1970-01-01T00:00:00Z' WHEN 'conda-forge-packages' THEN (CASE WHEN starts_with(coalesce(p.extra, ''), '{"_row":') THEN json_extract_string(p.extra, '$._row.source_meta.' || 'timestamp') WHEN json_type(p.extra, '$.source_meta') IS NOT NULL THEN json_extract_string(p.extra, '$.source_meta.' || 'timestamp') WHEN NOT coalesce(json_contains(json_extract(p.extra, '$._absent'), '"source_meta"'), false) THEN json_extract_string(b.const_source_meta, '$.' || 'timestamp') END) WHEN 'ansible-galaxy-collections' THEN (CASE WHEN starts_with(coalesce(p.extra, ''), '{"_row":') THEN json_extract_string(p.extra, '$._row.source_meta.' || 'published') WHEN json_type(p.extra, '$.source_meta') IS NOT NULL THEN json_extract_string(p.extra, '$.source_meta.' || 'published') WHEN NOT coalesce(json_contains(json_extract(p.extra, '$._absent'), '"source_meta"'), false) THEN json_extract_string(b.const_source_meta, '$.' || 'published') END) WHEN 'artifact-hub-helm-charts' THEN (CASE WHEN starts_with(coalesce(p.extra, ''), '{"_row":') THEN json_extract_string(p.extra, '$._row.source_meta.' || 'created') WHEN json_type(p.extra, '$.source_meta') IS NOT NULL THEN json_extract_string(p.extra, '$.source_meta.' || 'created') WHEN NOT coalesce(json_contains(json_extract(p.extra, '$._absent'), '"source_meta"'), false) THEN json_extract_string(b.const_source_meta, '$.' || 'created') END) WHEN 'go-module-proxy-zips' THEN (CASE WHEN starts_with(coalesce(p.extra, ''), '{"_row":') THEN json_extract_string(p.extra, '$._row.source_meta.' || 'index_timestamp') WHEN json_type(p.extra, '$.source_meta') IS NOT NULL THEN json_extract_string(p.extra, '$.source_meta.' || 'index_timestamp') WHEN NOT coalesce(json_contains(json_extract(p.extra, '$._absent'), '"source_meta"'), false) THEN json_extract_string(b.const_source_meta, '$.' || 'index_timestamp') END) WHEN 'hackage-packages' THEN (CASE WHEN starts_with(coalesce(p.extra, ''), '{"_row":') THEN json_extract_string(p.extra, '$._row.source_meta.' || 'uploaded') WHEN json_type(p.extra, '$.source_meta') IS NOT NULL THEN json_extract_string(p.extra, '$.source_meta.' || 'uploaded') WHEN NOT coalesce(json_contains(json_extract(p.extra, '$._absent'), '"source_meta"'), false) THEN json_extract_string(b.const_source_meta, '$.' || 'uploaded') END) END AS TIMESTAMPTZ) AS released
  FROM selected p JOIN b ON b.source = p.source AND b.batch = p.batch
  WHERE p.source IN ('pypi', 'npm', 'crates-io', 'cran', 'conda-forge-packages', 'ansible-galaxy-collections', 'artifact-hub-helm-charts', 'go-module-proxy-zips', 'hackage-packages')
), best AS (
  SELECT source, package, arg_max(version, released) AS version FROM (
    SELECT source, package, version, max(released) AS released FROM v
    WHERE version IS NOT NULL AND released IS NOT NULL GROUP BY ALL)
  GROUP BY ALL
)
SELECT v.* FROM v JOIN best ON best.source = v.source AND best.package = v.package AND best.version = v.version;
SELECT source, package, version, count(*) AS files FROM latest_version GROUP BY ALL ORDER BY 1, 2 LIMIT 20;
  1. Only rows within the reference size cap of their content class (rows of unknown size stay in; tools/fetch.py --cap per-class stops their download at the same cap):
SELECT p.source, p.uri, p.size_bytes, p.class_cap_bytes FROM selected p
WHERE p.size_bytes IS NULL OR p.size_bytes <= p.class_cap_bytes LIMIT 20;

python tools/fetch.py --cap per-class --limit 20 --out ./files (rows above the class cap are recorded as too_large and not downloaded)

Examples

  1. Rows tagged data-processing, CSV files only:
SELECT p.source, p.uri, p.size_bytes FROM selected p JOIN b ON b.source = p.source AND b.batch = p.batch WHERE lower(p.ext) = 'csv' AND EXISTS (SELECT 1 FROM t WHERE t.source = p.source AND t.batch = p.batch AND t.collection IS NOT DISTINCT FROM p.collection AND t.ext IS NOT DISTINCT FROM p.ext AND t.meta_value IS NOT DISTINCT FROM (CASE WHEN b.meta_key IS NOT NULL THEN (CASE WHEN starts_with(coalesce(p.extra, ''), '{"_row":') THEN json_extract_string(p.extra, '$._row.source_meta.' || b.meta_key) WHEN json_type(p.extra, '$.source_meta') IS NOT NULL THEN json_extract_string(p.extra, '$.source_meta.' || b.meta_key) WHEN NOT coalesce(json_contains(json_extract(p.extra, '$._absent'), '"source_meta"'), false) THEN json_extract_string(b.const_source_meta, '$.' || b.meta_key) END) END) AND t.content IS NOT DISTINCT FROM CAST((CASE WHEN starts_with(coalesce(p.extra, ''), '{"_row":') THEN json_extract(p.extra, '$._row.content') WHEN json_type(p.extra, '$.content') IS NOT NULL THEN json_extract(p.extra, '$.content') WHEN NOT coalesce(json_contains(json_extract(p.extra, '$._absent'), '"content"'), false) THEN b.const_content END) AS VARCHAR) AND t.tag IN ('data-processing')) LIMIT 20;

python tools/fetch.py --tag data-processing --ext csv --limit 20 --out ./files

  1. Rows tagged office-spreadsheets, smallest first:
SELECT p.source, p.uri, p.size_bytes FROM selected p JOIN b ON b.source = p.source AND b.batch = p.batch WHERE EXISTS (SELECT 1 FROM t WHERE t.source = p.source AND t.batch = p.batch AND t.collection IS NOT DISTINCT FROM p.collection AND t.ext IS NOT DISTINCT FROM p.ext AND t.meta_value IS NOT DISTINCT FROM (CASE WHEN b.meta_key IS NOT NULL THEN (CASE WHEN starts_with(coalesce(p.extra, ''), '{"_row":') THEN json_extract_string(p.extra, '$._row.source_meta.' || b.meta_key) WHEN json_type(p.extra, '$.source_meta') IS NOT NULL THEN json_extract_string(p.extra, '$.source_meta.' || b.meta_key) WHEN NOT coalesce(json_contains(json_extract(p.extra, '$._absent'), '"source_meta"'), false) THEN json_extract_string(b.const_source_meta, '$.' || b.meta_key) END) END) AND t.content IS NOT DISTINCT FROM CAST((CASE WHEN starts_with(coalesce(p.extra, ''), '{"_row":') THEN json_extract(p.extra, '$._row.content') WHEN json_type(p.extra, '$.content') IS NOT NULL THEN json_extract(p.extra, '$.content') WHEN NOT coalesce(json_contains(json_extract(p.extra, '$._absent'), '"content"'), false) THEN b.const_content END) AS VARCHAR) AND t.tag IN ('office-spreadsheets')) ORDER BY p.size_bytes LIMIT 20;

python tools/fetch.py --tag office-spreadsheets --limit 20 --dry-run

python tools/fetch.py --print-sql ... prints the exact query the script runs, so any selection can be repeated in DuckDB. The script checks size and every hash of each download and writes fetch_manifest.jsonl with one line per selected row.