Skip to content

core: SubstraitBuilder arithmetic aggregates hard-code the functions_arithmetic URN, so decimal and datetime inputs throw #1379

Description

@nielspardon

SubstraitBuilder's single-argument aggregate helpers (sum, sum0, min, max, avg) always look the function up under the functions_arithmetic URN, so they throw for any input type whose variant is declared in another standard extension — decimals live in functions_arithmetic_decimal, dates/times/timestamps/intervals in functions_datetime.

NamedScan dec = sb.namedScan(List.of("t"), List.of("d"), List.of(R.decimal(10, 2)));
sb.sum(dec, 0);
// IllegalArgumentException: Unexpected aggregate function with key sum:dec. The URN extension:io.substrait:functions_arithmetic is loaded but no aggregate function with this key was found.

NamedScan date = sb.namedScan(List.of("t"), List.of("d"), List.of(R.DATE));
sb.min(date, 0);
// IllegalArgumentException: ... key min:date ...

Measured on main at ca8315b.

The spec declares sum:dec (returning DECIMAL?<38,S>) and min:date etc., so these are valid plans the builder cannot produce. The helper should pick the URN that declares the variant for the argument type (or search the loaded catalog by name + signature) rather than hard-coding one. The sibling helpers that hard-code their output type instead of deriving it from the declaration — statisticalAggregate (std_dev, variance) and count/countStar — are worth moving onto the same resolveType path while there; with the default catalog that is a no-op today, but it makes them honor a custom catalog the way sum/min/… now do after #1262.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions