![]() |
OpenMS
|
Primary-key-aware, order-insensitive, tolerant comparison of Parquet tables. More...
#include <ParquetDiff/include/ParquetTableComparator.h>
Static Public Member Functions | |
| static ParquetDiffResult | compare (const std::string &file_1, const std::string &file_2, const ParquetDiffSettings &settings) |
| Compare two Parquet files. | |
| static ParquetDiffResult | validate (const std::string &file, const std::string &view, const ParquetDiffSettings &settings) |
| Check one Parquet file against a built-in QPX schema. | |
| static bool | dumpToTsv (const std::string &file, const std::string &out_file, const ParquetDiffSettings &settings) |
| Write a Parquet table out as TSV, one row per line, sorted by primary key. | |
| static std::vector< std::string > | qpxPrimaryKey (const std::string &view) |
| The primary key of a QPX view. | |
| static std::vector< std::string > | qpxIdentityColumns (const std::string &view) |
| The opaque identity and cross-reference columns of a QPX view. | |
| static std::string | viewFromFileType (const std::string &file_type) |
Map a QPX file_type metadata value to a view name. | |
Primary-key-aware, order-insensitive, tolerant comparison of Parquet tables.
Two Parquet files holding the same logical table may legitimately differ in row order and in the low-order bits of floating-point columns, so neither a byte comparison nor a text diff of a serialised form answers "are these the same result?". This class matches rows by a primary key, compares the matched rows cell-by-cell with a numeric tolerance, and reports schema drift separately from value drift.
It is the table-shaped counterpart of FuzzyDiff, and is exposed as ParquetDiff.
|
static |
Compare two Parquet files.
Rows are matched on ParquetDiffSettings::primary_key. List-valued key columns are canonicalised by sorting their elements before the key is formed, matching how QPX treats set-valued key columns such as grouped_runs.
| [in] | file_1 | first Parquet file |
| [in] | file_2 | second Parquet file |
| [in] | settings | tolerance, key and reporting options |
References ParquetDiffResult::equal, first, ParquetDiffResult::key_errors, ParquetDiffResult::max_absdiff, ParquetDiffResult::max_ratio, ParquetDiffSettings::max_reported, ParquetDiffSettings::primary_key, ParquetDiffResult::primary_key_used, ParquetTableComparator::qpxPrimaryKey(), ParquetDiffResult::rows_1, ParquetDiffResult::rows_2, ParquetDiffResult::rows_compared, ParquetDiffResult::schema_errors, ParquetDiffSettings::schema_only, ParquetDiffResult::suppressed, ParquetDiffResult::value_errors, and ParquetTableComparator::viewFromFileType().
|
static |
Write a Parquet table out as TSV, one row per line, sorted by primary key.
A Parquet file cannot be reviewed in a diff or patched by hand, so a committed binary reference can only ever be regenerated wholesale - which is exactly the operation that hides unrelated drift. Dumping to text puts Parquet output back on the same footing as every other reference in the suite: readable in a pull request, comparable with FuzzyDiff, and editable line by line.
Rows are emitted in primary-key order rather than file order, so the dump does not depend on the order the producer happened to write - the same property that makes the comparison order-insensitive. List- and struct-valued cells are rendered in full; nulls print as null, which is distinct from an empty string or a zero.
| [in] | file | the Parquet file to read |
| [in] | out_file | destination TSV path |
| [in] | settings | only ParquetDiffSettings::primary_key is used; when empty the key is derived from the file's QPX file_type metadata, and failing that rows are emitted in file order |
References OPENMS_LOG_ERROR, OPENMS_LOG_WARN, ParquetDiffSettings::primary_key, ParquetTableComparator::qpxPrimaryKey(), and ParquetTableComparator::viewFromFileType().
|
static |
The opaque identity and cross-reference columns of a QPX view.
feature_id / psm_id / pg_id, plus the optional references between the views. They are derived from the other columns rather than measured, so a difference in one is always a difference in something else that is reported anyway – see ParquetDiffSettings::compare_identity_columns for why comparing them across files is wrong rather than merely redundant.
| [in] | view | "psm", "feature" or "pg" |
References QPXPSMSchema::FEATURE_ID, QPXFeatureSchema::FEATURE_ID, QPXPgSchema::PG_ID, QPXPSMSchema::PSM_ID, and QPXFeatureSchema::PSM_IDS.
Referenced by ParquetTableComparator::validate().
|
static |
The primary key of a QPX view.
| [in] | view | one of psm, feature, pg |
| Exception::IllegalArgument | if view is not a known view name |
References QPXPgSchema::ANCHOR_PROTEIN, QPXPSMSchema::CHARGE, QPXFeatureSchema::CHARGE, QPXPgSchema::GROUPED_RUNS, QPXPgSchema::LABEL, QPXFeatureSchema::OBSERVED_MZ, QPXPSMSchema::PEPTIDOFORM, QPXFeatureSchema::PEPTIDOFORM, QPXFeatureSchema::RT, QPXPSMSchema::RUN_FILE_NAME, QPXFeatureSchema::RUN_FILE_NAME, and QPXPSMSchema::SCAN.
Referenced by ParquetTableComparator::compare(), ParquetTableComparator::dumpToTsv(), and ParquetTableComparator::validate().
|
static |
Check one Parquet file against a built-in QPX schema.
Reports columns the view requires but the file lacks, columns whose Arrow type differs from the schema, and columns the file carries that the view does not define. Duplicate primary keys are reported as well, since a QPX primary key must be unique.
| [in] | file | the Parquet file to check |
| [in] | view | one of psm, feature, pg |
| [in] | settings | reporting options (tolerances are unused) |
| Exception::IllegalArgument | if view is not a known view name |
References File::basename(), ParquetDiffResult::equal, ParquetDiffResult::key_errors, ParquetDiffSettings::max_reported, ParquetDiffSettings::primary_key, ParquetDiffResult::primary_key_used, ParquetTableComparator::qpxIdentityColumns(), ParquetTableComparator::qpxPrimaryKey(), ParquetDiffResult::rows_1, QPXPSMSchema::schema(), QPXFeatureSchema::schema(), QPXPgSchema::schema(), ParquetDiffResult::schema_errors, ParquetDiffSettings::schema_only, and ParquetDiffResult::suppressed.
|
static |
Map a QPX file_type metadata value to a view name.
| [in] | file_type | e.g. psm_file, feature_file, pg_file |
file_type is not recognised Referenced by ParquetTableComparator::compare(), and ParquetTableComparator::dumpToTsv().