Skip to content

Commit

Permalink
planner, expression: support multi-distinct agg under MPP mode (#39973)
Browse files Browse the repository at this point in the history
  • Loading branch information
AilinKid authored Feb 20, 2023
1 parent c987515 commit 4ccce9c
Show file tree
Hide file tree
Showing 26 changed files with 1,787 additions and 97 deletions.
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

0 comments on commit 4ccce9c

Please sign in to comment.