gengliangwang commented on code in PR #60314:
URL: https://github.com/apache/spark/pull/60314#discussion_r4621548060
##########
sql/native/rust/README.md:
##########
@@ -488,11 +488,34 @@ so that the scan can plan to read only them. The readers
get them as the schema
whether or not the scan implements it, and return exactly them, so a connector
can add
pruning to the planning of its scans incrementally.
-SPARK-61200 added `push_domains` to version 1 of the ABI: the domains of the
columns that the
-filters of a query constrain, with which a scan can skip data, such as a file
whose statistics
-exclude every value of a domain. The SDK binds the function but does not
expose it yet: it leaves
-it unset, so Spark pushes no filters down and evaluates them after reading.
SPARK-61306 will add
-it to `ScanBuilder`, with a default that uses no domain, so existing
connectors keep building.
+`ScanBuilder::push_domains` gets the domains of the columns that the filters
of the query
+constrain: for each column, whether null and NaN are in its domain, and the
ranges of its other
+values, sorted and without overlaps, or none for all of them. A scan can skip
the data that has
+no value in the domain of a column, such as a file or a row group whose
statistics exclude every
+value of the domain, but never a row whose values are all in their domains.
Spark evaluates all
+the filters after reading anyway, so the rows of a scan need not match them.
The method returns
+whether the scan uses each domain: Spark shows a filter as pushed, in the
formatted plan of the
+query and in the SQL tab of the Spark UI, when the scan uses the domains of
all the columns that
+the filter constrains. The default uses none, so a connector can ignore the
method. Spark pushes
+the domains to every builder, also to one that keeps the default: for a query
whose filters give
+a domain, it creates the source and the builder of the scan while it optimizes
the query, as it
+does for a LIMIT that it pushes, rather than when it plans the partitions.
Review Comment:
Done in 4ba076fabc70: Added that setting
`spark.sql.dataSource.native.filterPushdown.enabled` to false makes Spark push
no domain, for a connector whose `new`/`new_scan` is expensive and that uses
none.
##########
sql/native/rust/src/abi.rs:
##########
@@ -791,6 +848,40 @@ pub unsafe fn export_schema(schema: &SchemaRef, output:
*mut ArrowSchema) -> Res
Ok(())
}
+/// Checks Arrow data that Spark passed, as imported from C data, which Arrow
neither aligns nor
+/// validates, while the safe accessors of the connector rely on both. Arrow
requires each buffer
+/// of fixed-width values to be aligned to its type, such as the 16 bytes of
an `i128` for a
+/// decimal on x86_64 and aarch64, which the Arrow Java allocator of Spark
does not promise, so
+/// this copies the buffers that are not aligned, and only those. It then
validates the layout
+/// and values of the data: a Spark string may hold bytes that are not UTF-8,
such as those of a
+/// cast from binary, which a Rust `&str` must not. It leaves nullability to
Spark, for the reason
+/// that `validate` gives.
+pub fn check(mut data: ArrayData) -> Result<ArrayData> {
Review Comment:
Done in 4ba076fabc70: Renamed `abi::check` to `align_and_validate` and
updated its doc and both call sites.
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]