Skip to content

Conversation

cmoog
Copy link
Contributor

@cmoog cmoog commented Aug 6, 2021

Closes #518

This PR implements the STR_TO_DATE MySQL function.

In places where the spec is ambiguous, I'm attempting to match the behavior of MySQL version 8 from my manual testing. I need to implement a few more parsers and add more test cases to cover the expected behavior.

go test  -cover github.com/dolthub/go-mysql-server/sql/parse/dateparse

ok  	github.com/dolthub/go-mysql-server/sql/parse/dateparse	0.163s	coverage: 89.3% of statements

cc @zachmu

@cmoog cmoog marked this pull request as ready for review August 7, 2021 14:21
@cmoog cmoog changed the title [wip] implement built-in function STR_TO_DATE implement built-in function STR_TO_DATE Aug 7, 2021
@cmoog cmoog changed the title implement built-in function STR_TO_DATE implement built-in function str_to_date Aug 9, 2021
Comment on lines +210 to +217
'U': nil,
'u': nil,
'V': nil,
'v': nil,
'W': nil,
'w': nil,
'X': nil,
'x': nil,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

TODO

@cmoog
Copy link
Contributor Author

cmoog commented Aug 12, 2021

@zachmu it doesn't seem I can tag reviewers, but this is ready for a first pass while I finish up the final few format specifiers.

Copy link
Member

@zachmu zachmu left a comment

Choose a reason for hiding this comment

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

Overall this looks really good, thanks for the contribution!

The only things missing:

  1. An engine test (e.g. enginetest/queries.go)
  2. I think the time zone semantics are incorrect. Probably need all results in UTC for this to work reliably for everyone

@zachmu
Copy link
Member

zachmu commented Aug 16, 2021

I missed the timezone setup in the test, I get it now :)

I'm going to go ahead and merge this in, please add an engine test as a followup. You can implement the missing week specifiers, or leave them as TODO for now. Those are pretty obscure for the purpose of date parsing.

@zachmu zachmu merged commit 44c91d8 into dolthub:master Aug 16, 2021
@cmoog cmoog deleted the cmoog/str_to_date branch August 16, 2021 23:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement built-in STR_TO_DATE
2 participants