Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

planner, expression: support multi-distinct agg under MPP mode #39973

Merged
merged 25 commits into from
Feb 20, 2023
Merged
Show file tree
Hide file tree
Changes from 24 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
2 changes: 2 additions & 0 deletions executor/partition_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ func updateExecutorTableID(ctx context.Context, exec *tipb.Executor, recursive b
child = exec.Window.Child
case tipb.ExecType_TypeSort:
child = exec.Sort.Child
case tipb.ExecType_TypeExpand:
child = exec.Expand.Child
default:
return errors.Trace(fmt.Errorf("unknown new tipb protocol %d", exec.Tp))
}
Expand Down
4 changes: 4 additions & 0 deletions expression/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ go_library(
"expression.go",
"extension.go",
"function_traits.go",
"grouping_sets.go",
"helper.go",
"partition_pruner.go",
"scalar_function.go",
Expand All @@ -78,6 +79,7 @@ go_library(
"//parser/opcode",
"//parser/terror",
"//parser/types",
"//planner/funcdep",
"//privilege",
"//sessionctx",
"//sessionctx/stmtctx",
Expand Down Expand Up @@ -171,6 +173,7 @@ go_test(
"expr_to_pb_test.go",
"expression_test.go",
"function_traits_test.go",
"grouping_sets_test.go",
"helper_test.go",
"main_test.go",
"multi_valued_index_test.go",
Expand Down Expand Up @@ -227,6 +230,7 @@ go_test(
"@com_github_stretchr_testify//require",
"@com_github_tikv_client_go_v2//oracle",
"@com_github_tikv_client_go_v2//tikv",
"@io_opencensus_go//stats/view",
"@org_uber_go_goleak//:goleak",
],
)
2 changes: 2 additions & 0 deletions expression/aggregation/descriptor.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ type AggFuncDesc struct {
HasDistinct bool
// OrderByItems represents the order by clause used in GROUP_CONCAT
OrderByItems []*util.ByItems
// GroupingID is used for distinguishing with not-set 0, starting from 1.
GroupingID int
}

// NewAggFuncDesc creates an aggregation function signature descriptor.
Expand Down
12 changes: 12 additions & 0 deletions expression/constant.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,18 @@ func NewZero() *Constant {
}
}

// NewUInt64Const stands for constant of a given number.
func NewUInt64Const(num int) *Constant {
retT := types.NewFieldType(mysql.TypeLonglong)
retT.AddFlag(mysql.UnsignedFlag) // shrink range to avoid integral promotion
retT.SetFlen(mysql.MaxIntWidth)
retT.SetDecimal(0)
return &Constant{
Value: types.NewDatum(num),
RetType: retT,
}
}

// NewNull stands for null constant.
func NewNull() *Constant {
retT := types.NewFieldType(mysql.TypeTiny)
Expand Down
Loading