{"action":"created","issue":{"url":"https://api.github.com/repos/cloudera/ibis/issues/772","labels_url":"https://api.github.com/repos/cloudera/ibis/issues/772/labels{/name}","comments_url":"https://api.github.com/repos/cloudera/ibis/issues/772/comments","events_url":"https://api.github.com/repos/cloudera/ibis/issues/772/events","html_url":"https://github.com/cloudera/ibis/issues/772","id":124859717,"number":772,"title":"timestamp truncation switches 'J' and 'D'","user":{"login":"tsdlovell","id":16540200,"avatar_url":"https://avatars.githubusercontent.com/u/16540200?v=3","gravatar_id":"","url":"https://api.github.com/users/tsdlovell","html_url":"https://github.com/tsdlovell","followers_url":"https://api.github.com/users/tsdlovell/followers","following_url":"https://api.github.com/users/tsdlovell/following{/other_user}","gists_url":"https://api.github.com/users/tsdlovell/gists{/gist_id}","starred_url":"https://api.github.com/users/tsdlovell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tsdlovell/subscriptions","organizations_url":"https://api.github.com/users/tsdlovell/orgs","repos_url":"https://api.github.com/users/tsdlovell/repos","events_url":"https://api.github.com/users/tsdlovell/events{/privacy}","received_events_url":"https://api.github.com/users/tsdlovell/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/cloudera/ibis/labels/documentation","name":"documentation","color":"444444"}],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/cloudera/ibis/milestones/13","html_url":"https://github.com/cloudera/ibis/milestones/0.6.1","labels_url":"https://api.github.com/repos/cloudera/ibis/milestones/13/labels","id":1434680,"number":13,"title":"0.6.1","description":"","creator":{"login":"wesm","id":329591,"avatar_url":"https://avatars.githubusercontent.com/u/329591?v=3","gravatar_id":"","url":"https://api.github.com/users/wesm","html_url":"https://github.com/wesm","followers_url":"https://api.github.com/users/wesm/followers","following_url":"https://api.github.com/users/wesm/following{/other_user}","gists_url":"https://api.github.com/users/wesm/gists{/gist_id}","starred_url":"https://api.github.com/users/wesm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wesm/subscriptions","organizations_url":"https://api.github.com/users/wesm/orgs","repos_url":"https://api.github.com/users/wesm/repos","events_url":"https://api.github.com/users/wesm/events{/privacy}","received_events_url":"https://api.github.com/users/wesm/received_events","type":"User","site_admin":false},"open_issues":9,"closed_issues":5,"state":"open","created_at":"2015-11-30T08:30:40Z","updated_at":"2016-01-13T03:49:22Z","due_on":"2016-01-15T08:00:00Z","closed_at":null},"comments":2,"created_at":"2016-01-04T23:06:37Z","updated_at":"2016-01-13T03:51:53Z","closed_at":null,"body":"In a way that probably violates expectations of users of impala and oracle\r\n\r\nibis.impala.compiler._truncate does [this](https://github.com/cloudera/ibis/blob/master/ibis/impala/compiler.py#L946-L947)\r\n\r\n``` python\r\n    _impala_unit_names = {\r\n        'M': 'MONTH',\r\n        'D': 'J',\r\n        'J': 'D',\r\n        'H': 'HH'\r\n    }\r\n```\r\n\r\nIf I execute against an impala client I see\r\n```\r\nIn [3]: client.raw_sql('select trunc(\"2015-01-01 04:00:00\", \"D\")', True).fetchall()\r\nOut[3]: [(datetime.datetime(2014, 12, 29, 0, 0),)]\r\n\r\nIn [4]: ibis.timestamp(\"2015-01-01 04:00:00\").truncate(\"D\").execute()\r\nOut[4]: Timestamp('2015-01-01 00:00:00')\r\n\r\nIn [5]: client.raw_sql('select trunc(\"2015-01-01 04:00:00\", \"J\")', True).fetchall()\r\nOut[5]: [(datetime.datetime(2015, 1, 1, 0, 0),)]\r\n\r\nIn [6]: ibis.timestamp(\"2015-01-01 04:00:00\").truncate(\"J\").execute()\r\nOut[6]: Timestamp('2014-12-29 00:00:00')\r\n```"},"comment":{"url":"https://api.github.com/repos/cloudera/ibis/issues/comments/171154003","html_url":"https://github.com/cloudera/ibis/issues/772#issuecomment-171154003","issue_url":"https://api.github.com/repos/cloudera/ibis/issues/772","id":171154003,"user":{"login":"wesm","id":329591,"avatar_url":"https://avatars.githubusercontent.com/u/329591?v=3","gravatar_id":"","url":"https://api.github.com/users/wesm","html_url":"https://github.com/wesm","followers_url":"https://api.github.com/users/wesm/followers","following_url":"https://api.github.com/users/wesm/following{/other_user}","gists_url":"https://api.github.com/users/wesm/gists{/gist_id}","starred_url":"https://api.github.com/users/wesm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wesm/subscriptions","organizations_url":"https://api.github.com/users/wesm/orgs","repos_url":"https://api.github.com/users/wesm/repos","events_url":"https://api.github.com/users/wesm/events{/privacy}","received_events_url":"https://api.github.com/users/wesm/received_events","type":"User","site_admin":false},"created_at":"2016-01-13T03:51:53Z","updated_at":"2016-01-13T03:51:53Z","body":"In general, I'd like for the spirit of Ibis to be making sensible decisions around the generic expression API without feeling pressure to conform to legacy issues in the database implementations. Impala uses the Oracle convention probably because of legacy code portability. If it becomes an issue we could always add a compatibility API that behaves like Impala or Oracle.\r\n\r\nI marked this for 0.6.1 to make sure the docstrings are clear about what the behavior is."}}