{"action":"created","comment":{"url":"https://api.github.com/repos/apache/spark/pulls/comments/50801910","id":50801910,"diff_hunk":"@@ -309,4 +311,84 @@ final class DataFrameStatFunctions private[sql](df: DataFrame) {\n   def sampleBy[T](col: String, fractions: ju.Map[T, jl.Double], seed: Long): DataFrame = {\n     sampleBy(col, fractions.asScala.toMap.asInstanceOf[Map[T, Double]], seed)\n   }\n+\n+  /**\n+   * Builds a Count-min Sketch over a specified column.\n+   *\n+   * @param colName name of the column over which the sketch is built\n+   * @param depth depth of the sketch\n+   * @param width width of the sketch\n+   * @param seed random seed\n+   * @return a [[CountMinSketch]] over column `colName`\n+   * @since 2.0.0\n+   */\n+  def countMinSketch(colName: String, depth: Int, width: Int, seed: Int): CountMinSketch = {\n+    countMinSketch(Column(colName), depth, width, seed)\n+  }\n+\n+  /**\n+   * Builds a Count-min Sketch over a specified column.\n+   *\n+   * @param colName name of the column over which the sketch is built\n+   * @param eps relative error of the sketch\n+   * @param confidence confidence of the sketch\n+   * @param seed random seed\n+   * @return a [[CountMinSketch]] over column `colName`\n+   * @since 2.0.0\n+   */\n+  def countMinSketch(\n+      colName: String, eps: Double, confidence: Double, seed: Int): CountMinSketch = {\n+    countMinSketch(Column(colName), eps, confidence, seed)\n+  }\n+\n+  /**\n+   * Builds a Count-min Sketch over a specified column.\n+   *\n+   * @param col the column over which the sketch is built\n+   * @param depth depth of the sketch\n+   * @param width width of the sketch\n+   * @param seed random seed\n+   * @return a [[CountMinSketch]] over column `colName`\n+   * @since 2.0.0\n+   */\n+  def countMinSketch(col: Column, depth: Int, width: Int, seed: Int): CountMinSketch = {\n+    countMinSketch(col, CountMinSketch.create(depth, width, seed))\n+  }\n+\n+  /**\n+   * Builds a Count-min Sketch over a specified column.\n+   *\n+   * @param col the column over which the sketch is built\n+   * @param eps relative error of the sketch\n+   * @param confidence confidence of the sketch\n+   * @param seed random seed\n+   * @return a [[CountMinSketch]] over column `colName`\n+   * @since 2.0.0\n+   */\n+  def countMinSketch(col: Column, eps: Double, confidence: Double, seed: Int): CountMinSketch = {\n+    countMinSketch(col, CountMinSketch.create(eps, confidence, seed))\n+  }\n+\n+  private def countMinSketch(col: Column, zero: CountMinSketch): CountMinSketch = {\n+    val singleCol = df.select(col)\n+    val colType = singleCol.schema.head.dataType\n+    val supportedTypes: Set[DataType] = Set(ByteType, ShortType, IntegerType, LongType, StringType)\n+\n+    require(\n+      supportedTypes.contains(colType),","path":"sql/core/src/main/scala/org/apache/spark/sql/DataFrameStatFunctions.scala","position":77,"original_position":77,"commit_id":"32a98600705c951b202b0a060eaca536b1477713","original_commit_id":"32a98600705c951b202b0a060eaca536b1477713","user":{"login":"cloud-fan","id":3182036,"avatar_url":"https://avatars.githubusercontent.com/u/3182036?v=3","gravatar_id":"","url":"https://api.github.com/users/cloud-fan","html_url":"https://github.com/cloud-fan","followers_url":"https://api.github.com/users/cloud-fan/followers","following_url":"https://api.github.com/users/cloud-fan/following{/other_user}","gists_url":"https://api.github.com/users/cloud-fan/gists{/gist_id}","starred_url":"https://api.github.com/users/cloud-fan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cloud-fan/subscriptions","organizations_url":"https://api.github.com/users/cloud-fan/orgs","repos_url":"https://api.github.com/users/cloud-fan/repos","events_url":"https://api.github.com/users/cloud-fan/events{/privacy}","received_events_url":"https://api.github.com/users/cloud-fan/received_events","type":"User","site_admin":false},"body":"how about `colType == StringType || colType.isInstanceOf[IntegralType]`?","created_at":"2016-01-26T07:28:31Z","updated_at":"2016-01-26T07:28:31Z","html_url":"https://github.com/apache/spark/pull/10911#discussion_r50801910","pull_request_url":"https://api.github.com/repos/apache/spark/pulls/10911","_links":{"self":{"href":"https://api.github.com/repos/apache/spark/pulls/comments/50801910"},"html":{"href":"https://github.com/apache/spark/pull/10911#discussion_r50801910"},"pull_request":{"href":"https://api.github.com/repos/apache/spark/pulls/10911"}}},"pull_request":{"url":"https://api.github.com/repos/apache/spark/pulls/10911","id":57157181,"html_url":"https://github.com/apache/spark/pull/10911","diff_url":"https://github.com/apache/spark/pull/10911.diff","patch_url":"https://github.com/apache/spark/pull/10911.patch","issue_url":"https://api.github.com/repos/apache/spark/issues/10911","number":10911,"state":"open","locked":false,"title":"[SPARK-12935][SQL] DataFrame API for Count-Min Sketch","user":{"login":"liancheng","id":230655,"avatar_url":"https://avatars.githubusercontent.com/u/230655?v=3","gravatar_id":"","url":"https://api.github.com/users/liancheng","html_url":"https://github.com/liancheng","followers_url":"https://api.github.com/users/liancheng/followers","following_url":"https://api.github.com/users/liancheng/following{/other_user}","gists_url":"https://api.github.com/users/liancheng/gists{/gist_id}","starred_url":"https://api.github.com/users/liancheng/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/liancheng/subscriptions","organizations_url":"https://api.github.com/users/liancheng/orgs","repos_url":"https://api.github.com/users/liancheng/repos","events_url":"https://api.github.com/users/liancheng/events{/privacy}","received_events_url":"https://api.github.com/users/liancheng/received_events","type":"User","site_admin":false},"body":"This PR integrates Count-Min Sketch from spark-sketch into DataFrame. This version resorts to `RDD.aggregate` for building the sketch. A more performant UDAF version can be built in future follow-up PRs.","created_at":"2016-01-26T01:18:00Z","updated_at":"2016-01-26T07:28:31Z","closed_at":null,"merged_at":null,"merge_commit_sha":"4d738754d69b70b51c275de7f9d13d9ce0280c9d","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/apache/spark/pulls/10911/commits","review_comments_url":"https://api.github.com/repos/apache/spark/pulls/10911/comments","review_comment_url":"https://api.github.com/repos/apache/spark/pulls/comments{/number}","comments_url":"https://api.github.com/repos/apache/spark/issues/10911/comments","statuses_url":"https://api.github.com/repos/apache/spark/statuses/32a98600705c951b202b0a060eaca536b1477713","head":{"label":"liancheng:cms-df-api","ref":"cms-df-api","sha":"32a98600705c951b202b0a060eaca536b1477713","user":{"login":"liancheng","id":230655,"avatar_url":"https://avatars.githubusercontent.com/u/230655?v=3","gravatar_id":"","url":"https://api.github.com/users/liancheng","html_url":"https://github.com/liancheng","followers_url":"https://api.github.com/users/liancheng/followers","following_url":"https://api.github.com/users/liancheng/following{/other_user}","gists_url":"https://api.github.com/users/liancheng/gists{/gist_id}","starred_url":"https://api.github.com/users/liancheng/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/liancheng/subscriptions","organizations_url":"https://api.github.com/users/liancheng/orgs","repos_url":"https://api.github.com/users/liancheng/repos","events_url":"https://api.github.com/users/liancheng/events{/privacy}","received_events_url":"https://api.github.com/users/liancheng/received_events","type":"User","site_admin":false},"repo":{"id":17232535,"name":"spark","full_name":"liancheng/spark","owner":{"login":"liancheng","id":230655,"avatar_url":"https://avatars.githubusercontent.com/u/230655?v=3","gravatar_id":"","url":"https://api.github.com/users/liancheng","html_url":"https://github.com/liancheng","followers_url":"https://api.github.com/users/liancheng/followers","following_url":"https://api.github.com/users/liancheng/following{/other_user}","gists_url":"https://api.github.com/users/liancheng/gists{/gist_id}","starred_url":"https://api.github.com/users/liancheng/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/liancheng/subscriptions","organizations_url":"https://api.github.com/users/liancheng/orgs","repos_url":"https://api.github.com/users/liancheng/repos","events_url":"https://api.github.com/users/liancheng/events{/privacy}","received_events_url":"https://api.github.com/users/liancheng/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/liancheng/spark","description":"Mirror of Apache Spark","fork":true,"url":"https://api.github.com/repos/liancheng/spark","forks_url":"https://api.github.com/repos/liancheng/spark/forks","keys_url":"https://api.github.com/repos/liancheng/spark/keys{/key_id}","collaborators_url":"https://api.github.com/repos/liancheng/spark/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/liancheng/spark/teams","hooks_url":"https://api.github.com/repos/liancheng/spark/hooks","issue_events_url":"https://api.github.com/repos/liancheng/spark/issues/events{/number}","events_url":"https://api.github.com/repos/liancheng/spark/events","assignees_url":"https://api.github.com/repos/liancheng/spark/assignees{/user}","branches_url":"https://api.github.com/repos/liancheng/spark/branches{/branch}","tags_url":"https://api.github.com/repos/liancheng/spark/tags","blobs_url":"https://api.github.com/repos/liancheng/spark/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/liancheng/spark/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/liancheng/spark/git/refs{/sha}","trees_url":"https://api.github.com/repos/liancheng/spark/git/trees{/sha}","statuses_url":"https://api.github.com/repos/liancheng/spark/statuses/{sha}","languages_url":"https://api.github.com/repos/liancheng/spark/languages","stargazers_url":"https://api.github.com/repos/liancheng/spark/stargazers","contributors_url":"https://api.github.com/repos/liancheng/spark/contributors","subscribers_url":"https://api.github.com/repos/liancheng/spark/subscribers","subscription_url":"https://api.github.com/repos/liancheng/spark/subscription","commits_url":"https://api.github.com/repos/liancheng/spark/commits{/sha}","git_commits_url":"https://api.github.com/repos/liancheng/spark/git/commits{/sha}","comments_url":"https://api.github.com/repos/liancheng/spark/comments{/number}","issue_comment_url":"https://api.github.com/repos/liancheng/spark/issues/comments{/number}","contents_url":"https://api.github.com/repos/liancheng/spark/contents/{+path}","compare_url":"https://api.github.com/repos/liancheng/spark/compare/{base}...{head}","merges_url":"https://api.github.com/repos/liancheng/spark/merges","archive_url":"https://api.github.com/repos/liancheng/spark/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/liancheng/spark/downloads","issues_url":"https://api.github.com/repos/liancheng/spark/issues{/number}","pulls_url":"https://api.github.com/repos/liancheng/spark/pulls{/number}","milestones_url":"https://api.github.com/repos/liancheng/spark/milestones{/number}","notifications_url":"https://api.github.com/repos/liancheng/spark/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/liancheng/spark/labels{/name}","releases_url":"https://api.github.com/repos/liancheng/spark/releases{/id}","deployments_url":"https://api.github.com/repos/liancheng/spark/deployments","created_at":"2014-02-27T01:39:03Z","updated_at":"2015-03-31T08:56:24Z","pushed_at":"2016-01-26T02:26:55Z","git_url":"git://github.com/liancheng/spark.git","ssh_url":"git@github.com:liancheng/spark.git","clone_url":"https://github.com/liancheng/spark.git","svn_url":"https://github.com/liancheng/spark","homepage":null,"size":133752,"stargazers_count":1,"watchers_count":1,"language":"Scala","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":1,"default_branch":"master"}},"base":{"label":"apache:master","ref":"master","sha":"109061f7ad27225669cbe609ec38756b31d4e1b9","user":{"login":"apache","id":47359,"avatar_url":"https://avatars.githubusercontent.com/u/47359?v=3","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,"name":"spark","full_name":"apache/spark","owner":{"login":"apache","id":47359,"avatar_url":"https://avatars.githubusercontent.com/u/47359?v=3","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},"private":false,"html_url":"https://github.com/apache/spark","description":"Mirror of Apache Spark","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":"2016-01-26T06:49:41Z","pushed_at":"2016-01-26T07:25:29Z","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":null,"size":403983,"stargazers_count":7180,"watchers_count":7180,"language":"Scala","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":6582,"mirror_url":"git://git.apache.org/spark.git","open_issues_count":350,"forks":6582,"open_issues":350,"watchers":7180,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/apache/spark/pulls/10911"},"html":{"href":"https://github.com/apache/spark/pull/10911"},"issue":{"href":"https://api.github.com/repos/apache/spark/issues/10911"},"comments":{"href":"https://api.github.com/repos/apache/spark/issues/10911/comments"},"review_comments":{"href":"https://api.github.com/repos/apache/spark/pulls/10911/comments"},"review_comment":{"href":"https://api.github.com/repos/apache/spark/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/apache/spark/pulls/10911/commits"},"statuses":{"href":"https://api.github.com/repos/apache/spark/statuses/32a98600705c951b202b0a060eaca536b1477713"}}}}