MCPcopy Create free account
hub / github.com/apache/paimon-rust / validate_row

Method validate_row

crates/paimon/src/spec/partition_utils.rs:115–149  ·  view source on GitHub ↗

Validate that the `BinaryRow` is compatible with this computer's partition keys.

(&self, row: &BinaryRow)

Source from the content-addressed store, hash-verified

113
114 /// Validate that the `BinaryRow` is compatible with this computer's partition keys.
115 fn validate_row(&self, row: &BinaryRow) -> crate::Result<()> {
116 if self.partition_keys.len() != row.arity() as usize {
117 return Err(Error::UnexpectedError {
118 message: format!(
119 "Partition keys length ({}) does not match row arity ({})",
120 self.partition_keys.len(),
121 row.arity()
122 ),
123 source: None,
124 });
125 }
126
127 if row.is_empty() {
128 return Err(Error::UnexpectedError {
129 message: "Partition row has no backing data but arity > 0".to_string(),
130 source: None,
131 });
132 }
133
134 // Validate that the backing data is large enough for null-bits + fixed-part.
135 let min_size = BinaryRow::cal_bit_set_width_in_bytes(row.arity()) as usize
136 + (row.arity() as usize) * 8;
137 if row.data().len() < min_size {
138 return Err(Error::UnexpectedError {
139 message: format!(
140 "Partition BinaryRow data too short: need at least {} bytes, got {}",
141 min_size,
142 row.data().len()
143 ),
144 source: None,
145 });
146 }
147
148 Ok(())
149 }
150}
151
152/// Resolve the `DataField` for each partition key from the schema fields, preserving order.

Callers 1

generate_part_valuesMethod · 0.80

Calls 4

arityMethod · 0.80
dataMethod · 0.80
lenMethod · 0.45
is_emptyMethod · 0.45

Tested by

no test coverage detected