Skip to content

feat: decimal support for gcd and lcm#22655

Open
theirix wants to merge 10 commits into
apache:mainfrom
theirix:gcd-lcm-decimal
Open

feat: decimal support for gcd and lcm#22655
theirix wants to merge 10 commits into
apache:mainfrom
theirix:gcd-lcm-decimal

Conversation

@theirix

@theirix theirix commented May 30, 2026

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

Rationale for this change

A binary gcd and lcm UDF in the datafusion-functions crate supports only Int64, but not Decimals. Adding missing support for decimals.

What changes are included in this PR?

  1. Updated gcd and lcm functions to add decimal support. The integer path is more performant and stays intact. For decimals, the Euclidean algorithm is used for GCD
  2. Added coercion rules: casting to decimals if any argument is decimal; otherwise, stay with ints as before
  3. Common functionality extracted to common.rs to avoid inter-UDF dependency
  4. In order to use calculate_binary_math for Decimals, updated it to accept a target type instead of raw Decimal128Type::DATA_TYPE - it causes scaling issues for these UDFs, see Improve scale support for binary decimal operations #19621

A bit more on (4). The driving force is this failing example:

query R
select gcd(2::decimal(38, 0), 3::decimal(38, 0));
----
1

Previously in #19874, I suggested a more complicated solution to extend calculate_binary_math. However, it only affected gcd/lcm and could be considered overkill. This PR extends these functions with an extra parameter cast_target for calculate_binary_decimal_math to perform a proper cast to the actual type used, rather than to the default Decimal128Type::DATA_TYPE - it is much lighter.

Are these changes tested?

  • Added unit test for UDFs with decimals for array and scalar paths
  • Added unit tests for the gcd/lcm math itself
  • Added new SLT tests for decimals

Are there any user-facing changes?

No

@github-actions github-actions Bot added sqllogictest SQL Logic Tests (.slt) functions Changes to functions implementation labels May 30, 2026
@github-actions

github-actions Bot commented May 30, 2026

Copy link
Copy Markdown

Thank you for opening this pull request!

Reviewer note: cargo-semver-checks reported the current version number is not SemVer-compatible with the changes in this pull request (compared against the base branch).

Details
     Cloning apache/main
    Building datafusion-functions v54.0.0 (current)
       Built [  35.668s] (current)
     Parsing datafusion-functions v54.0.0 (current)
      Parsed [   0.084s] (current)
    Building datafusion-functions v54.0.0 (baseline)
       Built [  29.677s] (baseline)
     Parsing datafusion-functions v54.0.0 (baseline)
      Parsed [   0.078s] (baseline)
    Checking datafusion-functions v54.0.0 -> v54.0.0 (no change; assume patch)
     Checked [   0.381s] 223 checks: 222 pass, 1 fail, 0 warn, 30 skip

--- failure function_missing: pub fn removed or renamed ---

Description:
A publicly-visible function cannot be imported by its prior path. A `pub use` may have been removed, or the function itself may have been renamed or removed entirely.
        ref: https://doc.rust-lang.org/cargo/reference/semver.html#item-remove
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.48.0/src/lints/function_missing.ron

Failed in:
  function datafusion_functions::math::gcd::compute_gcd, previously in file /home/runner/work/datafusion/datafusion/target/semver-checks/git-apache_main/2274274c18c3d085dff48f5bcbf1e70b553d9260/datafusion/functions/src/math/gcd.rs:175

     Summary semver requires new major version: 1 major and 0 minor checks failed
    Finished [  67.266s] datafusion-functions
    Building datafusion-sqllogictest v54.0.0 (current)
error: running cargo-doc on crate 'datafusion-sqllogictest' failed with output:
-----
   Compiling proc-macro2 v1.0.106
   Compiling unicode-ident v1.0.24
   Compiling quote v1.0.45
   Compiling libc v0.2.186
    Checking cfg-if v1.0.4
    Checking bytes v1.11.1
    Checking memchr v2.8.2
   Compiling serde_core v1.0.228
   Compiling syn v2.0.117
   Compiling autocfg v1.5.1
   Compiling jobserver v0.1.34
   Compiling shlex v2.0.1
   Compiling find-msvc-tools v0.1.9
   Compiling cc v1.2.63
    Checking itoa v1.0.18
    Checking allocator-api2 v0.2.21
    Checking equivalent v1.0.2
    Checking once_cell v1.21.4
    Checking foldhash v0.2.0
   Compiling libm v0.2.16
   Compiling num-traits v0.2.19
    Checking hashbrown v0.17.1
    Checking pin-project-lite v0.2.17
   Compiling zmij v1.0.21
    Checking futures-core v0.3.32
    Checking indexmap v2.14.0
   Compiling zerocopy v0.8.52
    Checking futures-sink v0.3.32
    Checking errno v0.3.14
    Checking socket2 v0.6.4
    Checking signal-hook-registry v1.4.8
    Checking mio v1.2.1
   Compiling version_check v0.9.5
   Compiling getrandom v0.3.4
   Compiling serde v1.0.228
    Checking num-integer v0.1.46
    Checking slab v0.4.12
   Compiling serde_json v1.0.150
    Checking futures-channel v0.3.32
    Checking smallvec v1.15.2
    Checking num-bigint v0.4.6
   Compiling synstructure v0.13.2
    Checking http v1.4.2
    Checking futures-io v0.3.32
    Checking base64 v0.22.1
    Checking futures-task v0.3.32
    Checking iana-time-zone v0.1.65
    Checking chrono v0.4.45
    Checking tracing-core v0.1.36
   Compiling zerocopy-derive v0.8.52
   Compiling tokio-macros v2.7.0
   Compiling serde_derive v1.0.228
    Checking tokio v1.52.3
   Compiling futures-macro v0.3.32
    Checking futures-util v0.3.32
   Compiling zerofrom-derive v0.1.7
   Compiling tracing-attributes v0.1.31
    Checking siphasher v1.0.3
    Checking zerofrom v0.1.8
   Compiling yoke-derive v0.8.2
    Checking stable_deref_trait v1.2.1
    Checking num-complex v0.4.6
   Compiling zerovec-derive v0.11.3
    Checking tracing v0.1.44
    Checking getrandom v0.2.17
   Compiling pkg-config v0.3.33
    Checking phf_shared v0.12.1
    Checking half v2.7.1
   Compiling displaydoc v0.2.6
   Compiling ahash v0.8.12
   Compiling thiserror v2.0.18
    Checking yoke v0.8.3
   Compiling chrono-tz v0.10.4
    Checking zerovec v0.11.6
    Checking percent-encoding v2.3.2
    Checking arrow-buffer v59.0.0
    Checking phf v0.12.1
    Checking ppv-lite86 v0.2.21
   Compiling thiserror-impl v2.0.18
    Checking arrow-schema v59.0.0
   Compiling ring v0.17.14
    Checking arrow-data v59.0.0
   Compiling semver v1.0.28
    Checking log v0.4.32
   Compiling getrandom v0.4.2
    Checking rand_core v0.10.1
    Checking tinystr v0.8.3
    Checking untrusted v0.9.0
    Checking bitflags v2.13.0
    Checking litemap v0.8.2
    Checking writeable v0.6.3
    Checking icu_locale_core v2.2.0
    Checking potential_utf v0.1.5
    Checking zerotrie v0.2.4
   Compiling zstd-sys v2.0.16+zstd.1.5.7
   Compiling async-trait v0.1.89
    Checking rand_core v0.9.5
   Compiling icu_properties_data v2.2.0
    Checking utf8_iter v1.0.4
   Compiling icu_normalizer_data v2.2.0
    Checking icu_collections v2.2.0
    Checking rand_chacha v0.9.0
    Checking icu_provider v2.2.0
    Checking rand v0.9.4
    Checking aho-corasick v1.1.4
   Compiling zstd-safe v7.2.4
    Checking ryu v1.0.23
    Checking lexical-util v1.0.7
   Compiling object v0.37.3
    Checking regex-syntax v0.8.11
    Checking arrow-array v59.0.0
    Checking regex-automata v0.4.14
    Checking arrow-select v59.0.0
    Checking icu_normalizer v2.2.0
    Checking icu_properties v2.2.0
   Compiling rustix v1.1.4
    Checking regex v1.12.4
    Checking form_urlencoded v1.2.2
    Checking unicode-width v0.2.2
   Compiling crc32fast v1.5.0
    Checking either v1.16.0
    Checking idna_adapter v1.2.2
   Compiling parking_lot_core v0.9.12
    Checking typenum v1.20.1
    Checking idna v1.1.0
    Checking lexical-parse-integer v1.0.6
    Checking lexical-write-integer v1.0.6
   Compiling rustc_version v0.4.1
    Checking futures-executor v0.3.32
   Compiling pin-project-internal v1.1.13
    Checking adler2 v2.0.1
    Checking simd-adler32 v0.3.9
    Checking scopeguard v1.2.0
    Checking lock_api v0.4.14
    Checking miniz_oxide v0.8.9
    Checking futures v0.3.32
   Compiling flatbuffers v25.12.19
    Checking lexical-write-float v1.0.6
    Checking pin-project v1.1.13
    Checking lexical-parse-float v1.0.6
    Checking url v2.5.8
    Checking zlib-rs v0.6.3
    Checking unicode-segmentation v1.13.3
   Compiling ar_archive_writer v0.5.2
    Checking comfy-table v7.2.2
    Checking lexical-core v1.0.6
    Checking itertools v0.14.0
    Checking flate2 v1.1.9
   Compiling psm v0.1.31
    Checking arrow-ord v59.0.0
    Checking twox-hash v2.1.2
    Checking atoi v2.0.0
   Compiling stacker v0.1.24
   Compiling snap v1.1.1
    Checking hex v0.4.3
    Checking alloc-no-stdlib v2.0.4
    Checking alloc-stdlib v0.2.2
    Checking lz4_flex v0.13.1
    Checking arrow-cast v59.0.0
    Checking parking_lot v0.12.5
    Checking csv-core v0.1.13
    Checking same-file v1.0.6
    Checking simdutf8 v0.1.5
    Checking humantime v2.3.0
   Compiling paste v1.0.15
    Checking csv v1.4.0
    Checking walkdir v2.5.0
    Checking brotli-decompressor v5.0.1
   Compiling recursive-proc-macro-impl v0.1.1
    Checking subtle v2.6.1
    Checking arrow-json v59.0.0
    Checking recursive v0.1.1
    Checking arrow-csv v59.0.0
    Checking brotli v8.0.3
    Checking object_store v0.13.2
    Checking arrow-string v59.0.0
    Checking arrow-arith v59.0.0
    Checking arrow-row v59.0.0
    Checking uuid v1.23.3
    Checking zstd v0.13.3
    Checking tokio-util v0.7.18
    Checking arrow-ipc v59.0.0
   Compiling sqlparser_derive v0.5.0
   Compiling seq-macro v0.3.6
    Checking cpufeatures v0.3.0
    Checking hybrid-array v0.4.12
    Checking sqlparser v0.62.0
    Checking cmov v0.5.4
    Checking linux-raw-sys v0.12.1
    Checking block-buffer v0.12.1
    Checking crypto-common v0.2.2
    Checking parquet v59.0.0
    Checking arrow v59.0.0
    Checking ctutils v0.4.2
   Compiling generic-array v0.14.7
    Checking const-oid v0.10.2
    Checking digest v0.11.3
    Checking datafusion-doc v54.0.0 (/home/runner/work/datafusion/datafusion/datafusion/doc)
   Compiling crossbeam-utils v0.8.21
    Checking foldhash v0.1.5
    Checking hashbrown v0.15.5
    Checking block-buffer v0.10.4
    Checking crypto-common v0.1.7
    Checking fixedbitset v0.5.7
   Compiling heck v0.5.0
    Checking fastrand v2.4.1
    Checking petgraph v0.8.3
    Checking tempfile v3.27.0
    Checking digest v0.10.7
    Checking md-5 v0.11.0
    Checking sha2 v0.11.0
    Checking hashbrown v0.14.5
    Checking dashmap v6.2.1
   Compiling blake3 v1.8.5
   Compiling datafusion-macros v54.0.0 (/home/runner/work/datafusion/datafusion/datafusion/macros)
   Compiling anyhow v1.0.102
    Checking arrayref v0.3.9
    Checking constant_time_eq v0.4.2
    Checking arrayvec v0.7.6
    Checking blake2 v0.10.6
   Compiling liblzma-sys v0.4.6
    Checking libbz2-rs-sys v0.2.5
    Checking bzip2 v0.6.1
    Checking datafusion-common-runtime v54.0.0 (/home/runner/work/datafusion/datafusion/datafusion/common-runtime)
   Compiling httparse v1.10.1
   Compiling prost-derive v0.14.4
    Checking compression-core v0.4.32
    Checking http-body v1.0.1
    Checking glob v0.3.3
    Checking tower-service v0.3.3
    Checking atomic-waker v1.1.2
    Checking fnv v1.0.7
    Checking try-lock v0.2.5
    Checking want v0.3.1
    Checking h2 v0.4.14
    Checking tokio-stream v0.1.18
    Checking httpdate v1.0.3
    Checking zeroize v1.8.2
    Checking rustls-pki-types v1.14.1
    Checking hyper v1.10.1
    Checking datafusion-common v54.0.0 (/home/runner/work/datafusion/datafusion/datafusion/common)
   Compiling prost v0.14.4
    Checking hyper-util v0.1.20
    Checking http-body-util v0.1.3
    Checking sync_wrapper v1.0.2
   Compiling prettyplease v0.2.37
   Compiling rustls v0.23.40
    Checking tower-layer v0.3.3
   Compiling prost-types v0.14.4
    Checking liblzma v0.4.6
    Checking compression-codecs v0.4.38
    Checking async-compression v0.4.42
    Checking rustls-webpki v0.103.13
    Checking datafusion-expr-common v54.0.0 (/home/runner/work/datafusion/datafusion/datafusion/expr-common)
   Compiling serde_derive_internals v0.29.1
   Compiling schemars v0.8.22
    Checking mime v0.3.17
    Checking axum-core v0.5.6
    Checking datafusion-physical-expr-common v54.0.0 (/home/runner/work/datafusion/datafusion/datafusion/physical-expr-common)
   Compiling schemars_derive v0.8.22
   Compiling hashbrown v0.16.1
    Checking datafusion-functions-window-common v54.0.0 (/home/runner/work/datafusion/datafusion/datafusion/functions-window-common)
    Checking datafusion-functions-aggregate-common v54.0.0 (/home/runner/work/datafusion/datafusion/datafusion/functions-aggregate-common)
    Checking datafusion-expr v54.0.0 (/home/runner/work/datafusion/datafusion/datafusion/expr)
    Checking tower v0.5.3
    Checking matchit v0.8.4
   Compiling dyn-clone v1.0.20
   Compiling multimap v0.10.1
   Compiling prost-build v0.14.4
    Checking axum v0.8.9
   Compiling regress v0.10.5
   Compiling pbjson-build v0.8.0
    Checking datafusion-physical-expr v54.0.0 (/home/runner/work/datafusion/datafusion/datafusion/physical-expr)
    Checking datafusion-execution v54.0.0 (/home/runner/work/datafusion/datafusion/datafusion/execution)
    Checking hyper-timeout v0.5.2
    Checking datafusion-functions v54.0.0 (/home/runner/work/datafusion/datafusion/datafusion/functions)
    Checking chacha20 v0.10.0
   Compiling portable-atomic v1.13.1
   Compiling strsim v0.11.1
   Compiling ident_case v1.0.1
   Compiling darling_core v0.23.0
   Compiling typify-impl v0.5.0
    Checking rand v0.10.1
    Checking tonic v0.14.6
   Compiling serde_tokenstream v0.2.3
    Checking ureq-proto v0.6.0
   Compiling bigdecimal v0.4.10
    Checking utf8-zero v0.8.1
   Compiling bollard-buildkit-proto v0.7.0
    Checking tinyvec_macros v0.1.1
    Checking crc-catalog v2.5.0
    Checking utf8parse v0.2.2
    Checking anstyle-parse v1.0.0
    Checking datafusion-physical-plan v54.0.0 (/home/runner/work/datafusion/datafusion/datafusion/physical-plan)
    Checking datafusion-physical-expr-adapter v54.0.0 (/home/runner/work/datafusion/datafusion/datafusion/physical-expr-adapter)
   Compiling darling_macro v0.23.0
    Checking crc v3.4.0
    Checking tinyvec v1.11.0
    Checking ureq v3.3.0
    Checking tonic-prost v0.14.6
    Checking datafusion-functions-aggregate v54.0.0 (/home/runner/work/datafusion/datafusion/datafusion/functions-aggregate)
   Compiling strum_macros v0.28.0
   Compiling typify-macro v0.5.0
   Compiling structmeta-derive v0.3.0
    Checking deranged v0.5.8
    Checking powerfmt v0.2.0
    Checking anstyle v1.0.14
    Checking num-conv v0.2.2
    Checking time-core v0.1.9
   Compiling unsafe-libyaml v0.2.11
    Checking is_terminal_polyfill v1.70.2
    Checking anstyle-query v1.1.5
    Checking colorchoice v1.0.5
    Checking time v0.3.48
    Checking anstream v1.0.0
   Compiling serde_yaml v0.9.34+deprecated
   Compiling structmeta v0.3.0
    Checking arrow-avro v59.0.0
   Compiling typify v0.5.0
    Checking datafusion-functions-nested v54.0.0 (/home/runner/work/datafusion/datafusion/datafusion/functions-nested)
    Checking datafusion-session v54.0.0 (/home/runner/work/datafusion/datafusion/datafusion/session)
    Checking datafusion-datasource v54.0.0 (/home/runner/work/datafusion/datafusion/datafusion/datasource)
    Checking unicode-normalization v0.1.25
   Compiling darling v0.23.0
   Compiling pbjson-types v0.8.0
    Checking tokio-rustls v0.26.4
   Compiling async-stream-impl v0.3.6
   Compiling serde_repr v0.1.20
    Checking datafusion-pruning v54.0.0 (/home/runner/work/datafusion/datafusion/datafusion/pruning)
    Checking datafusion-catalog v54.0.0 (/home/runner/work/datafusion/datafusion/datafusion/catalog)
    Checking num-rational v0.4.2
    Checking num-iter v0.1.45
    Checking openssl-probe v0.2.1
    Checking unicode-bidi v0.3.18
    Checking unicode-properties v0.1.4
    Checking clap_lex v1.1.0
    Checking clap_builder v4.6.0
    Checking num v0.4.3
    Checking stringprep v0.1.5
    Checking rustls-native-certs v0.8.4
    Checking datafusion-datasource-parquet v54.0.0 (/home/runner/work/datafusion/datafusion/datafusion/datasource-parquet)
    Checking datafusion-physical-optimizer v54.0.0 (/home/runner/work/datafusion/datafusion/datafusion/physical-optimizer)
    Checking bollard-stubs v1.52.1-rc.29.1.3
    Checking async-stream v0.3.6
    Checking datafusion-datasource-json v54.0.0 (/home/runner/work/datafusion/datafusion/datafusion/datasource-json)
    Checking datafusion-datasource-arrow v54.0.0 (/home/runner/work/datafusion/datafusion/datafusion/datasource-arrow)
    Checking datafusion-datasource-avro v54.0.0 (/home/runner/work/datafusion/datafusion/datafusion/datasource-avro)
    Checking datafusion-datasource-csv v54.0.0 (/home/runner/work/datafusion/datafusion/datafusion/datasource-csv)
    Checking datafusion-sql v54.0.0 (/home/runner/work/datafusion/datafusion/datafusion/sql)
    Checking hyper-rustls v0.27.9
   Compiling serde_with_macros v3.21.0
   Compiling substrait v0.63.0
   Compiling parse-display-derive v0.9.1
    Checking datafusion-optimizer v54.0.0 (/home/runner/work/datafusion/datafusion/datafusion/optimizer)
    Checking datafusion-functions-window v54.0.0 (/home/runner/work/datafusion/datafusion/datafusion/functions-window)
    Checking hyperlocal v0.9.1
   Compiling clap_derive v4.6.1
    Checking xattr v1.6.1
    Checking hmac v0.13.0
    Checking serde_urlencoded v0.7.1
    Checking pbjson v0.8.0
    Checking rand_core v0.6.4
   Compiling enum-ordinalize-derive v4.3.2
   Compiling fs-err v3.3.0
    Checking filetime v0.2.29
   Compiling owo-colors v4.3.0
    Checking home v0.5.12
    Checking fallible-iterator v0.2.0
    Checking byteorder v1.5.0
    Checking rustc-hash v2.1.2
    Checking astral-tokio-tar v0.6.2
    Checking postgres-protocol v0.6.11
    Checking clap v4.6.1
   Compiling enum-ordinalize v4.3.2
    Checking rand_chacha v0.3.1
    Checking bollard v0.20.2
    Checking parse-display v0.9.1
error[E0119]: conflicting implementations of trait `From<format_description::parse::format_item::HourBase>` for type `<format_description::parse::format_item::HourBase as format_description::parse::format_item::ModifierValue>::Type`
   --> /home/runner/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/bollard-0.20.2/src/docker.rs:209:1
    |
209 | impl<T: Into<String>> From<T> for MaybeClientVersion {
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: conflicting implementation in crate `time`:
            - impl From<format_description::parse::format_item::HourBase> for <format_description::parse::format_item::HourBase as format_description::parse::format_item::ModifierValue>::Type;
    = note: upstream crates may add a new impl of trait `std::convert::Into<std::string::String>` for type `time::format_description::parse::format_item::HourBase` in future versions

    Checking serde_with v3.21.0
    Checking ferroid v2.0.0
   Compiling postgres-derive v0.4.8
For more information about this error, try `rustc --explain E0119`.
error: could not compile `bollard` (lib) due to 1 previous error
warning: build failed, waiting for other jobs to finish...

-----

error: failed to build rustdoc for crate datafusion-sqllogictest v54.0.0
note: this is usually due to a compilation error in the crate,
      and is unlikely to be a bug in cargo-semver-checks
note: the following command can be used to reproduce the error:
      cargo new --lib example &&
          cd example &&
          echo '[workspace]' >> Cargo.toml &&
          cargo add --path /home/runner/work/datafusion/datafusion/datafusion/sqllogictest --features avro,backtrace,bytes,chrono,datafusion-substrait,parquet_encryption,postgres,postgres-types,substrait,testcontainers-modules,tokio-postgres &&
          cargo check &&
          cargo doc

error: aborting due to failure to build rustdoc for crate datafusion-sqllogictest v54.0.0

@github-actions github-actions Bot added the auto detected api change Auto detected API change label May 30, 2026
@theirix theirix marked this pull request as ready for review May 30, 2026 20:55
@theirix

theirix commented May 31, 2026

Copy link
Copy Markdown
Contributor Author

@neilconway , @Jefffrey I'd appreciate hearing your thoughts on this PR

query error DataFusion error: Arrow error: Compute error: Signed integer overflow in GCD\(0, \-9223372036854775808\)
select gcd(0, -9223372036854775808);

# gcd decimal

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could we add test cases for:

  • negative number inputs
  • decimals with different scale/precision inputs
  • decimal point 1.23 inputs

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Comment thread datafusion/functions/src/utils.rs Outdated
}

/// Computes a binary math function for input arrays using a specified function.
/// Deprecated, use [`calculate_binary_math_cast`] instead.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

im not sure if we should deprecate this as the calculate_binary_math_cast alternative introduces a new argument that is only really relevant for decimals 🤔

Comment thread datafusion/functions/src/utils.rs Outdated

/// Computes a binary math function for input arrays using a specified function
/// and applies rescaling to given precision and scale.
/// Deprecated, use [`calculate_binary_decimal_math_cast`] instead.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of just stating its deprecated might be better to explicitly mark it as so #[deprecated]

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the original function calculate_binary_math_cast is public, we cannot track its usage outside, and removal is only possible with deprecation. It shouldn't have been declared as public in the first place - so the new function, too.

What I can see as a plan:

  • Deprecate it explicitly with the macro, as you suggest
  • Port some usages in the datafusion repo in the next PR
  • Mark the new function as pub(crate) as it is intended to be used locally only

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A second thought - marking it as deprecated fails a clippy check. Rolled back to an informational comment until the PR removes its usage in (2)

Comment thread datafusion/functions/src/utils.rs Outdated
/// - `right`: Right input array or scalar value
/// - `fun`: Function of type `F`
/// - `cast_target`: Data type to cast right operand to before applying function
pub fn calculate_binary_math_cast<L, R, O, F>(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this just be a private function that the others use internally? otherwise its a bit confusing to have this as public when only decimals can really take advantage of cast_target

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's true, made it private

Comment thread datafusion/functions/src/math/gcd.rs Outdated
Comment thread datafusion/functions/src/math/gcd.rs
Comment thread datafusion/functions/src/math/gcd.rs Outdated
Comment thread datafusion/functions/src/math/lcm.rs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

auto detected api change Auto detected API change functions Changes to functions implementation sqllogictest SQL Logic Tests (.slt)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: Decimal support for gcd and lcm

2 participants