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

expression: add builtin function tidb_parse_tso #8385

Merged
merged 20 commits into from
Nov 28, 2018
Merged

Conversation

yu34po
Copy link
Contributor

@yu34po yu34po commented Nov 21, 2018

What problem does this PR solve?

#8384

What is changed and how it works?

add time builtin function tso

Check List

  • Unit test
  • Integration test

Code changes

  • Has exported function/method change
  • Has exported variable/fields change

Side effects

Related changes


This change is Reviewable

@sre-bot
Copy link
Contributor

sre-bot commented Nov 21, 2018

Hi contributor, thanks for your PR.

This patch needs to be approved by someone of admins. They should reply with "/ok-to-test" to accept this PR for running test automatically.

@jackysp
Copy link
Member

jackysp commented Nov 21, 2018

/ok-to-test

@jackysp
Copy link
Member

jackysp commented Nov 21, 2018

Thanks for your contribution, @yu34po !
Please fix CI, seems the failure is about the timezone.

@jackysp jackysp added contribution This PR is from a community contributor. component/expression labels Nov 21, 2018
@jackysp
Copy link
Member

jackysp commented Nov 21, 2018

/run-all-tests

expression/builtin_time.go Outdated Show resolved Hide resolved
// evalTime evals a builtinTsoSig.
func (b *builtinTsoSig) evalTime(row chunk.Row) (types.Time, bool, error) {
arg, isNull, err := b.args[0].EvalInt(b.ctx, row)
if isNull || err != nil || arg <= 0 {
Copy link
Contributor

@dbjoa dbjoa Nov 22, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why should we consider the case of isNull == true as an error ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

function must accept a parameter

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

got it.

@dbjoa
Copy link
Contributor

dbjoa commented Nov 22, 2018

@yu34po The PR includes vender files, which should not be. Would you check whether or not you set the environment variable, GO111MODULE=on?

@dbjoa
Copy link
Contributor

dbjoa commented Nov 22, 2018

@yu34po Would you also add the test for SQL statements having tidb_parse_tso()? expression/integration_test.go can be a candidate place for the test.

@@ -413,6 +413,7 @@ var funcs = map[string]functionClass{
ast.Year: &yearFunctionClass{baseFunctionClass{ast.Year, 1, 1}},
ast.YearWeek: &yearWeekFunctionClass{baseFunctionClass{ast.YearWeek, 1, 2}},
ast.LastDay: &lastDayFunctionClass{baseFunctionClass{ast.LastDay, 1, 1}},
ast.Tso: &tsoFunctionClass{baseFunctionClass{ast.Tso, 1, 1}},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'd better change ast.Tso to ast.TidbParseTso

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ast.Tso already merged in parser master

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can push another PR to change the name

@XuHuaiyu XuHuaiyu changed the title add builtin function from_tso expression: add builtin function tidb_parse_tso Nov 22, 2018
Copy link
Member

@zz-jason zz-jason left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@zz-jason
Copy link
Member

@XuHuaiyu @dbjoa PTAL

@zz-jason zz-jason added the status/LGT1 Indicates that a PR has LGTM 1. label Nov 22, 2018
Copy link
Contributor

@XuHuaiyu XuHuaiyu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we'd better:

  1. change ast.Tso to ast.TiDBParseTso
  2. change tsoXXX to tidbParseTsoXXX

@dbjoa
Copy link
Contributor

dbjoa commented Nov 23, 2018

LGTM

Copy link
Contributor

@XuHuaiyu XuHuaiyu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please address the comment.
Rest LGTM.
Thanks for your contribution.

expression/builtin_time.go Outdated Show resolved Hide resolved
go.mod Outdated
@@ -49,3 +50,5 @@ require (
gopkg.in/natefinch/lumberjack.v2 v2.0.0
sourcegraph.com/sourcegraph/appdash v0.0.0-20180531100431-4c381bd170b4
)

replace github.com/pingcap/parser => github.com/yu34po/parser v0.0.0-20181123030610-1d6c3c585f2d
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please update go.mod to use the latest pingcap/parser.

XuHuaiyu
XuHuaiyu previously approved these changes Nov 26, 2018
Copy link
Member

@zz-jason zz-jason left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please update go.mod

@zz-jason
Copy link
Member

@yu34po pingcap/parser#50 has been merged, you can update go.mod to the latest pingcap/parser now.

go.mod Outdated
@@ -41,6 +41,7 @@ require (
github.com/shirou/gopsutil v2.18.10+incompatible
github.com/sirupsen/logrus v1.2.0
github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72
github.com/tiancaiamao/appdash v0.0.0-20181126055449-889f96f722a2
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why add this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know how this happened.
same as master expect parser version

Copy link
Member

@zz-jason zz-jason Nov 28, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It disappeared after merging the master branch..

Copy link
Member

@zz-jason zz-jason left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@zz-jason zz-jason added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Nov 28, 2018
@zz-jason
Copy link
Member

/run-all-tests

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/expression contribution This PR is from a community contributor. status/LGT2 Indicates that a PR has LGTM 2.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants