feat: add implicit native coercion constructor (#24282) ## Which issue does this PR close? - Closes #24135. ## Rationale for this change When a coercion's desired type is a native logical type, callers currently have to repeat that type as both `TypeSignatureClass::Native(...)` and `default_casted_type`. This duplication is confusing and can allow the two values to disagree. ## What changes are included in this PR? - Add `Coercion::new_implicit_native`, which derives `default_casted_type` from the desired logical type and delegates to the existing `new_implicit` constructor. - Keep `Coercion::new_implicit` unchanged for backward compatibility and non-native desired type classes. - Migrate the representative `reverse` and `approx_percentile_cont` call sites linked from the issue. - Update the `Coercion` rustdoc example and add a constructor-equivalence unit test. ## Are these changes tested? Yes: - `cargo test -p datafusion-expr-common test_new_implicit_native --lib` - `cargo test -p datafusion-functions reverse --lib` - `cargo test -p datafusion-functions-aggregate approx_percentile_cont --lib` - `cargo test -p datafusion-expr-common --doc` - `cargo clippy -p datafusion-expr-common -p datafusion-functions -p datafusion-functions-aggregate --all-targets --all-features -- -D warnings` - `cargo fmt --all` The required full-workspace `cargo clippy --all-targets --all-features -- -D warnings` was also attempted on Windows. It reached an unrelated MSVC native-link failure while building `protobuf-src` (`LNK2005`/`LNK4098` in `protoc-gen-upb`); affected-crate clippy passed with warnings denied, and CI will run the full Linux workspace checks. No benchmark was run because this is an API convenience constructor that delegates to the existing constructor and does not change runtime execution. ## Are there any user-facing changes? Yes. This adds the public `Coercion::new_implicit_native` convenience API. It is additive and backward compatible; existing `new_implicit` callers continue to work unchanged. --------- Co-authored-by: jiangzhen <jiangzhen@nuanwa.net>
DataFusion is an extensible query engine written in Rust that uses Apache Arrow as its in-memory format.
This crate provides libraries and binaries for developers building fast and feature-rich database and analytic systems, customized for particular workloads. See use cases for examples. The following related subprojects target end users:
“Out of the box,” DataFusion offers SQL and DataFrame APIs, excellent performance, built-in support for CSV, Parquet, JSON, and Avro, extensive customization, and a great community.
DataFusion features a full query planner, a columnar, streaming, multi-threaded, vectorized execution engine, and partitioned data sources. You can customize DataFusion at almost all points including additional data sources, query languages, functions, custom operators and more. See the Architecture section for more details.
Here are links to important resources:
DataFusion is great for building projects such as domain-specific query engines, new database platforms and data pipelines, query languages and more. It lets you start quickly from a fully working engine, and then customize those features specific to your needs. See the list of known users.
Please see the contributor guide and communication pages for more information.
We discuss our roadmap via GitHub issues and invite you to join the conversation. The current discussion is the DataFusion 2026 Q3-Q4 Roadmap Discussion.
This crate has several features which can be specified in your Cargo.toml.
Default features:
nested_expressions: functions for working with nested types such as array_to_stringcompression: reading files compressed with xz2, bzip2, flate2, and zstdcrypto_expressions: cryptographic functions such as md5 and sha256datetime_expressions: date and time functions such as to_timestampencoding_expressions: encode and decode functionsparquet: support for reading the Apache Parquet formatsql: support for SQL parsing and planningregex_expressions: regular expression functions, such as regexp_matchunicode_expressions: include Unicode-aware functions such as character_lengthunparser: enables support to reverse LogicalPlans back into SQLrecursive_protection: uses recursive for stack overflow protection.Optional features:
avro: support for reading the Apache Avro formatbacktrace: include backtrace information in error messagesparquet_encryption: support for using Parquet Modular Encryptionserde: enable arrow-schema's serde featurePublic methods in Apache DataFusion evolve over time: while we try to maintain a stable API, we also improve the API over time. As a result, we typically deprecate methods before removing them, according to the deprecation guidelines.
Cargo.lockFollowing the guidance on committing Cargo.lock files, this project commits its Cargo.lock file.
CI uses the committed Cargo.lock file, and dependencies are updated regularly using Dependabot PRs.