{"action":"created","issue":{"url":"https://api.github.com/repos/apache/spark/issues/15668","repository_url":"https://api.github.com/repos/apache/spark","labels_url":"https://api.github.com/repos/apache/spark/issues/15668/labels{/name}","comments_url":"https://api.github.com/repos/apache/spark/issues/15668/comments","events_url":"https://api.github.com/repos/apache/spark/issues/15668/events","html_url":"https://github.com/apache/spark/pull/15668","id":185831853,"number":15668,"title":"[SPARK-18137][SQL]Fix RewriteDistinctAggregates UnresolvedException when a UDAF has a foldable TypeCheck","user":{"login":"windpiger","id":12979185,"avatar_url":"https://avatars.githubusercontent.com/u/12979185?v=3","gravatar_id":"","url":"https://api.github.com/users/windpiger","html_url":"https://github.com/windpiger","followers_url":"https://api.github.com/users/windpiger/followers","following_url":"https://api.github.com/users/windpiger/following{/other_user}","gists_url":"https://api.github.com/users/windpiger/gists{/gist_id}","starred_url":"https://api.github.com/users/windpiger/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/windpiger/subscriptions","organizations_url":"https://api.github.com/users/windpiger/orgs","repos_url":"https://api.github.com/users/windpiger/repos","events_url":"https://api.github.com/users/windpiger/events{/privacy}","received_events_url":"https://api.github.com/users/windpiger/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":20,"created_at":"2016-10-28T03:40:11Z","updated_at":"2016-11-08T06:10:12Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/apache/spark/pulls/15668","html_url":"https://github.com/apache/spark/pull/15668","diff_url":"https://github.com/apache/spark/pull/15668.diff","patch_url":"https://github.com/apache/spark/pull/15668.patch"},"body":"## What changes were proposed in this pull request?\n\nIn RewriteDistinctAggregates rewrite funtion,after the UDAF's childs are mapped to AttributeRefference, If the UDAF(such as ApproximatePercentile) has a foldable TypeCheck for the input, It will failed because the AttributeRefference is not foldable,then the UDAF is not resolved, and then nullify on the unresolved object will throw a Exception.\n\nIn this PR, only map Unfoldable child to AttributeRefference, this can avoid the UDAF's foldable TypeCheck. and then only Expand Unfoldable child, there is no need to Expand a static value(foldable value).\n\n**Before sql result**\n\n> select percentile_approxy(key,0.99999),count(distinct key),sume(distinc key) from src limit 1\n> org.apache.spark.sql.catalyst.analysis.UnresolvedException: Invalid call to dataType on unresolved object, tree: 'percentile_approx(CAST(src.`key` AS DOUBLE), CAST(0.99999BD AS DOUBLE), 10000)\n> at org.apache.spark.sql.catalyst.analysis.UnresolvedAttribute.dataType(unresolved.scala:92)\n>     at org.apache.spark.sql.catalyst.optimizer.RewriteDistinctAggregates$.org$apache$spark$sql$catalyst$optimizer$RewriteDistinctAggregates$$nullify(RewriteDistinctAggregates.scala:261)\n\n**After sql result**\n\n> select percentile_approxy(key,0.99999),count(distinct key),sume(distinc key) from src limit 1\n> [498.0,309,79136]\n## How was this patch tested?\n\nAdd a test case in HiveUDFSuit.\n"},"comment":{"url":"https://api.github.com/repos/apache/spark/issues/comments/259054312","html_url":"https://github.com/apache/spark/pull/15668#issuecomment-259054312","issue_url":"https://api.github.com/repos/apache/spark/issues/15668","id":259054312,"user":{"login":"AmplabJenkins","id":4031291,"avatar_url":"https://avatars.githubusercontent.com/u/4031291?v=3","gravatar_id":"","url":"https://api.github.com/users/AmplabJenkins","html_url":"https://github.com/AmplabJenkins","followers_url":"https://api.github.com/users/AmplabJenkins/followers","following_url":"https://api.github.com/users/AmplabJenkins/following{/other_user}","gists_url":"https://api.github.com/users/AmplabJenkins/gists{/gist_id}","starred_url":"https://api.github.com/users/AmplabJenkins/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AmplabJenkins/subscriptions","organizations_url":"https://api.github.com/users/AmplabJenkins/orgs","repos_url":"https://api.github.com/users/AmplabJenkins/repos","events_url":"https://api.github.com/users/AmplabJenkins/events{/privacy}","received_events_url":"https://api.github.com/users/AmplabJenkins/received_events","type":"User","site_admin":false},"created_at":"2016-11-08T06:10:12Z","updated_at":"2016-11-08T06:10:12Z","body":"Test PASSed.\nRefer to this link for build results (access rights to CI server needed): \nhttps://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/68315/\nTest PASSed."}}
{"actor":{"display_login":"AmplabJenkins"}}