{"action":"created","issue":{"url":"https://api.github.com/repos/pingcap/tispark/issues/498","repository_url":"https://api.github.com/repos/pingcap/tispark","labels_url":"https://api.github.com/repos/pingcap/tispark/issues/498/labels{/name}","comments_url":"https://api.github.com/repos/pingcap/tispark/issues/498/comments","events_url":"https://api.github.com/repos/pingcap/tispark/issues/498/events","html_url":"https://github.com/pingcap/tispark/pull/498","id":383993943,"node_id":"MDExOlB1bGxSZXF1ZXN0MjMzMzIyNTk1","number":498,"title":"Add special sum without null initial value","user":{"login":"ilovesoup","id":3347719,"node_id":"MDQ6VXNlcjMzNDc3MTk=","avatar_url":"https://avatars2.githubusercontent.com/u/3347719?v=4","gravatar_id":"","url":"https://api.github.com/users/ilovesoup","html_url":"https://github.com/ilovesoup","followers_url":"https://api.github.com/users/ilovesoup/followers","following_url":"https://api.github.com/users/ilovesoup/following{/other_user}","gists_url":"https://api.github.com/users/ilovesoup/gists{/gist_id}","starred_url":"https://api.github.com/users/ilovesoup/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ilovesoup/subscriptions","organizations_url":"https://api.github.com/users/ilovesoup/orgs","repos_url":"https://api.github.com/users/ilovesoup/repos","events_url":"https://api.github.com/users/ilovesoup/events{/privacy}","received_events_url":"https://api.github.com/users/ilovesoup/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-11-24T14:27:57Z","updated_at":"2018-11-26T08:08:58Z","closed_at":null,"author_association":"COLLABORATOR","pull_request":{"url":"https://api.github.com/repos/pingcap/tispark/pulls/498","html_url":"https://github.com/pingcap/tispark/pull/498","diff_url":"https://github.com/pingcap/tispark/pull/498.diff","patch_url":"https://github.com/pingcap/tispark/pull/498.patch"},"body":"Previously count on empty table break in Spark 2.3.\r\nThis is because:\r\n1. Count is rewrite into Sum of count value from coproc.\r\n2. Sum on empty records in SQL is initialized into null.\r\n3. Count is not nullable in SQL and thus when rewritten into Sum nullable flag is carried.\r\n4. Spark's codegen will not guard on null value and only when forced to String (when using show instead of collect) will throw. If return schema is int it will return 0 normally. \r\n5. Spark 2.3 changed plan of Dataset.show into cast(sum as string) and then NPE encountered.\r\n\r\nNow we change Sum into 0 initialized if it is to replace count in TiSpark.\n\n<!-- Reviewable:start -->\n---\nThis change is [<img src=\"https://reviewable.io/review_button.svg\" height=\"34\" align=\"absmiddle\" alt=\"Reviewable\"/>](https://reviewable.io/reviews/pingcap/tispark/498)\n<!-- Reviewable:end -->\n"},"comment":{"url":"https://api.github.com/repos/pingcap/tispark/issues/comments/441551095","html_url":"https://github.com/pingcap/tispark/pull/498#issuecomment-441551095","issue_url":"https://api.github.com/repos/pingcap/tispark/issues/498","id":441551095,"node_id":"MDEyOklzc3VlQ29tbWVudDQ0MTU1MTA5NQ==","user":{"login":"birdstorm","id":15857134,"node_id":"MDQ6VXNlcjE1ODU3MTM0","avatar_url":"https://avatars1.githubusercontent.com/u/15857134?v=4","gravatar_id":"","url":"https://api.github.com/users/birdstorm","html_url":"https://github.com/birdstorm","followers_url":"https://api.github.com/users/birdstorm/followers","following_url":"https://api.github.com/users/birdstorm/following{/other_user}","gists_url":"https://api.github.com/users/birdstorm/gists{/gist_id}","starred_url":"https://api.github.com/users/birdstorm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/birdstorm/subscriptions","organizations_url":"https://api.github.com/users/birdstorm/orgs","repos_url":"https://api.github.com/users/birdstorm/repos","events_url":"https://api.github.com/users/birdstorm/events{/privacy}","received_events_url":"https://api.github.com/users/birdstorm/received_events","type":"User","site_admin":false},"created_at":"2018-11-26T08:08:58Z","updated_at":"2018-11-26T08:08:58Z","author_association":"MEMBER","body":"/run-all-tests"}}
{"actor":{"display_login":"birdstorm"}}