Skip to content

Commit

Permalink
adjust
Browse files Browse the repository at this point in the history
  • Loading branch information
SunRunAway committed Sep 23, 2019
1 parent 73ec099 commit 71233d5
Showing 1 changed file with 21 additions and 16 deletions.
37 changes: 21 additions & 16 deletions expression/generator/time_vec.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
. "github.com/pingcap/tidb/expression/generator/helper"
)

const header = `// Copyright 2019 PingCAP, Inc.
var addTime = template.Must(template.New("").Parse(`// Copyright 2019 PingCAP, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -43,21 +43,14 @@ const header = `// Copyright 2019 PingCAP, Inc.
// Code generated by go generate in expression/generator; DO NOT EDIT.
package expression
`
const imports = `import (
import (
"github.com/pingcap/parser/mysql"
"github.com/pingcap/parser/terror"
"github.com/pingcap/tidb/types"
"github.com/pingcap/tidb/util/chunk"
)`

// TODO:
// builtinAddTimeDateTimeNullSig.evalTime
// builtinAddTimeStringNullSig.evalString
// builtinAddTimeDurationNullSig.evalDuration
// builtinAddTimeStringNullSig.evalString
var addTime = template.Must(template.New("").Parse(`
)
{{ define "SetNull" }}{{if .Output.Fixed}}result.SetNull(i, true){{else}}result.AppendNull(){{end}} // fixed: {{.Output.Fixed }}{{ end }}
{{ define "ConvertStringToDuration" }}
if !isDuration(arg1) {
Expand Down Expand Up @@ -252,7 +245,23 @@ func (b *{{.SigName}}) vectorized() bool {
{{ end }}{{/* range */}}
`))

var testFile = template.Must(template.New("").Parse(`
var testFile = template.Must(template.New("").Parse(`// Copyright 2019 PingCAP, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// See the License for the specific language governing permissions and
// limitations under the License.
// Code generated by go generate in expression/generator; DO NOT EDIT.
package expression
import (
"testing"
Expand Down Expand Up @@ -358,9 +367,6 @@ var tmplVal = struct {

func generateDotGo(fileName string) error {
w := new(bytes.Buffer)
w.WriteString(header)
w.WriteString("\n")
w.WriteString(imports)
err := addTime.Execute(w, addTimeSigsTmpl)
if err != nil {
return err
Expand All @@ -375,7 +381,6 @@ func generateDotGo(fileName string) error {

func generateTestDotGo(fileName string) error {
w := new(bytes.Buffer)
w.WriteString(header)
err := testFile.Execute(w, tmplVal)
if err != nil {
return err
Expand Down

0 comments on commit 71233d5

Please sign in to comment.