{"action":"created","issue":{"url":"https://api.github.com/repos/apache/spark/issues/4472","labels_url":"https://api.github.com/repos/apache/spark/issues/4472/labels{/name}","comments_url":"https://api.github.com/repos/apache/spark/issues/4472/comments","events_url":"https://api.github.com/repos/apache/spark/issues/4472/events","html_url":"https://github.com/apache/spark/pull/4472","id":57024114,"number":4472,"title":"[SQL] Optimize arithmetic and predicate operators","user":{"login":"kai-zeng","id":8623633,"avatar_url":"https://avatars.githubusercontent.com/u/8623633?v=3","gravatar_id":"","url":"https://api.github.com/users/kai-zeng","html_url":"https://github.com/kai-zeng","followers_url":"https://api.github.com/users/kai-zeng/followers","following_url":"https://api.github.com/users/kai-zeng/following{/other_user}","gists_url":"https://api.github.com/users/kai-zeng/gists{/gist_id}","starred_url":"https://api.github.com/users/kai-zeng/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kai-zeng/subscriptions","organizations_url":"https://api.github.com/users/kai-zeng/orgs","repos_url":"https://api.github.com/users/kai-zeng/repos","events_url":"https://api.github.com/users/kai-zeng/events{/privacy}","received_events_url":"https://api.github.com/users/kai-zeng/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":25,"created_at":"2015-02-09T12:25:21Z","updated_at":"2015-02-16T09:13:11Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/apache/spark/pulls/4472","html_url":"https://github.com/apache/spark/pull/4472","diff_url":"https://github.com/apache/spark/pull/4472.diff","patch_url":"https://github.com/apache/spark/pull/4472.patch"},"body":"Existing implementation of arithmetic operators and BinaryComparison operators have redundant type checking codes, e.g.:\r\nExpression.n2 is used by Add/Subtract/Multiply.\r\n(1) n2 always checks left.dataType == right.dataType. However, this checking should be done once when we resolve expression types;\r\n(2) n2 requires dataType is a NumericType. This can be done once.\r\n\r\nThis PR optimizes arithmetic and predicate operators by removing such redundant type-checking codes.\r\n\r\nSome preliminary benchmarking on 10G TPC-H data over 5 r3.2xlarge EC2 machines shows that this PR can reduce the query time by 5.5% to 11%.\r\nThe benchmark queries follow the template below, where OP is plus/minus/times/divide/remainder/bitwise and/bitwise or/bitwise xor.\r\n\r\nSELECT l_returnflag,  l_linestatus, SUM(l_quantity OP cnt1), SUM(l_quantity OP cnt2), ...., SUM(l_quantity OP cnt700)\r\nFROM (\r\n    SELECT l_returnflag, l_linestatus, l_quantity, 1 AS cnt1, 2 AS cnt2, ..., 700 AS cnt700\r\n    FROM lineitem\r\n    WHERE l_shipdate <= '1998-09-01'\r\n)\r\nGROUP BY l_returnflag,  l_linestatus;"},"comment":{"url":"https://api.github.com/repos/apache/spark/issues/comments/74478451","html_url":"https://github.com/apache/spark/pull/4472#issuecomment-74478451","issue_url":"https://api.github.com/repos/apache/spark/issues/4472","id":74478451,"user":{"login":"kai-zeng","id":8623633,"avatar_url":"https://avatars.githubusercontent.com/u/8623633?v=3","gravatar_id":"","url":"https://api.github.com/users/kai-zeng","html_url":"https://github.com/kai-zeng","followers_url":"https://api.github.com/users/kai-zeng/followers","following_url":"https://api.github.com/users/kai-zeng/following{/other_user}","gists_url":"https://api.github.com/users/kai-zeng/gists{/gist_id}","starred_url":"https://api.github.com/users/kai-zeng/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kai-zeng/subscriptions","organizations_url":"https://api.github.com/users/kai-zeng/orgs","repos_url":"https://api.github.com/users/kai-zeng/repos","events_url":"https://api.github.com/users/kai-zeng/events{/privacy}","received_events_url":"https://api.github.com/users/kai-zeng/received_events","type":"User","site_admin":false},"created_at":"2015-02-16T09:13:11Z","updated_at":"2015-02-16T09:13:11Z","body":"@chenghao-intel you mean revert aggregates.scala to executable?"}}