You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
power and log simplifications return wrong results for base 1, 0 or negative #25137
Currently, power/log rewrites check the base's nullability but not its value, so degenerate bases fold wrong.
To Reproduce
CREATEVIEWnnASSELECT*FROM (VALUES (1.0), (0.0), (-2.0), (2.0)) s(a);
CREATEVIEWnbASSELECT a FROM (VALUES (1.0),(0.0),(-2.0),(2.0),(NULL)) s(a) WHERE a IS NOT NULL;
CREATEVIEWtASSELECT*FROM (VALUES (2.0), (3.0)) s(b);
SELECT a, log(a, 1.0), log(a, a) FROM nn;
-- 0.0 and 1.0 on all four rows, a = 1.0, 0.0 and -2.0 includedSELECT a, log(a, 1.0), log(a, a) FROM nb;
-- NaN NaN / -0.0 NaN / NaN NaN / 0.0 1.0, so only the schema's nullability differsSELECT b, power(1.0, log(1.0, b)), log(1.0, power(1.0, b)) FROM t;
-- both b; should be 1.0 and NaNSELECTcount(*) FROM t WHERE power(1.0, log(1.0, b)) =2.0;
-- 1, should be 0SELECT power(1.0, log(1.0, 2.0)), log(1.0, 2.0);
-- 1.0 and inf, so the all-literal form is evaluated rather than rewritten
Expected behavior
What the nullable-base rows already print: NaN where the identity does not hold, and 1.0 for power(1.0, log(1.0, b)).
Additional context
The four are power(a, log(a,b)), log(a,1), log(a,a) and log(a, power(a,b)), each gated only on !base_nullable.
Activity
fix: preserve nested log and power results (apache#25138)
fix: preserve nested log and power results (apache#25138)