Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions pkg/sql/plan/function/func_binary_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions pkg/sql/plan/function/function_id.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
9 changes: 9 additions & 0 deletions test/distributed/cases/function/func_math_power.result
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions test/distributed/cases/function/func_math_power.test
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Loading