ENH: deterministic ordering for better Parquet compression#128
Merged
Conversation
… Parquet compression Add ORDER BY to all ARRAY_AGG/STRING_AGG calls that lacked it, ensuring identical logical arrays are always encoded the same way (improving dictionary encoding). Add compression-friendly final ORDER BY to all queries, clustering rows by semantically meaningful columns (anatomy, staining, collection) rather than arbitrary UIDs to maximize run-length and dictionary encoding in the output Parquet files. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…ibility BigQuery does not support positional ORDER BY inside aggregate functions. Replace all ORDER BY 1 with the actual aggregated expression. Also fix final ORDER BY clauses that referenced ARRAY columns (not sortable in BQ) by using [SAFE_OFFSET(0)] to extract the first element. Add BQ dry-run validation guidance to CLAUDE.md. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Member
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Summary
ORDER BYto allARRAY_AGG/STRING_AGGcalls that lacked deterministic ordering (21 aggregations across 7 files), ensuring identical logical arrays are always encoded the same way across query runsORDER BYto all queries (9 files), clustering rows by semantically meaningful columns (anatomy, staining, collection, algorithm type) rather than arbitrary UIDsSTRING_AGG(DISTINCT collection_id)withANY_VALUE(collection_id)insm_index.sqlsince a series always belongs to one collectionseg_index.sqldo not preserve positional correspondenceThese changes improve Parquet dictionary encoding and run-length encoding without removing any content from query results.
Files changed
scripts/sql/idc_index.sqlORDER BY collection_id, PatientID, StudyInstanceUID, SeriesInstanceUIDscripts/sql/prior_versions_index.sqlORDER BY versiontoSTRING_AGG+ finalORDER BY collection_id, min_idc_version, Modalityscripts/sql/collections_index.sqlORDER BY collection_idscripts/sql/analysis_results_index.sqlORDER BY analysis_result_idassets/sm_index.sqlORDER BY primaryAnatomicStructure, staining, collection_idassets/sm_instance_index.sqlstaining, TransferSyntaxUID, SeriesInstanceUIDassets/seg_index.sqlORDER BY SegmentationType, AlgorithmType, AlgorithmNameassets/contrast_index.sqlORDER BY ContrastBolusAgent, Ingredient, Routeassets/ann_index.sqlORDER BY AnnotationCoordinateType, referenced_SeriesInstanceUIDassets/ann_group_index.sqlORDER BY category, type, algorithmscripts/gdc/idc_gdc_selection.sqlARRAY_AGGTest plan
🤖 Generated with Claude Code