Re: [PR] [python] Push batched Variant extraction into native reads [paimon-rust]
JingsongLi merged PR #1009: URL: https://github.com/apache/paimon-rust/pull/1009 -- 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]
Re: [PR] [python] Push batched Variant extraction into native reads [paimon-rust]
XiaoHongbo-Hope commented on PR #1009: URL: https://github.com/apache/paimon-rust/pull/1009#issuecomment-5980713295 > Reverified the rebased [34cf10f](https://github.com/apache/paimon-rust/commit/34cf10ffce01de1dff3e39e98375adaaf09e07f0) against main [5a81a6d](https://github.com/apache/paimon-rust/commit/5a81a6d92a1bb8a9a327c5f98c716a0c10c29645) (the integrated tree is identical to the PR head). The previous merge conflict is resolved. I rebuilt and loaded the exact native Python extension: all 113 author/Java-description interoperability read tests and 73 Rust Variant tests pass. The Java FLOAT string finding remains: the additional two actual SQL-written Parquet/native Python read probes still return 1.5 for NBSP-wrapped "1.5" under both fail_on_error=false and true, instead of NULL or a cast error. Float.parseFloat rejects NBSP; the revised variant.rs:2826 still uses Unicode trim(). Please replace this with Java-compatible string parsing/trimming in the shared conversion used by the fast path, and retain both error-policy regression tests. Thanks, fixed -- 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]
Re: [PR] [python] Push batched Variant extraction into native reads [paimon-rust]
JingsongLi commented on code in PR #1009:
URL: https://github.com/apache/paimon-rust/pull/1009#discussion_r4177621158
##
crates/paimon/src/variant.rs:
##
@@ -2797,6 +2808,25 @@ fn cast_variant_to_f64(variant: VariantRef<'_>) ->
Option {
}
}
+pub(crate) fn cast_variant_to_f32(variant: VariantRef<'_>) -> Option {
+match variant.kind().ok()? {
+VariantKind::Boolean => Some(if variant.get_boolean().ok()? {
+1.0
+} else {
+0.0
+}),
+VariantKind::Long => Some(variant.get_long().ok()? as f32),
+VariantKind::Float => variant.get_float().ok(),
+VariantKind::Double => Some(variant.get_double().ok()? as f32),
+VariantKind::Decimal => {
+let decimal = variant.get_decimal().ok()?;
+Some((decimal.unscaled as f64 / 10f64.powi(decimal.scale as i32))
as f32)
+}
+VariantKind::String =>
variant.get_string().ok()?.trim().parse::().ok(),
Review Comment:
[P2] Use Java whitespace rules for Variant string-to-FLOAT casts. Rust
str::trim removes Unicode whitespace such as NBSP (U+00A0), whereas Java
VariantGet delegates through
StringToNumericPrimitiveCastRule/BinaryStringUtils.toFloat to Float.parseFloat,
which rejects a NBSP-wrapped number. With a real table containing
{"x":"\u00a01.5\u00a0"}, the new native FLOAT projection returns 1.5 for
failOnError=false instead of null, and also returns 1.5 for failOnError=true
instead of failing. Both Python/Parquet probes fail; a Java runtime probe
rejects the same string, and the previous Rust f64 cast also rejected it. This
silently changes data/error semantics across Java and Rust. Trim only the
characters accepted by Java and cover both error policies while retaining
ordinary ASCII whitespace support.
--
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]
Re: [PR] [python] Push batched Variant extraction into native reads [paimon-rust]
JingsongLi commented on PR #1009: URL: https://github.com/apache/paimon-rust/pull/1009#issuecomment-5978038131 The new `with_read_type` API follows Java's `withReadType` model. As the next step, please align the read-type JSON produced by both Rust and the paired PyPaimon PR with Java's existing contract, especially the Variant field descriptions. Java's [`VariantMetadataUtils`](https://github.com/apache/paimon/blob/09d859879ee5ff4765a9bd1ae7fe6b16c1188a05/paimon-common/src/main/java/org/apache/paimon/data/variant/VariantMetadataUtils.java#L45) encodes these descriptions as: ```text __VARIANT_METADATA;; ``` For example: `__VARIANT_METADATA$.x;false;UTC`. Rust's `build_variant_metadata` and PyPaimon's `_variant_read_type_json` instead emit a JSON payload after the marker. Java currently only parses the semicolon-separated format. I verified that parsing the current Python-generated description with Java's `failOnError` method throws `ArrayIndexOutOfBoundsException`. Please make both producers emit the Java format first, and add interoperability tests for Java-generated read-type JSON consumed by Rust and Python/Rust-generated read-type JSON consumed by Java, checking the path, error flag, and time zone. Rust can retain its JSON-payload parser for backward compatibility if needed, while newly generated descriptions should use the shared Java representation. Please also apply Java's restriction on semicolons in paths consistently. The overall ROW schema can remain JSON; the incompatibility here is the encoding inside each Variant child's `description`. -- 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]
Re: [PR] [python] Push batched Variant extraction into native reads [paimon-rust]
XiaoHongbo-Hope commented on code in PR #1009: URL: https://github.com/apache/paimon-rust/pull/1009#discussion_r4175864730 ## bindings/python/python/pypaimon_rust/datafusion.pyi: ## @@ -87,7 +87,14 @@ class TableRead: def read(self, splits: Sequence[Split]) -> List[pyarrow.RecordBatch]: ... class ReadBuilder: -def with_projection(self, columns: List[str]) -> "ReadBuilder": ... +def with_projection( Review Comment: Thanks, updated in 8fdc6bd. The Rust Python binding now exposes `with_read_type` for a Paimon ROW read type and no longer adds a Variant-specific argument to `with_projection`. PyPaimon #10336 converts its existing public `variant_fields` option to that read type. Local binding tests (112) and paired PyPaimon tests (247) pass. -- 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]
Re: [PR] [python] Push batched Variant extraction into native reads [paimon-rust]
XiaoHongbo-Hope commented on code in PR #1009: URL: https://github.com/apache/paimon-rust/pull/1009#discussion_r4175864730 ## bindings/python/python/pypaimon_rust/datafusion.pyi: ## @@ -87,7 +87,14 @@ class TableRead: def read(self, splits: Sequence[Split]) -> List[pyarrow.RecordBatch]: ... class ReadBuilder: -def with_projection(self, columns: List[str]) -> "ReadBuilder": ... +def with_projection( Review Comment: Thanks, updated in 8fdc6bd. The Rust Python binding now exposes `with_read_type` for a Paimon ROW read type and no longer adds a Variant-specific argument to `with_projection`. PyPaimon #10336 converts its existing public `variant_fields` option to that read type. Local binding tests (112) and paired PyPaimon tests (247) pass. -- 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]
Re: [PR] [python] Push batched Variant extraction into native reads [paimon-rust]
JingsongLi commented on code in PR #1009: URL: https://github.com/apache/paimon-rust/pull/1009#discussion_r4175670578 ## bindings/python/python/pypaimon_rust/datafusion.pyi: ## @@ -87,7 +87,14 @@ class TableRead: def read(self, splits: Sequence[Split]) -> List[pyarrow.RecordBatch]: ... class ReadBuilder: -def with_projection(self, columns: List[str]) -> "ReadBuilder": ... +def with_projection( Review Comment: Can we use withReadType like Java? -- 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]
Re: [PR] [python] Push batched Variant extraction into native reads [paimon-rust]
JingsongLi commented on code in PR #1009:
URL: https://github.com/apache/paimon-rust/pull/1009#discussion_r4173422997
##
crates/paimon/src/table/kv_file_reader.rs:
##
@@ -392,6 +394,33 @@ impl KeyValueFileReader {
.map(|s| s.as_str())
.collect();
+// File readers run before PK deduplication. Keep Variant values in
their
+// logical storage type until the visible row has been selected: a
strict
+// extraction must not fail on an older, overwritten version.
+let merge_read_type: Vec = self
+.config
+.read_type
+.iter()
+.map(|field| {
+if !is_variant_extraction_row_type(field.data_type()) {
+return Ok(field.clone());
+}
+self.config
+.table_fields
+.iter()
+.find(|source| source.id() == field.id())
+.filter(|source| matches!(source.data_type(),
PaimonDataType::Variant(_)))
+.cloned()
Review Comment:
[P2] Preserve the requested field name when restoring the Variant storage
type
Cloning the complete table field here replaces the name supplied through
`with_read_type`. That API can resolve historical fields by their stable field
IDs when reading older files, but `reorder_map` later still looks up the
original requested name in `value_fields` and calls `unwrap()`.
I reproduced this by writing two versions of the same primary key, renaming
`payload` to `renamed_payload`, then requesting a FLOAT32 Variant extraction
with the original name `payload` and the unchanged field ID through the Rust
`with_read_type` API. The splits require sort-merge. Base commit `69118de8`
returns the expected value `1.5`; this head panics at line 578 with
`Option::unwrap()` on `None`. This is specific to the Rust historical-name
read-type path; the Python builder uses canonical names.
Please retain the requested field's ID and name and replace only its data
type with the source Variant type, or resolve the output mapping by field ID.
--
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]
[PR] [python] Push batched Variant extraction into native reads [paimon-rust]
XiaoHongbo-Hope opened a new pull request, #1009: URL: https://github.com/apache/paimon-rust/pull/1009 ### Purpose Avoid materializing a complete wide Variant column in Python when a reader only needs many typed numeric paths. The existing Variant extraction read type evaluates each row/path independently. This change reuses the batched layout/slot cache added by #997 for the common case of top-level `FLOAT` extractions, while preserving the existing read type and output schema. ### Brief change log - Batch plain, top-level Variant-to-`FLOAT` extractions through the existing typed Variant read path. - Preserve path order, duplicate paths, null rows, missing fields, numeric casts, and `fail_on_error` behavior. - Fall back to the existing general implementation for nested paths, mixed target types, and shredded Variant values. - Add a low-level Python `ReadBuilder.with_variant_projection(...)` hook that composes with normal column projection. A PyPaimon public API is intentionally out of scope. ### Tests - `cargo test -p paimon arrow::shredding::variant::tests --lib` - `cargo test -p paimon arrow::variant::tests --lib` - `cargo test -p paimon variant::numeric::tests --lib` - `cargo test -p paimon-datafusion --test variant_pushdown` - `pytest -q bindings/python/tests/test_read.py` (107 passed) - `cargo clippy -p paimon -p pypaimon_rust --all-targets -- -D warnings` An earlier F-zone prototype used the same #997 batched extraction kernel immediately before the Python FFI boundary on the target workload (8 ranks x 8 workers, batch size 16, three fresh runs): | metric | control median | batched prototype median | | --- | ---: | ---: | | supply throughput | 276.67 samples/s | 337.95 samples/s | | pose p50 | 1.337 s | 1.106 s | | Python-visible topic Arrow bytes | 426.3 MB | 1.21 MB | | process-tree peak RSS | 106.8 GiB | 106.5 GiB | The throughput change was +22.1%. The prototype returned a `FixedSizeList` from a benchmark-only post-read hook; this PR instead integrates the same kernel with the existing typed Struct read path. These numbers motivate the change but are not presented as an exact A/B of the final API. ### API and Format Adds a Python binding method. No storage-format change. ### Documentation The low-level binding is documented in its type stub. Higher-level PyPaimon API work is separate. -- 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]
