raghuvanshraj commented on code in PR #12303:
URL: https://github.com/apache/arrow-rs/pull/12303#discussion_r4715670297


##########
parquet-variant/src/canonicalize.rs:
##########
@@ -0,0 +1,552 @@
+// SPDX-License-Identifier: Apache-2.0
+// SPDX-FileCopyrightText: See the NOTICE file distributed with this work for 
additional information regarding copyright ownership
+// SPDX-FileContributor: Licensed to the Apache Software Foundation (ASF) 
under one or more contributor license agreements
+
+//! Canonical encoding of [`Variant`] values.
+//!
+//! The Variant binary encoding allows one logical value to be written in many 
ways: the metadata
+//! dictionary may hold unused or unsorted field names, an integer may use a 
wider width than it
+//! needs, a decimal may carry trailing zeros, and so on. Byte-oriented 
operations such as hashing
+//! for `GROUP BY` or a join therefore treat equal values as different.
+//!
+//! [`Variant::canonicalize`] rebuilds a value so that equal values share one 
encoding.
+
+use std::collections::BTreeSet;
+
+use arrow_schema::ArrowError;
+
+use crate::{
+    ObjectFieldBuilder, Variant, VariantBuilder, VariantBuilderExt, 
VariantDecimal4,
+    VariantDecimal8, VariantDecimal16, VariantObject,
+};
+
+impl Variant<'_, '_> {
+    /// Returns the canonical `(metadata, value)` encoding of this variant.
+    ///
+    /// Two variants that are logically equal canonicalize to identical bytes, 
so the result can be
+    /// hashed or compared byte-wise. The rules follow the canonical form 
proposed for Apache Spark
+    /// ([apache/spark#59669]):
+    ///
+    /// * The metadata dictionary holds only the field names the value 
references, sorted by their

Review Comment:
   Agreed, so that explanation now lives as the module doc on equivalence.rs, 
with the spec table linked, and the canonicalize doc points to it.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to