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

*: remove fsp out of Datum and Duration(experimental) #7013

Closed
wants to merge 7 commits into from
Closed

*: remove fsp out of Datum and Duration(experimental) #7013

wants to merge 7 commits into from

Conversation

lysu
Copy link
Contributor

@lysu lysu commented Jul 8, 2018

What have you changed? (mandatory)

The purpose of this PR is remove fsp from Time(types.Duration).

What's Fsp?

For MySQL, Time/Timestamp/Datetime has an fsp argument is given to specify a fractional seconds precision from 0 to 6, the return value includes a fractional seconds part of that many digits.
https://dev.mysql.com/doc/refman/5.7/en/date-and-time-functions.html

what's the problem now we have?

In current version(2.1 beta), types.Duration(stand for MySQL Time) has combinate time.Duration with fsp(int) in types.Duration

but after reading previous MySQL document, we can abstract fsp is just :

  • an Column definition
  • an Expression part(in builtin)
  • and it's real effection is control the digit nums of return value for Result column

So...fsp seems not property of Data type(like Time), but property of

  • Column definition
  • Expression property
  • Derived Result column type(this is done by Huaiyu last year)

but NOT a property of data , it will be only be calculate & allocate one time for a query in type infer stage, no need calcuate it in every row.

How?

to solve this, we should

  • remove fsp, and make types.Duration be just a alias of time.Duration(long), make arrow use 8bytes instead of 16bytes
  • modify types.Duration output method and rely a input parameter to determine (fsp) during output stage
    pass ResultType.Column.decimal as new added parameter value
  • modify all time related function and testcase to make type decimals infer work well.

What are the type of the changes (mandatory)?

At, first we remove fsp in types.Duration, and modify ToString to let fsp can be pass in different context.

Then modify time related funcation and testcase to meet type decimal infer.

How has this PR been tested (mandatory)?

  • unit tests
  • integration tests

This change is Reviewable


func timePrecision(ctx sessionctx.Context, expression Expression) (int, error) {
constExp, isConstant := expression.(*Constant)
if isConstant && (types.IsNonBinaryStr(expression.GetType()) || types.IsBinaryStr(expression.GetType())) && !isTemporalColumn(expression) {
Copy link
Member

Choose a reason for hiding this comment

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

Please add comments for this.

@lysu lysu changed the title expression: fix time function's type decimals infer expression: reduce fsp of duration Jul 10, 2018
@lysu
Copy link
Contributor Author

lysu commented Jul 12, 2018

/run-all-tests

@lysu lysu added the proposal label Jul 12, 2018
@lysu lysu changed the title expression: reduce fsp of duration *: remove fsp out of Datum and Duration(experimental) Jul 12, 2018
@lysu lysu closed this Jul 17, 2018
@lysu lysu deleted the dev/fix-time-func-decimal branch September 27, 2018 04:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants