{"action":"created","issue":{"url":"https://api.github.com/repos/apache/spark/issues/21401","repository_url":"https://api.github.com/repos/apache/spark","labels_url":"https://api.github.com/repos/apache/spark/issues/21401/labels{/name}","comments_url":"https://api.github.com/repos/apache/spark/issues/21401/comments","events_url":"https://api.github.com/repos/apache/spark/issues/21401/events","html_url":"https://github.com/apache/spark/pull/21401","id":325357505,"number":21401,"title":"[SPARK-24350][SQL] \"array_position\" error fix","user":{"login":"wajda","id":795479,"avatar_url":"https://avatars3.githubusercontent.com/u/795479?v=4","gravatar_id":"","url":"https://api.github.com/users/wajda","html_url":"https://github.com/wajda","followers_url":"https://api.github.com/users/wajda/followers","following_url":"https://api.github.com/users/wajda/following{/other_user}","gists_url":"https://api.github.com/users/wajda/gists{/gist_id}","starred_url":"https://api.github.com/users/wajda/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wajda/subscriptions","organizations_url":"https://api.github.com/users/wajda/orgs","repos_url":"https://api.github.com/users/wajda/repos","events_url":"https://api.github.com/users/wajda/events{/privacy}","received_events_url":"https://api.github.com/users/wajda/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2018-05-22T15:51:50Z","updated_at":"2018-05-22T22:02:28Z","closed_at":null,"author_association":"CONTRIBUTOR","pull_request":{"url":"https://api.github.com/repos/apache/spark/pulls/21401","html_url":"https://github.com/apache/spark/pull/21401","diff_url":"https://github.com/apache/spark/pull/21401.diff","patch_url":"https://github.com/apache/spark/pull/21401.patch"},"body":"## What changes were proposed in this pull request?\r\n\r\n### Fixes `ClassCastException` in the `array_position` function - [SPARK-24350](https://issues.apache.org/jira/browse/SPARK-24350)\r\nWhen calling `array_position` function with a wrong type of the 1st argument an `AnalysisException` should be thrown instead of `ClassCastException`\r\n\r\nExample:\r\n\r\n```sql\r\nselect array_position('foo', 'bar')\r\n```\r\n\r\n```\r\njava.lang.ClassCastException: org.apache.spark.sql.types.StringType$ cannot be cast to org.apache.spark.sql.types.ArrayType\r\n\tat org.apache.spark.sql.catalyst.expressions.ArrayPosition.inputTypes(collectionOperations.scala:1398)\r\n\tat org.apache.spark.sql.catalyst.expressions.ExpectsInputTypes$class.checkInputDataTypes(ExpectsInputTypes.scala:44)\r\n\tat org.apache.spark.sql.catalyst.expressions.ArrayPosition.checkInputDataTypes(collectionOperations.scala:1401)\r\n\tat org.apache.spark.sql.catalyst.expressions.Expression.resolved$lzycompute(Expression.scala:168)\r\n\tat org.apache.spark.sql.catalyst.expressions.Expression.resolved(Expression.scala:168)\r\n\tat org.apache.spark.sql.catalyst.analysis.Analyzer$ResolveAliases$$anonfun$org$apache$spark$sql$catalyst$analysis$Analyzer$ResolveAliases$$assignAliases$1$$anonfun$apply$3.applyOrElse(Analyzer.scala:256)\r\n\tat org.apache.spark.sql.catalyst.analysis.Analyzer$ResolveAliases$$anonfun$org$apache$spark$sql$catalyst$analysis$Analyzer$ResolveAliases$$assignAliases$1$$anonfun$apply$3.applyOrElse(Analyzer.scala:252)\r\n\tat org.apache.spark.sql.catalyst.trees.TreeNode$$anonfun$transformUp$1.apply(TreeNode.scala:289)\r\n\tat org.apache.spark.sql.catalyst.trees.TreeNode$$anonfun$transformUp$1.apply(TreeNode.scala:289)\r\n\tat org.apache.spark.sql.catalyst.trees.CurrentOrigin$.withOrigin(TreeNode.scala:70)\r\n\tat org.apache.spark.sql.catalyst.trees.TreeNode.transformUp(TreeNode.scala:288)\r\n```\r\n\r\n## How was this patch tested?\r\n\r\nunit test"},"comment":{"url":"https://api.github.com/repos/apache/spark/issues/comments/391155201","html_url":"https://github.com/apache/spark/pull/21401#issuecomment-391155201","issue_url":"https://api.github.com/repos/apache/spark/issues/21401","id":391155201,"user":{"login":"wajda","id":795479,"avatar_url":"https://avatars3.githubusercontent.com/u/795479?v=4","gravatar_id":"","url":"https://api.github.com/users/wajda","html_url":"https://github.com/wajda","followers_url":"https://api.github.com/users/wajda/followers","following_url":"https://api.github.com/users/wajda/following{/other_user}","gists_url":"https://api.github.com/users/wajda/gists{/gist_id}","starred_url":"https://api.github.com/users/wajda/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wajda/subscriptions","organizations_url":"https://api.github.com/users/wajda/orgs","repos_url":"https://api.github.com/users/wajda/repos","events_url":"https://api.github.com/users/wajda/events{/privacy}","received_events_url":"https://api.github.com/users/wajda/received_events","type":"User","site_admin":false},"created_at":"2018-05-22T22:02:28Z","updated_at":"2018-05-22T22:02:28Z","author_association":"CONTRIBUTOR","body":"retest this please"}}
{"actor":{"display_login":"wajda"}}