From a5483a939d45c473bbde09878bcb32dfb7fac116 Mon Sep 17 00:00:00 2001 From: ULookup Date: Mon, 1 Jun 2026 23:56:55 -0700 Subject: [PATCH] fix(plan): add POW alias to functionIdRegister Fixes #24439 --- pkg/sql/plan/function/func_binary_test.go | 11 +++++++++++ pkg/sql/plan/function/function_id.go | 1 + .../distributed/cases/function/func_math_power.result | 9 +++++++++ test/distributed/cases/function/func_math_power.test | 5 +++++ 4 files changed, 26 insertions(+) diff --git a/pkg/sql/plan/function/func_binary_test.go b/pkg/sql/plan/function/func_binary_test.go index 836292e749605..36c557bae3f39 100644 --- a/pkg/sql/plan/function/func_binary_test.go +++ b/pkg/sql/plan/function/func_binary_test.go @@ -5146,6 +5146,17 @@ func TestPower(t *testing.T) { } } +// TestPowFunctionId validates that "pow" is registered in the functionIdRegister +// and getFunctionIdByName resolves it to the POW function ID (149). +// This ensures the fix for issue #24439 is effective: adding "pow": POW +// to the functionIdRegister map in function_id.go. +func TestPowFunctionId(t *testing.T) { + ctx := context.Background() + fnId, err := getFunctionIdByName(ctx, "pow") + require.NoError(t, err) + require.Equal(t, int32(POW), fnId) +} + // TRUNCATE func initTruncateTestCase() []tcTemp { cases := []struct { diff --git a/pkg/sql/plan/function/function_id.go b/pkg/sql/plan/function/function_id.go index 1f9287ac5a82a..717df1926ad66 100644 --- a/pkg/sql/plan/function/function_id.go +++ b/pkg/sql/plan/function/function_id.go @@ -562,6 +562,7 @@ var functionIdRegister = map[string]int32{ "endswith": ENDSWITH, "findinset": FINDINSET, "find_in_set": FINDINSET, + "pow": POW, "power": POW, "startswith": STARTSWITH, "to_date": STR_TO_DATE, diff --git a/test/distributed/cases/function/func_math_power.result b/test/distributed/cases/function/func_math_power.result index 22c16d6b7e5ee..9d412b66afc4a 100644 --- a/test/distributed/cases/function/func_math_power.result +++ b/test/distributed/cases/function/func_math_power.result @@ -16,6 +16,15 @@ power(10, 100) SELECT power(1,100); power(1, 100) 1.0 +SELECT POW(2, 10); +pow(2, 10) +1024.0 +SELECT pow(2, 10); +pow(2, 10) +1024.0 +SELECT POW(1.5, 3); +pow(1.5, 3) +3.375 select power(2,-1); power(2, -1) 0.5 diff --git a/test/distributed/cases/function/func_math_power.test b/test/distributed/cases/function/func_math_power.test index 99a00540ab261..67d37d5998aac 100644 --- a/test/distributed/cases/function/func_math_power.test +++ b/test/distributed/cases/function/func_math_power.test @@ -8,6 +8,11 @@ SELECT power(2,100); SELECT power(10,100); SELECT power(1,100); +#POW alias (issue 24439) +SELECT POW(2, 10); +SELECT pow(2, 10); +SELECT POW(1.5, 3); + #EXTREME VALUE, 科学计数法 select power(2,-1); select power(-2,1);