{"url":"https://api.github.com/repos/apache/spark/pulls/28692","id":425837403,"node_id":"MDExOlB1bGxSZXF1ZXN0NDI1ODM3NDAz","html_url":"https://github.com/apache/spark/pull/28692","diff_url":"https://github.com/apache/spark/pull/28692.diff","patch_url":"https://github.com/apache/spark/pull/28692.patch","issue_url":"https://api.github.com/repos/apache/spark/issues/28692","number":28692,"state":"closed","locked":false,"title":"[SPARK-31879][SQL] Using GB as default Locale for datetime formatters","user":{"login":"yaooqinn","id":8326978,"node_id":"MDQ6VXNlcjgzMjY5Nzg=","avatar_url":"https://avatars.githubusercontent.com/u/8326978?v=4","gravatar_id":"","url":"https://api.github.com/users/yaooqinn","html_url":"https://github.com/yaooqinn","followers_url":"https://api.github.com/users/yaooqinn/followers","following_url":"https://api.github.com/users/yaooqinn/following{/other_user}","gists_url":"https://api.github.com/users/yaooqinn/gists{/gist_id}","starred_url":"https://api.github.com/users/yaooqinn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yaooqinn/subscriptions","organizations_url":"https://api.github.com/users/yaooqinn/orgs","repos_url":"https://api.github.com/users/yaooqinn/repos","events_url":"https://api.github.com/users/yaooqinn/events{/privacy}","received_events_url":"https://api.github.com/users/yaooqinn/received_events","type":"User","site_admin":false},"body":" # What changes were proposed in this pull request?\r\n\r\nThis PR switches the default Locale from the `US` to `GB` to change the behavior of the first day of the week from Sunday-started to Monday-started as same as v2.4\r\n\r\n\r\n### Why are the changes needed?\r\n\r\n#### cases\r\n```sql\r\nspark-sql> select to_timestamp('2020-1-1', 'YYYY-w-u');\r\n2019-12-29 00:00:00\r\nspark-sql> set spark.sql.legacy.timeParserPolicy=legacy;\r\nspark.sql.legacy.timeParserPolicy\tlegacy\r\nspark-sql> select to_timestamp('2020-1-1', 'YYYY-w-u');\r\n2019-12-30 00:00:00\r\n```\r\n\r\n#### reasons\r\n\r\nThese week-based fields need Locale to express their semantics, the first day of the week varies from country to country.\r\n\r\nFrom the Java doc of WeekFields\r\n```java\r\n /**\r\n * Gets the first day-of-week.\r\n *
\r\n * The first day-of-week varies by culture.\r\n * For example, the US uses Sunday, while France and the ISO-8601 standard use Monday.\r\n * This method returns the first day using the standard {@code DayOfWeek} enum.\r\n *\r\n * @return the first day-of-week, not null\r\n */\r\n public DayOfWeek getFirstDayOfWeek() {\r\n return firstDayOfWeek;\r\n }\r\n```\r\n\r\nBut for the SimpleDateFormat, the day-of-week is not localized\r\n\r\n```\r\nu\tDay number of week (1 = Monday, ..., 7 = Sunday)\tNumber\t1\r\n```\r\n\r\nCurrently, the default locale we use is the US, so the result moved a day backward.\r\n\r\nFor other countries, please refer to [First Day of the Week in Different Countries](http://chartsbin.com/view/41671)\r\n\r\nWith this change, it restores the first day of week calculating for functions when using the default locale.\r\n\r\n### Does this PR introduce _any_ user-facing change?\r\n\r\n\r\nYes, but the behavior change is used to restore the old one of v2.4\r\n\r\n\r\n### How was this patch tested?\r\n\r\nadd unit tests\r\n","created_at":"2020-06-01T08:45:41Z","updated_at":"2020-06-04T05:50:36Z","closed_at":"2020-06-03T06:08:18Z","merged_at":null,"merge_commit_sha":"f13734aada9716b34b0e7c4824207243e0b82520","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":1405794576,"node_id":"MDU6TGFiZWwxNDA1Nzk0NTc2","url":"https://api.github.com/repos/apache/spark/labels/SQL","name":"SQL","color":"ededed","default":false,"description":null}],"milestone":null,"draft":false,"commits_url":"https://api.github.com/repos/apache/spark/pulls/28692/commits","review_comments_url":"https://api.github.com/repos/apache/spark/pulls/28692/comments","review_comment_url":"https://api.github.com/repos/apache/spark/pulls/comments{/number}","comments_url":"https://api.github.com/repos/apache/spark/issues/28692/comments","statuses_url":"https://api.github.com/repos/apache/spark/statuses/f94c72be5edc5846b64bef8ed81a24a9109716c8","head":{"label":"yaooqinn:SPARK-31879","ref":"SPARK-31879","sha":"f94c72be5edc5846b64bef8ed81a24a9109716c8","user":{"login":"yaooqinn","id":8326978,"node_id":"MDQ6VXNlcjgzMjY5Nzg=","avatar_url":"https://avatars.githubusercontent.com/u/8326978?v=4","gravatar_id":"","url":"https://api.github.com/users/yaooqinn","html_url":"https://github.com/yaooqinn","followers_url":"https://api.github.com/users/yaooqinn/followers","following_url":"https://api.github.com/users/yaooqinn/following{/other_user}","gists_url":"https://api.github.com/users/yaooqinn/gists{/gist_id}","starred_url":"https://api.github.com/users/yaooqinn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yaooqinn/subscriptions","organizations_url":"https://api.github.com/users/yaooqinn/orgs","repos_url":"https://api.github.com/users/yaooqinn/repos","events_url":"https://api.github.com/users/yaooqinn/events{/privacy}","received_events_url":"https://api.github.com/users/yaooqinn/received_events","type":"User","site_admin":false},"repo":null},"base":{"label":"apache:master","ref":"master","sha":"b806fc458265578fddf544363b60fb5e122439b5","user":{"login":"apache","id":47359,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQ3MzU5","avatar_url":"https://avatars.githubusercontent.com/u/47359?v=4","gravatar_id":"","url":"https://api.github.com/users/apache","html_url":"https://github.com/apache","followers_url":"https://api.github.com/users/apache/followers","following_url":"https://api.github.com/users/apache/following{/other_user}","gists_url":"https://api.github.com/users/apache/gists{/gist_id}","starred_url":"https://api.github.com/users/apache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apache/subscriptions","organizations_url":"https://api.github.com/users/apache/orgs","repos_url":"https://api.github.com/users/apache/repos","events_url":"https://api.github.com/users/apache/events{/privacy}","received_events_url":"https://api.github.com/users/apache/received_events","type":"Organization","site_admin":false},"repo":{"id":17165658,"node_id":"MDEwOlJlcG9zaXRvcnkxNzE2NTY1OA==","name":"spark","full_name":"apache/spark","private":false,"owner":{"login":"apache","id":47359,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQ3MzU5","avatar_url":"https://avatars.githubusercontent.com/u/47359?v=4","gravatar_id":"","url":"https://api.github.com/users/apache","html_url":"https://github.com/apache","followers_url":"https://api.github.com/users/apache/followers","following_url":"https://api.github.com/users/apache/following{/other_user}","gists_url":"https://api.github.com/users/apache/gists{/gist_id}","starred_url":"https://api.github.com/users/apache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apache/subscriptions","organizations_url":"https://api.github.com/users/apache/orgs","repos_url":"https://api.github.com/users/apache/repos","events_url":"https://api.github.com/users/apache/events{/privacy}","received_events_url":"https://api.github.com/users/apache/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/apache/spark","description":"Apache Spark - A unified analytics engine for large-scale data processing","fork":false,"url":"https://api.github.com/repos/apache/spark","forks_url":"https://api.github.com/repos/apache/spark/forks","keys_url":"https://api.github.com/repos/apache/spark/keys{/key_id}","collaborators_url":"https://api.github.com/repos/apache/spark/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/apache/spark/teams","hooks_url":"https://api.github.com/repos/apache/spark/hooks","issue_events_url":"https://api.github.com/repos/apache/spark/issues/events{/number}","events_url":"https://api.github.com/repos/apache/spark/events","assignees_url":"https://api.github.com/repos/apache/spark/assignees{/user}","branches_url":"https://api.github.com/repos/apache/spark/branches{/branch}","tags_url":"https://api.github.com/repos/apache/spark/tags","blobs_url":"https://api.github.com/repos/apache/spark/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/apache/spark/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/apache/spark/git/refs{/sha}","trees_url":"https://api.github.com/repos/apache/spark/git/trees{/sha}","statuses_url":"https://api.github.com/repos/apache/spark/statuses/{sha}","languages_url":"https://api.github.com/repos/apache/spark/languages","stargazers_url":"https://api.github.com/repos/apache/spark/stargazers","contributors_url":"https://api.github.com/repos/apache/spark/contributors","subscribers_url":"https://api.github.com/repos/apache/spark/subscribers","subscription_url":"https://api.github.com/repos/apache/spark/subscription","commits_url":"https://api.github.com/repos/apache/spark/commits{/sha}","git_commits_url":"https://api.github.com/repos/apache/spark/git/commits{/sha}","comments_url":"https://api.github.com/repos/apache/spark/comments{/number}","issue_comment_url":"https://api.github.com/repos/apache/spark/issues/comments{/number}","contents_url":"https://api.github.com/repos/apache/spark/contents/{+path}","compare_url":"https://api.github.com/repos/apache/spark/compare/{base}...{head}","merges_url":"https://api.github.com/repos/apache/spark/merges","archive_url":"https://api.github.com/repos/apache/spark/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/apache/spark/downloads","issues_url":"https://api.github.com/repos/apache/spark/issues{/number}","pulls_url":"https://api.github.com/repos/apache/spark/pulls{/number}","milestones_url":"https://api.github.com/repos/apache/spark/milestones{/number}","notifications_url":"https://api.github.com/repos/apache/spark/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/apache/spark/labels{/name}","releases_url":"https://api.github.com/repos/apache/spark/releases{/id}","deployments_url":"https://api.github.com/repos/apache/spark/deployments","created_at":"2014-02-25T08:00:08Z","updated_at":"2024-03-29T10:03:57Z","pushed_at":"2024-03-29T11:38:07Z","git_url":"git://github.com/apache/spark.git","ssh_url":"git@github.com:apache/spark.git","clone_url":"https://github.com/apache/spark.git","svn_url":"https://github.com/apache/spark","homepage":"https://spark.apache.org/","size":427718,"stargazers_count":38139,"watchers_count":38139,"language":"Scala","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"has_discussions":false,"forks_count":27874,"mirror_url":null,"archived":false,"disabled":false,"open_issues_count":189,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"allow_forking":true,"is_template":false,"web_commit_signoff_required":false,"topics":["big-data","java","jdbc","python","r","scala","spark","sql"],"visibility":"public","forks":27874,"open_issues":189,"watchers":38139,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/apache/spark/pulls/28692"},"html":{"href":"https://github.com/apache/spark/pull/28692"},"issue":{"href":"https://api.github.com/repos/apache/spark/issues/28692"},"comments":{"href":"https://api.github.com/repos/apache/spark/issues/28692/comments"},"review_comments":{"href":"https://api.github.com/repos/apache/spark/pulls/28692/comments"},"review_comment":{"href":"https://api.github.com/repos/apache/spark/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/apache/spark/pulls/28692/commits"},"statuses":{"href":"https://api.github.com/repos/apache/spark/statuses/f94c72be5edc5846b64bef8ed81a24a9109716c8"}},"author_association":"MEMBER","auto_merge":null,"active_lock_reason":null,"merged":false,"mergeable":null,"rebaseable":null,"mergeable_state":"unknown","merged_by":null,"comments":28,"review_comments":6,"maintainer_can_modify":false,"commits":3,"additions":69,"deletions":5,"changed_files":6}