{"database": "github", "table": "issues", "is_view": false, "human_description_en": "where \"closed_at\" is on date 2024-02-05, state_reason = \"completed\" and user = 35968931 sorted by updated_at descending", "rows": [[2098882374, "I_kwDOAMm_X859GmdG", 8660, "dtype encoding ignored during IO?", 35968931, "closed", 0, null, null, 3, "2024-01-24T18:50:47Z", "2024-02-05T17:35:03Z", "2024-02-05T17:35:02Z", "MEMBER", null, null, null, "### What happened?\n\nWhen I set the `.encoding['dtype']` attribute before saving a to disk, the actual on-disk representation appears to store a record of the dtype encoding, but when opening it back up in xarray I get the same dtype I had before, not the one specified in the encoding. Is that what's supposed to happen? How does this work? (This happens with both zarr and netCDF.)\n\n### What did you expect to happen?\n\nI expected that setting `.encoding['dtype']` would mean that once I open the data back up, it would be in the new dtype that I set in the encoding.\n\n### Minimal Complete Verifiable Example\n\n```Python\nair = xr.tutorial.open_dataset('air_temperature')\r\n\r\nair['air'].dtype  # returns dtype('float32')\r\n\r\nair['air'].encoding['dtype']  # returns dtype('int16'), which already seems weird\r\n\r\nair.to_zarr('air.zarr')  # I would assume here that the encoding actually does something during IO\r\n\r\n# now if I check the zarr `.zarray` metadata for the `air` variable it says \r\n`\"dtype\": `\"<i2\"`\r\n\r\nair2 = xr.open_dataset('air.zarr', engine='zarr')  # open it back up\r\n\r\nair2['air'].dtype  # returns dtype('float32'), but I expected dtype('int16')\r\n\r\n\r\n(the same thing happens also with saving to netCDF instead of Zarr)\n```\n\n\n### MVCE confirmation\n\n- [X] Minimal example \u2014 the example is as focused as reasonably possible to demonstrate the underlying issue in xarray.\n- [X] Complete example \u2014 the example is self-contained, including all data and the text of any traceback.\n- [X] Verifiable example \u2014 the example copy & pastes into an IPython prompt or [Binder notebook](https://mybinder.org/v2/gh/pydata/xarray/main?urlpath=lab/tree/doc/examples/blank_template.ipynb), returning the result.\n- [X] New issue \u2014 a search of GitHub Issues suggests this is not a duplicate.\n- [X] Recent environment \u2014 the issue occurs with the latest version of xarray and its dependencies.\n\n### Relevant log output\n\n_No response_\n\n### Anything else we need to know?\n\nI know I didn't explicitly cast with `.asdtype`, but I'm still confused as to what the relation between the dtype encoding is supposed to be here.\r\n\r\nI am probably just misunderstanding how this is supposed to work, but then this is arguably a docs issue, because [here it says]( https://xarray.pydata.org/en/v2024.01.1/user-guide/io.html#scaling-and-type-conversions) \"[the encoding dtype field] controls the type of the data written on disk\", which I would have thought also affects the data you get back when you open it up again?\n\n### Environment\n\n`main` branch of xarray", "{\"url\": \"https://api.github.com/repos/pydata/xarray/issues/8660/reactions\", \"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", null, "completed", 13221727, "issue"]], "truncated": false, "filtered_table_rows_count": 1, "expanded_columns": [], "expandable_columns": [[{"column": "repo", "other_table": "repos", "other_column": "id"}, "name"], [{"column": "milestone", "other_table": "milestones", "other_column": "id"}, "title"], [{"column": "assignee", "other_table": "users", "other_column": "id"}, "login"], [{"column": "user", "other_table": "users", "other_column": "id"}, "login"]], "columns": ["id", "node_id", "number", "title", "user", "state", "locked", "assignee", "milestone", "comments", "created_at", "updated_at", "closed_at", "author_association", "active_lock_reason", "draft", "pull_request", "body", "reactions", "performed_via_github_app", "state_reason", "repo", "type"], "primary_keys": ["id"], "units": {}, "query": {"sql": "select id, node_id, number, title, user, state, locked, assignee, milestone, comments, created_at, updated_at, closed_at, author_association, active_lock_reason, draft, pull_request, body, reactions, performed_via_github_app, state_reason, repo, type from issues where date(\"closed_at\") = :p0 and \"state_reason\" = :p1 and \"user\" = :p2 order by updated_at desc limit 101", "params": {"p0": "2024-02-05", "p1": "completed", "p2": "35968931"}}, "facet_results": {"state": {"name": "state", "type": "column", "hideable": false, "toggle_url": "/github/issues.json?closed_at__date=2024-02-05&state_reason=completed&user=35968931", "results": [{"value": "closed", "label": "closed", "count": 1, "toggle_url": "http://xarray-datasette.fly.dev/github/issues.json?closed_at__date=2024-02-05&state_reason=completed&user=35968931&state=closed", "selected": false}], "truncated": false}, "repo": {"name": "repo", "type": "column", "hideable": false, "toggle_url": "/github/issues.json?closed_at__date=2024-02-05&state_reason=completed&user=35968931", "results": [{"value": 13221727, "label": "xarray", "count": 1, "toggle_url": "http://xarray-datasette.fly.dev/github/issues.json?closed_at__date=2024-02-05&state_reason=completed&user=35968931&repo=13221727", "selected": false}], "truncated": false}, "type": {"name": "type", "type": "column", "hideable": false, "toggle_url": "/github/issues.json?closed_at__date=2024-02-05&state_reason=completed&user=35968931", "results": [{"value": "issue", "label": "issue", "count": 1, "toggle_url": "http://xarray-datasette.fly.dev/github/issues.json?closed_at__date=2024-02-05&state_reason=completed&user=35968931&type=issue", "selected": false}], "truncated": false}}, "suggested_facets": [{"name": "created_at", "type": "date", "toggle_url": "http://xarray-datasette.fly.dev/github/issues.json?closed_at__date=2024-02-05&state_reason=completed&user=35968931&_facet_date=created_at"}, {"name": "updated_at", "type": "date", "toggle_url": "http://xarray-datasette.fly.dev/github/issues.json?closed_at__date=2024-02-05&state_reason=completed&user=35968931&_facet_date=updated_at"}, {"name": "closed_at", "type": "date", "toggle_url": "http://xarray-datasette.fly.dev/github/issues.json?closed_at__date=2024-02-05&state_reason=completed&user=35968931&_facet_date=closed_at"}], "next": null, "next_url": null, "private": false, "allow_execute_sql": true, "query_ms": 33.338762819767}