{"action":"created","issue":{"url":"https://api.github.com/repos/apache/spark/issues/22365","repository_url":"https://api.github.com/repos/apache/spark","labels_url":"https://api.github.com/repos/apache/spark/issues/22365/labels{/name}","comments_url":"https://api.github.com/repos/apache/spark/issues/22365/comments","events_url":"https://api.github.com/repos/apache/spark/issues/22365/events","html_url":"https://github.com/apache/spark/pull/22365","id":358308418,"node_id":"MDExOlB1bGxSZXF1ZXN0MjE0MTAyNjQ3","number":22365,"title":"[SPARK-25381][SQL] Stratified sampling by Column argument","user":{"login":"MaxGekk","id":1580697,"node_id":"MDQ6VXNlcjE1ODA2OTc=","avatar_url":"https://avatars1.githubusercontent.com/u/1580697?v=4","gravatar_id":"","url":"https://api.github.com/users/MaxGekk","html_url":"https://github.com/MaxGekk","followers_url":"https://api.github.com/users/MaxGekk/followers","following_url":"https://api.github.com/users/MaxGekk/following{/other_user}","gists_url":"https://api.github.com/users/MaxGekk/gists{/gist_id}","starred_url":"https://api.github.com/users/MaxGekk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MaxGekk/subscriptions","organizations_url":"https://api.github.com/users/MaxGekk/orgs","repos_url":"https://api.github.com/users/MaxGekk/repos","events_url":"https://api.github.com/users/MaxGekk/events{/privacy}","received_events_url":"https://api.github.com/users/MaxGekk/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2018-09-08T16:16:31Z","updated_at":"2018-09-08T20:27:11Z","closed_at":null,"author_association":"CONTRIBUTOR","pull_request":{"url":"https://api.github.com/repos/apache/spark/pulls/22365","html_url":"https://github.com/apache/spark/pull/22365","diff_url":"https://github.com/apache/spark/pull/22365.diff","patch_url":"https://github.com/apache/spark/pull/22365.patch"},"body":"## What changes were proposed in this pull request?\r\n\r\nIn the PR, I propose to add an overloaded method for `sampleBy` which accepts the first argument of the `Column` type. This will allow to sample by any complex columns as well as sampling by multiple columns. For example:\r\n\r\n```Scala\r\nspark.createDataFrame(Seq((\"Bob\", 17), (\"Alice\", 10), (\"Nico\", 8), (\"Bob\", 17),\r\n  (\"Alice\", 10))).toDF(\"name\", \"age\")\r\n  .stat\r\n  .sampleBy(struct($\"name\", $\"age\"), Map(Row(\"Alice\", 10) -> 0.3, Row(\"Nico\", 8) -> 1.0), 36L)\r\n  .show()\r\n\r\n+-----+---+\r\n| name|age|\r\n+-----+---+\r\n| Nico|  8|\r\n|Alice| 10|\r\n+-----+---+\r\n```\r\n\r\n## How was this patch tested?\r\n\r\nAdded new test for sampling by multiple columns for Scala and test for Java, Python to check that `sampleBy` is able to sample by `Column` type argument.\r\n"},"comment":{"url":"https://api.github.com/repos/apache/spark/issues/comments/419670655","html_url":"https://github.com/apache/spark/pull/22365#issuecomment-419670655","issue_url":"https://api.github.com/repos/apache/spark/issues/22365","id":419670655,"node_id":"MDEyOklzc3VlQ29tbWVudDQxOTY3MDY1NQ==","user":{"login":"SparkQA","id":8108735,"node_id":"MDQ6VXNlcjgxMDg3MzU=","avatar_url":"https://avatars1.githubusercontent.com/u/8108735?v=4","gravatar_id":"","url":"https://api.github.com/users/SparkQA","html_url":"https://github.com/SparkQA","followers_url":"https://api.github.com/users/SparkQA/followers","following_url":"https://api.github.com/users/SparkQA/following{/other_user}","gists_url":"https://api.github.com/users/SparkQA/gists{/gist_id}","starred_url":"https://api.github.com/users/SparkQA/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SparkQA/subscriptions","organizations_url":"https://api.github.com/users/SparkQA/orgs","repos_url":"https://api.github.com/users/SparkQA/repos","events_url":"https://api.github.com/users/SparkQA/events{/privacy}","received_events_url":"https://api.github.com/users/SparkQA/received_events","type":"User","site_admin":false},"created_at":"2018-09-08T20:27:11Z","updated_at":"2018-09-08T20:27:11Z","author_association":"NONE","body":"**[Test build #95836 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/95836/testReport)** for PR 22365 at commit [`2845bca`](https://github.com/apache/spark/commit/2845bca09797a34e930e6aca42f198ec5cbd95e3).\n * This patch passes all tests.\n * This patch merges cleanly.\n * This patch adds no public classes."}}
{"actor":{"display_login":"SparkQA"}}