From 1097ba80c8da0b3c2f0456abd5edcaae532bacf3 Mon Sep 17 00:00:00 2001 From: Yiding Cui Date: Wed, 11 Sep 2024 01:26:16 +0800 Subject: [PATCH] session: set EnableWindowFunction for all SessionVars (#55991) (#55992) ref pingcap/tidb#55981 --- sessionctx/variable/session.go | 1 + sessionctx/variable/sysvar_test.go | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/sessionctx/variable/session.go b/sessionctx/variable/session.go index 8cfe1854edef7..c0318adf56a13 100644 --- a/sessionctx/variable/session.go +++ b/sessionctx/variable/session.go @@ -1727,6 +1727,7 @@ func NewSessionVars(hctx HookContext) *SessionVars { EnableReuseCheck: DefTiDBEnableReusechunk, preUseChunkAlloc: DefTiDBUseAlloc, ChunkPool: ReuseChunkPool{Alloc: nil}, + EnableWindowFunction: DefEnableWindowFunction, } vars.KVVars = tikvstore.NewVariables(&vars.Killed) vars.Concurrency = Concurrency{ diff --git a/sessionctx/variable/sysvar_test.go b/sessionctx/variable/sysvar_test.go index f6da8c87495c7..6f3af221dbdc7 100644 --- a/sessionctx/variable/sysvar_test.go +++ b/sessionctx/variable/sysvar_test.go @@ -1092,3 +1092,14 @@ func TestSetJobScheduleWindow(t *testing.T) { require.NoError(t, err) require.Equal(t, "16:11 +0800", val) } + +func TestEnableWindowFunction(t *testing.T) { + vars := NewSessionVars(nil) + require.Equal(t, vars.EnableWindowFunction, DefEnableWindowFunction) + require.NoError(t, vars.SetSystemVar(TiDBEnableWindowFunction, "on")) + require.Equal(t, vars.EnableWindowFunction, true) + require.NoError(t, vars.SetSystemVar(TiDBEnableWindowFunction, "0")) + require.Equal(t, vars.EnableWindowFunction, false) + require.NoError(t, vars.SetSystemVar(TiDBEnableWindowFunction, "1")) + require.Equal(t, vars.EnableWindowFunction, true) +}