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

Update formatPatternMap to correctly interpret %u #126

Closed
wants to merge 1 commit into from

Conversation

philschoefer
Copy link

@philschoefer philschoefer commented Oct 31, 2023

Solves #125

Summary of problem:

When using something like FORMAT_TIMESTAMP('%u', sale_happened_at) it currently returns the week number of the current year (e.g. 43).

According to the BigQuery docs this should return the number of the week day instead (starting at 0 for Sunday).

(possible) cause

It looks like this is simply calling the wrong function.

Changes made in this PR:

I created a new function to return the number and added a test.

Thank you for considering this merge!

@@ -416,6 +416,10 @@ func weekOfDayFormatter(t *time.Time) ([]rune, error) {
return []rune(dayOfWeeks[int(t.Weekday())]), nil
}

func weekOfDayNumberFormatter(t *time.Time) ([]rune, error) {
return []rune(fmt.Sprintf("%d", int(t.Weekday()))), nil
Copy link
Owner

Choose a reason for hiding this comment

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

please use []rune(fmt.Sprint(int(t.Weekday())))

@philschoefer
Copy link
Author

Thank you! Updated, please re-review ❤️

@philschoefer philschoefer requested a review from goccy January 23, 2024 21:15
@@ -416,6 +416,10 @@ func weekOfDayFormatter(t *time.Time) ([]rune, error) {
return []rune(dayOfWeeks[int(t.Weekday())]), nil
}

func weekOfDayNumberFormatter(t *time.Time) ([]rune, error) {
return []rune(fmt.Sprint(int(t.Weekday())))
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for the update @philschoefer
It looks like the build is failing as you're no longer returning a nil error

By the way, I'm not a project member, so I won't have permission to approve / get this merged.
We'll need to wait for @goccy

@goccy
Copy link
Owner

goccy commented Mar 9, 2024

Due to lack of response, this PR is closed

@goccy goccy closed this Mar 9, 2024
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