jdymitarai opened a new pull request, #26211: URL: https://github.com/apache/datafusion/pull/26211
Closes #26193. When SingleDistinctToGroupBy rewrites an aggregate containing both DISTINCT and non-distinct expressions such as sum over Decimal128, the non-distinct expression is split into inner and outer phases. The outer phase evaluates sum over the already-widened Decimal output of the inner aggregation, which widens precision a second time and causes the resulting schema to diverge from the original aggregate schema. To maintain schema consistency, the outer projection now checks if the data type produced by outer_aggr differs from the field type declared in the original schema, wrapping the projected expression with a cast back to the declared field type when a mismatch occurs. All optimizer unit tests including a dedicated regression test reproducing the two-phase decimal precision expansion pass cleanly. -- 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]
