-
-
Notifications
You must be signed in to change notification settings - Fork 218
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
implementing quarter()
function
#2258
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code looks alright, but a couple of test cases look wrong to me. Once those match MySQL's results, this looks good to go though.
sql/expression/function/time_test.go
Outdated
{ | ||
name: "1", | ||
row: sql.NewRow(1), | ||
expected: int32(1), | ||
}, | ||
{ | ||
name: "1.1", | ||
row: sql.NewRow(1.1), | ||
expected: int32(1), | ||
}, | ||
{ | ||
name: "invalid type", | ||
row: sql.NewRow([]byte{0, 1, 2}), | ||
expected: int32(1), | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like all of these should return NULL
, right?
Here's the MySQL behavior:
mysql> select quarter("1"), quarter("1.1");
+--------------+----------------+
| quarter("1") | quarter("1.1") |
+--------------+----------------+
| NULL | NULL |
+--------------+----------------+
sql/expression/function/time_test.go
Outdated
name: "date as time", | ||
row: sql.NewRow(time.Now()), | ||
expected: int32(time.Now().UTC().Month()), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like this test will only pass in the month of January? 🤔
This PR adds support for the
QUARTER()
function, which tells the quarter from the provided date.MySQL Docs: https://dev.mysql.com/doc/refman/8.0/en/date-and-time-functions.html#function_quarter