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) +}