Skip to content

Commit

Permalink
parser: add new analyze option `SAMPLERATE
Browse files Browse the repository at this point in the history
  • Loading branch information
winoros committed Oct 21, 2021
1 parent 9f8c053 commit 74c01cc
Show file tree
Hide file tree
Showing 6 changed files with 9,165 additions and 9,109 deletions.
6 changes: 4 additions & 2 deletions parser/ast/stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ const (
AnalyzeOptCMSketchDepth
AnalyzeOptCMSketchWidth
AnalyzeOptNumSamples
AnalyzeOptSampleRate
)

// AnalyzeOptionString stores the string form of analyze options.
Expand All @@ -64,6 +65,7 @@ var AnalyzeOptionString = map[AnalyzeOptionType]string{
AnalyzeOptCMSketchWidth: "CMSKETCH WIDTH",
AnalyzeOptCMSketchDepth: "CMSKETCH DEPTH",
AnalyzeOptNumSamples: "SAMPLES",
AnalyzeOptSampleRate: "SAMPLERATE",
}

// HistogramOperationType is the type for histogram operation.
Expand Down Expand Up @@ -91,7 +93,7 @@ func (hot HistogramOperationType) String() string {
// AnalyzeOpt stores the analyze option type and value.
type AnalyzeOpt struct {
Type AnalyzeOptionType
Value uint64
Value ValueExpr
}

// Restore implements Node interface.
Expand Down Expand Up @@ -159,7 +161,7 @@ func (n *AnalyzeTableStmt) Restore(ctx *format.RestoreCtx) error {
if i != 0 {
ctx.WritePlain(",")
}
ctx.WritePlainf(" %d ", opt.Value)
ctx.WritePlainf(" %v ", opt.Value.GetValue())
ctx.WritePlain(AnalyzeOptionString[opt.Type])
}
}
Expand Down
1 change: 1 addition & 0 deletions parser/misc.go
Original file line number Diff line number Diff line change
Expand Up @@ -607,6 +607,7 @@ var tokenMap = map[string]int{
"RUNNING": running,
"S3": s3,
"SAMPLES": samples,
"SAMPLERATE": sampleRate,
"SAN": san,
"SCHEDULE": schedule,
"SCHEMA": database,
Expand Down
Loading

0 comments on commit 74c01cc

Please sign in to comment.