MCPcopy
hub / github.com/pingcap/tidb / TestVisitFrameBound

Function TestVisitFrameBound

pkg/parser/parser_test.go:6651–6671  ·  view source on GitHub ↗

For issue #51 See https://github.com/pingcap/parser/pull/51 for details

(t *testing.T)

Source from the content-addressed store, hash-verified

6649// For issue #51
6650// See https://github.com/pingcap/parser/pull/51 for details
6651func TestVisitFrameBound(t *testing.T) {
6652 p := parser.New()
6653 p.EnableWindowFunc(true)
6654 table := []struct {
6655 s string
6656 exprRc int
6657 unit ast.TimeUnitType
6658 }{
6659 {`SELECT AVG(val) OVER (RANGE INTERVAL 1+3 MINUTE_SECOND PRECEDING) FROM t;`, 1, ast.TimeUnitMinuteSecond},
6660 {`SELECT AVG(val) OVER (RANGE 5 PRECEDING) FROM t;`, 1, ast.TimeUnitInvalid},
6661 {`SELECT AVG(val) OVER () FROM t;`, 0, ast.TimeUnitInvalid},
6662 }
6663 for _, tbl := range table {
6664 stmt, err := p.ParseOneStmt(tbl.s, "", "")
6665 require.NoError(t, err)
6666 checker := windowFrameBoundChecker{t: t}
6667 stmt.Accept(&checker)
6668 require.Equal(t, tbl.exprRc, checker.exprRc)
6669 require.Equal(t, tbl.unit, checker.unit)
6670 }
6671}
6672
6673func TestFieldText(t *testing.T) {
6674 p := parser.New()

Callers

nothing calls this directly

Calls 5

NewFunction · 0.92
ParseOneStmtMethod · 0.80
AcceptMethod · 0.65
EqualMethod · 0.65
EnableWindowFuncMethod · 0.45

Tested by

no test coverage detected