{"action":"created","issue":{"url":"https://api.github.com/repos/tidyverse/dbplyr/issues/108","repository_url":"https://api.github.com/repos/tidyverse/dbplyr","labels_url":"https://api.github.com/repos/tidyverse/dbplyr/issues/108/labels{/name}","comments_url":"https://api.github.com/repos/tidyverse/dbplyr/issues/108/comments","events_url":"https://api.github.com/repos/tidyverse/dbplyr/issues/108/events","html_url":"https://github.com/tidyverse/dbplyr/issues/108","id":335363695,"node_id":"MDU6SXNzdWUzMzUzNjM2OTU=","number":108,"title":"dbplyr does not translate base R integer division %/%","user":{"login":"move[bot]","id":33596368,"node_id":"MDM6Qm90MzM1OTYzNjg=","avatar_url":"https://avatars1.githubusercontent.com/in/6673?v=4","gravatar_id":"","url":"https://api.github.com/users/move%5Bbot%5D","html_url":"https://github.com/apps/move","followers_url":"https://api.github.com/users/move%5Bbot%5D/followers","following_url":"https://api.github.com/users/move%5Bbot%5D/following{/other_user}","gists_url":"https://api.github.com/users/move%5Bbot%5D/gists{/gist_id}","starred_url":"https://api.github.com/users/move%5Bbot%5D/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/move%5Bbot%5D/subscriptions","organizations_url":"https://api.github.com/users/move%5Bbot%5D/orgs","repos_url":"https://api.github.com/users/move%5Bbot%5D/repos","events_url":"https://api.github.com/users/move%5Bbot%5D/events{/privacy}","received_events_url":"https://api.github.com/users/move%5Bbot%5D/received_events","type":"Bot","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2018-06-25T11:19:08Z","updated_at":"2018-06-25T11:19:14Z","closed_at":null,"author_association":"NONE","body":"*@emilyriederer commented on Aug 27, 2017, 7:16 PM UTC:*\n\nBase R integer division (%/%) is translated to normal division (/) in SQL.\n\nApologies for non-reprex. I couldn't think of a way to get around the fact that a user must establish a connection to get this to run. When run connected to a AWS Redshift DB, data$z contains values 0, 1, and 2 while data_db$z contains floating point values.\n\nThe cause is that %/% is translated as / without accounting for integer-format. One correct SQL translation (at least for Redshift) would be CAST(\"x\"/5 AS INTEGER) or FLOOR(\"x\"/5)\n\n```r\nlibrary(dplyr)\n\ndata <- data.frame(x=as.integer(1:10))\ndata_db <- copy_to(con, data, \"data_db\", temporary = FALSE)\n\ndata <- mutate(data, z = x %/% 5)\ndata_db <- mutate(data_db, z = x %/% 5)\n\ndata\ncollect(data_db)\n\nshow_query(data_db)\n```\n\n*This issue was moved by [krlmlr](https://github.com/krlmlr) from tidyverse/dplyr/issues/3057.*"},"comment":{"url":"https://api.github.com/repos/tidyverse/dbplyr/issues/comments/399917774","html_url":"https://github.com/tidyverse/dbplyr/issues/108#issuecomment-399917774","issue_url":"https://api.github.com/repos/tidyverse/dbplyr/issues/108","id":399917774,"node_id":"MDEyOklzc3VlQ29tbWVudDM5OTkxNzc3NA==","user":{"login":"move[bot]","id":33596368,"node_id":"MDM6Qm90MzM1OTYzNjg=","avatar_url":"https://avatars1.githubusercontent.com/in/6673?v=4","gravatar_id":"","url":"https://api.github.com/users/move%5Bbot%5D","html_url":"https://github.com/apps/move","followers_url":"https://api.github.com/users/move%5Bbot%5D/followers","following_url":"https://api.github.com/users/move%5Bbot%5D/following{/other_user}","gists_url":"https://api.github.com/users/move%5Bbot%5D/gists{/gist_id}","starred_url":"https://api.github.com/users/move%5Bbot%5D/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/move%5Bbot%5D/subscriptions","organizations_url":"https://api.github.com/users/move%5Bbot%5D/orgs","repos_url":"https://api.github.com/users/move%5Bbot%5D/repos","events_url":"https://api.github.com/users/move%5Bbot%5D/events{/privacy}","received_events_url":"https://api.github.com/users/move%5Bbot%5D/received_events","type":"Bot","site_admin":false},"created_at":"2018-06-25T11:19:14Z","updated_at":"2018-06-25T11:19:14Z","author_association":"NONE","body":"*@hadley commented on Oct 23, 2017, 4:46 PM UTC:*\n\nTo make equivalent to `1 %/% 0.2` will probably need to implement via modulo arithmetic.\n\n```\nx == (x %/% m) * m + (x %% m)  \nx %/% m == (x - (x %% m)) / m\n\n```"}}
{"actor":{"display_login":"move"}}