{"action":"created","issue":{"url":"https://api.github.com/repos/apache/spark/issues/6405","labels_url":"https://api.github.com/repos/apache/spark/issues/6405/labels{/name}","comments_url":"https://api.github.com/repos/apache/spark/issues/6405/comments","events_url":"https://api.github.com/repos/apache/spark/issues/6405/events","html_url":"https://github.com/apache/spark/pull/6405","id":80852207,"number":6405,"title":"[WIP][SPARK-7562][SPARK-6444][SQL] Improve error reporting for expression data type mismatch","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},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":42,"created_at":"2015-05-26T08:14:29Z","updated_at":"2015-05-28T11:32:32Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/apache/spark/pulls/6405","html_url":"https://github.com/apache/spark/pull/6405","diff_url":"https://github.com/apache/spark/pull/6405.diff","patch_url":"https://github.com/apache/spark/pull/6405.patch"},"body":"It seems hard to find a common pattern of checking types in `Expression`. Sometimes we know what input types we need(like `And`, we know we need two booleans), sometimes we just have some rules(like `Add`, we need 2 numeric types which are equal). So I defined a very general interface `checkInputDataTypes` which returns a `TypeCheckResult` . I'm still seeking a better generalization.\r\n\r\nThis PR mainly works on apply input types checking for arithmetic and predicate expressions.\r\n\r\nI also abstracted some common patterns to reduce code size:\r\n* abstract the usage of getting a `Numeric[Any]` or `Ordering[Any]`\r\n* abstract the type check for numeric, bitwise, ordering, etc.\r\n\r\nTODO:\r\n* When detect data types mismatch, we may need to do type casting(`ExpectsInputTypes` defines the casting behavior). Should we generalize it?\r\n* docs and tests."},"comment":{"url":"https://api.github.com/repos/apache/spark/issues/comments/106285146","html_url":"https://github.com/apache/spark/pull/6405#issuecomment-106285146","issue_url":"https://api.github.com/repos/apache/spark/issues/6405","id":106285146,"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":"2015-05-28T11:32:32Z","updated_at":"2015-05-28T11:32:32Z","body":"Test PASSed.\nRefer to this link for build results (access rights to CI server needed): \nhttps://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/33655/\nTest PASSed."}}