Repository: pydata/xarray

Issue:
Decoding non-utf-8 encoded strings with the h5netcdf engine
**What happened**:
Trying to load a netCDF file-like (`io.BytesIO` object) with attribute strings in non-utf-8 encoding with the `h5netcdf` engine leads to `UnicodeDecodeError`.

**What you expected to happen**:
Loading the same file, albeit persisted to disk, with the `netcdf4` engine works fine, however, since the `netcdf4` engine doesnt support the file-like objects I ran into this issue. 

**Traceback**:
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/thns/.venv/cmems/lib/python3.8/site-packages/xarray/backends/api.py", line 242, in load_dataset
    with open_dataset(filename_or_obj, **kwargs) as ds:
  File "/home/thns/.venv/cmems/lib/python3.8/site-packages/xarray/backends/api.py", line 496, in open_dataset
    backend_ds = backend.open_dataset(
  File "/home/thns/.venv/cmems/lib/python3.8/site-packages/xarray/backends/h5netcdf_.py", line 384, in open_dataset
    ds = store_entrypoint.open_dataset(
  File "/home/thns/.venv/cmems/lib/python3.8/site-packages/xarray/backends/store.py", line 22, in open_dataset
    vars, attrs = store.load()
  File "/home/thns/.venv/cmems/lib/python3.8/site-packages/xarray/backends/common.py", line 126, in load
    attributes = FrozenDict(self.get_attrs())
  File "/home/thns/.venv/cmems/lib/python3.8/site-packages/xarray/backends/h5netcdf_.py", line 234, in get_attrs
    return FrozenDict(_read_attributes(self.ds))
  File "/home/thns/.venv/cmems/lib/python3.8/site-packages/xarray/backends/h5netcdf_.py", line 75, in _read_attributes
    v = maybe_decode_bytes(v)
  File "/home/thns/.venv/cmems/lib/python3.8/site-packages/xarray/backends/h5netcdf_.py", line 63, in maybe_decode_bytes
    return txt.decode("utf-8")

**Minimal Complete Verifiable Example**:

```python
import xarray as xr
import netCDF4

title = b'\xc3'

f = netCDF4.Dataset('test.nc', 'w')
f.title = title
f.close()
xr.load_dataset("test.nc", engine="h5netcdf")
```

**Environment**:

<details><summary>Output of <tt>xr.show_versions()</tt></summary>

<!-- Paste the output here xr.show_versions() here -->
INSTALLED VERSIONS
------------------
commit: None
python: 3.8.0 (default, Feb 25 2021, 22:10:10)
[GCC 8.4.0]
python-bits: 64
OS: Linux
OS-release: 4.15.0-136-generic
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
LOCALE: ('en_US', 'UTF-8')
libhdf5: 1.12.0
libnetcdf: 4.7.4

xarray: 0.18.1
pandas: 1.2.4
numpy: 1.20.3
scipy: None
netCDF4: 1.5.6
pydap: None
h5netcdf: 0.11.0
h5py: 3.2.1
Nio: None
zarr: None
cftime: 1.4.1
nc_time_axis: None
PseudoNetCDF: None
rasterio: None
cfgrib: None
iris: None
bottleneck: None
dask: None
distributed: None
matplotlib: None
cartopy: None
seaborn: None
numbagg: None
pint: None
setuptools: 57.0.0
pip: 21.1.3
conda: None
pytest: 6.2.4
IPython: 7.25.0
sphinx: None

</details>


Discussion:

Patch:
diff --git a/doc/user-guide/indexing.rst b/doc/user-guide/indexing.rst
index fba9dd58..0f575160 100644
--- a/doc/user-guide/indexing.rst
+++ b/doc/user-guide/indexing.rst
@@ -748,7 +748,7 @@ Whether array indexing returns a view or a copy of the underlying
 data depends on the nature of the labels.
 
 For positional (integer)
-indexing, xarray follows the same rules as NumPy:
+indexing, xarray follows the same `rules`_ as NumPy:
 
 * Positional indexing with only integers and slices returns a view.
 * Positional indexing with arrays or lists returns a copy.
@@ -765,8 +765,10 @@ Whether data is a copy or a view is more predictable in xarray than in pandas, s
 unlike pandas, xarray does not produce `SettingWithCopy warnings`_. However, you
 should still avoid assignment with chained indexing.
 
-.. _SettingWithCopy warnings: https://pandas.pydata.org/pandas-docs/stable/indexing.html#returning-a-view-versus-a-copy
+Note that other operations (such as :py:meth:`~xarray.DataArray.values`) may also return views rather than copies.
 
+.. _SettingWithCopy warnings: https://pandas.pydata.org/pandas-docs/stable/indexing.html#returning-a-view-versus-a-copy
+.. _rules: https://numpy.org/doc/stable/user/basics.copies.html
 
 .. _multi-level indexing:
 
diff --git a/doc/whats-new.rst b/doc/whats-new.rst
index c1bfaba8..08016f18 100644
--- a/doc/whats-new.rst
+++ b/doc/whats-new.rst
@@ -23,17 +23,20 @@ v2024.03.0 (unreleased)
 New Features
 ~~~~~~~~~~~~
 
+- Grouped and resampling quantile calculations now use the vectorized algorithm in ``flox>=0.9.4`` if present.
+  By `Deepak Cherian <https://github.com/dcherian>`_.
 - Do not broadcast in arithmetic operations when global option ``arithmetic_broadcast=False``
   (:issue:`6806`, :pull:`8784`).
   By `Etienne Schalk <https://github.com/etienneschalk>`_ and `Deepak Cherian <https://github.com/dcherian>`_.
 - Add the ``.oindex`` property to Explicitly Indexed Arrays for orthogonal indexing functionality. (:issue:`8238`, :pull:`8750`)
   By `Anderson Banihirwe <https://github.com/andersy005>`_.
-
 - Add the ``.vindex`` property to Explicitly Indexed Arrays for vectorized indexing functionality. (:issue:`8238`, :pull:`8780`)
   By `Anderson Banihirwe <https://github.com/andersy005>`_.
-
 - Expand use of ``.oindex`` and ``.vindex`` properties. (:pull: `8790`)
   By `Anderson Banihirwe <https://github.com/andersy005>`_ and `Deepak Cherian <https://github.com/dcherian>`_.
+- Allow creating :py:class:`xr.Coordinates` objects with no indexes (:pull:`8711`)
+  By `Benoit Bovy <https://github.com/benbovy>`_ and `Tom Nicholas
+  <https://github.com/TomNicholas>`_.
 
 Breaking changes
 ~~~~~~~~~~~~~~~~
@@ -57,15 +60,17 @@ Bug fixes
   `CFMaskCoder`/`CFScaleOffsetCoder` (:issue:`2304`, :issue:`5597`,
   :issue:`7691`, :pull:`8713`, see also discussion in :pull:`7654`).
   By `Kai Mühlbauer <https://github.com/kmuehlbauer>`_.
-- do not cast `_FillValue`/`missing_value` in `CFMaskCoder` if `_Unsigned` is provided
+- Do not cast `_FillValue`/`missing_value` in `CFMaskCoder` if `_Unsigned` is provided
   (:issue:`8844`, :pull:`8852`).
 - Adapt handling of copy keyword argument for numpy >= 2.0dev
-  (:issue:`8844`, :pull:`8851`, :pull:`8865``).
+  (:issue:`8844`, :pull:`8851`, :pull:`8865`).
   By `Kai Mühlbauer <https://github.com/kmuehlbauer>`_.
-- import trapz/trapezoid depending on numpy version.
+- Import trapz/trapezoid depending on numpy version
   (:issue:`8844`, :pull:`8865`).
   By `Kai Mühlbauer <https://github.com/kmuehlbauer>`_.
-
+- Warn and return bytes undecoded in case of UnicodeDecodeError in h5netcdf-backend
+  (:issue:`5563`, :pull:`8874`).
+  By `Kai Mühlbauer <https://github.com/kmuehlbauer>`_.
 
 
 Documentation
diff --git a/xarray/backends/h5netcdf_.py b/xarray/backends/h5netcdf_.py
index b7c1b2a5..81ba37f6 100644
--- a/xarray/backends/h5netcdf_.py
+++ b/xarray/backends/h5netcdf_.py
@@ -28,6 +28,7 @@ from xarray.backends.store import StoreBackendEntrypoint
 from xarray.core import indexing
 from xarray.core.utils import (
     FrozenDict,
+    emit_user_level_warning,
     is_remote_uri,
     read_magic_number_from_file,
     try_read_magic_number_from_file_or_path,
@@ -58,13 +59,6 @@ class H5NetCDFArrayWrapper(BaseNetCDF4Array):
             return array[key]
 
 
-def maybe_decode_bytes(txt):
-    if isinstance(txt, bytes):
-        return txt.decode("utf-8")
-    else:
-        return txt
-
-
 def _read_attributes(h5netcdf_var):
     # GH451
     # to ensure conventions decoding works properly on Python 3, decode all
@@ -72,7 +66,16 @@ def _read_attributes(h5netcdf_var):
     attrs = {}
     for k, v in h5netcdf_var.attrs.items():
         if k not in ["_FillValue", "missing_value"]:
-            v = maybe_decode_bytes(v)
+            if isinstance(v, bytes):
+                try:
+                    v = v.decode("utf-8")
+                except UnicodeDecodeError:
+                    emit_user_level_warning(
+                        f"'utf-8' codec can't decode bytes for attribute "
+                        f"{k!r} of h5netcdf object {h5netcdf_var.name!r}, "
+                        f"returning bytes undecoded.",
+                        UnicodeWarning,
+                    )
         attrs[k] = v
     return attrs
 
diff --git a/xarray/core/_aggregations.py b/xarray/core/_aggregations.py
index bee6afd5..96f860b3 100644
--- a/xarray/core/_aggregations.py
+++ b/xarray/core/_aggregations.py
@@ -2392,8 +2392,6 @@ class DatasetGroupByAggregations:
         Use the ``flox`` package to significantly speed up groupby computations,
         especially with dask arrays. Xarray will use flox by default if installed.
         Pass flox-specific keyword arguments in ``**kwargs``.
-        The default choice is ``method="cohorts"`` which generalizes the best,
-        other methods might work better for your problem.
         See the `flox documentation <https://flox.readthedocs.io>`_ for more.
 
         Examples
@@ -2490,8 +2488,6 @@ class DatasetGroupByAggregations:
         Use the ``flox`` package to significantly speed up groupby computations,
         especially with dask arrays. Xarray will use flox by default if installed.
         Pass flox-specific keyword arguments in ``**kwargs``.
-        The default choice is ``method="cohorts"`` which generalizes the best,
-        other methods might work better for your problem.
         See the `flox documentation <https://flox.readthedocs.io>`_ for more.
 
         Examples
@@ -2588,8 +2584,6 @@ class DatasetGroupByAggregations:
         Use the ``flox`` package to significantly speed up groupby computations,
         especially with dask arrays. Xarray will use flox by default if installed.
         Pass flox-specific keyword arguments in ``**kwargs``.
-        The default choice is ``method="cohorts"`` which generalizes the best,
-        other methods might work better for your problem.
         See the `flox documentation <https://flox.readthedocs.io>`_ for more.
 
         Examples
@@ -2692,8 +2686,6 @@ class DatasetGroupByAggregations:
         Use the ``flox`` package to significantly speed up groupby computations,
         especially with dask arrays. Xarray will use flox by default if installed.
         Pass flox-specific keyword arguments in ``**kwargs``.
-        The default choice is ``method="cohorts"`` which generalizes the best,
-        other methods might work better for your problem.
         See the `flox documentation <https://flox.readthedocs.io>`_ for more.
 
         Examples
@@ -2808,8 +2800,6 @@ class DatasetGroupByAggregations:
         Use the ``flox`` package to significantly speed up groupby computations,
         especially with dask arrays. Xarray will use flox by default if installed.
         Pass flox-specific keyword arguments in ``**kwargs``.
-        The default choice is ``method="cohorts"`` which generalizes the best,
-        other methods might work better for your problem.
         See the `flox documentation <https://flox.readthedocs.io>`_ for more.
 
         Examples
@@ -2924,8 +2914,6 @@ class DatasetGroupByAggregations:
         Use the ``flox`` package to significantly speed up groupby computations,
         especially with dask arrays. Xarray will use flox by default if installed.
         Pass flox-specific keyword arguments in ``**kwargs``.
-        The default choice is ``method="cohorts"`` which generalizes the best,
-        other methods might work better for your problem.
         See the `flox documentation <https://flox.readthedocs.io>`_ for more.
 
         Non-numeric variables will be removed prior to reducing.
@@ -3049,8 +3037,6 @@ class DatasetGroupByAggregations:
         Use the ``flox`` package to significantly speed up groupby computations,
         especially with dask arrays. Xarray will use flox by default if installed.
         Pass flox-specific keyword arguments in ``**kwargs``.
-        The default choice is ``method="cohorts"`` which generalizes the best,
-        other methods might work better for your problem.
         See the `flox documentation <https://flox.readthedocs.io>`_ for more.
 
         Non-numeric variables will be removed prior to reducing.
@@ -3186,8 +3172,6 @@ class DatasetGroupByAggregations:
         Use the ``flox`` package to significantly speed up groupby computations,
         especially with dask arrays. Xarray will use flox by default if installed.
         Pass flox-specific keyword arguments in ``**kwargs``.
-        The default choice is ``method="cohorts"`` which generalizes the best,
-        other methods might work better for your problem.
         See the `flox documentation <https://flox.readthedocs.io>`_ for more.
 
         Non-numeric variables will be removed prior to reducing.
@@ -3320,8 +3304,6 @@ class DatasetGroupByAggregations:
         Use the ``flox`` package to significantly speed up groupby computations,
         especially with dask arrays. Xarray will use flox by default if installed.
         Pass flox-specific keyword arguments in ``**kwargs``.
-        The default choice is ``method="cohorts"`` which generalizes the best,
-        other methods might work better for your problem.
         See the `flox documentation <https://flox.readthedocs.io>`_ for more.
 
         Non-numeric variables will be removed prior to reducing.
@@ -3454,8 +3436,6 @@ class DatasetGroupByAggregations:
         Use the ``flox`` package to significantly speed up groupby computations,
         especially with dask arrays. Xarray will use flox by default if installed.
         Pass flox-specific keyword arguments in ``**kwargs``.
-        The default choice is ``method="cohorts"`` which generalizes the best,
-        other methods might work better for your problem.
         See the `flox documentation <https://flox.readthedocs.io>`_ for more.
 
         Non-numeric variables will be removed prior to reducing.
@@ -3584,8 +3564,6 @@ class DatasetGroupByAggregations:
         Use the ``flox`` package to significantly speed up groupby computations,
         especially with dask arrays. Xarray will use flox by default if installed.
         Pass flox-specific keyword arguments in ``**kwargs``.
-        The default choice is ``method="cohorts"`` which generalizes the best,
-        other methods might work better for your problem.
         See the `flox documentation <https://flox.readthedocs.io>`_ for more.
 
         Non-numeric variables will be removed prior to reducing.
@@ -3687,8 +3665,6 @@ class DatasetGroupByAggregations:
         Use the ``flox`` package to significantly speed up groupby computations,
         especially with dask arrays. Xarray will use flox by default if installed.
         Pass flox-specific keyword arguments in ``**kwargs``.
-        The default choice is ``method="cohorts"`` which generalizes the best,
-        other methods might work better for your problem.
         See the `flox documentation <https://flox.readthedocs.io>`_ for more.
 
         Non-numeric variables will be removed prior to reducing.
@@ -3788,8 +3764,6 @@ class DatasetGroupByAggregations:
         Use the ``flox`` package to significantly speed up groupby computations,
         especially with dask arrays. Xarray will use flox by default if installed.
         Pass flox-specific keyword arguments in ``**kwargs``.
-        The default choice is ``method="cohorts"`` which generalizes the best,
-        other methods might work better for your problem.
         See the `flox documentation <https://flox.readthedocs.io>`_ for more.
 
         Non-numeric variables will be removed prior to reducing.
@@ -3919,8 +3893,6 @@ class DatasetResampleAggregations:
         Use the ``flox`` package to significantly speed up resampling computations,
         especially with dask arrays. Xarray will use flox by default if installed.
         Pass flox-specific keyword arguments in ``**kwargs``.
-        The default choice is ``method="cohorts"`` which generalizes the best,
-        ``method="blockwise"`` might work better for your problem.
         See the `flox documentation <https://flox.readthedocs.io>`_ for more.
 
         Examples
@@ -4017,8 +3989,6 @@ class DatasetResampleAggregations:
         Use the ``flox`` package to significantly speed up resampling computations,
         especially with dask arrays. Xarray will use flox by default if installed.
         Pass flox-specific keyword arguments in ``**kwargs``.
-        The default choice is ``method="cohorts"`` which generalizes the best,
-        ``method="blockwise"`` might work better for your problem.
         See the `flox documentation <https://flox.readthedocs.io>`_ for more.
 
         Examples
@@ -4115,8 +4085,6 @@ class DatasetResampleAggregations:
         Use the ``flox`` package to significantly speed up resampling computations,
         especially with dask arrays. Xarray will use flox by default if installed.
         Pass flox-specific keyword arguments in ``**kwargs``.
-        The default choice is ``method="cohorts"`` which generalizes the best,
-        ``method="blockwise"`` might work better for your problem.
         See the `flox documentation <https://flox.readthedocs.io>`_ for more.
 
         Examples
@@ -4219,8 +4187,6 @@ class DatasetResampleAggregations:
         Use the ``flox`` package to significantly speed up resampling computations,
         especially with dask arrays. Xarray will use flox by default if installed.
         Pass flox-specific keyword arguments in ``**kwargs``.
-        The default choice is ``method="cohorts"`` which generalizes the best,
-        ``method="blockwise"`` might work better for your problem.
         See the `flox documentation <https://flox.readthedocs.io>`_ for more.
 
         Examples
@@ -4335,8 +4301,6 @@ class DatasetResampleAggregations:
         Use the ``flox`` package to significantly speed up resampling computations,
         especially with dask arrays. Xarray will use flox by default if installed.
         Pass flox-specific keyword arguments in ``**kwargs``.
-        The default choice is ``method="cohorts"`` which generalizes the best,
-        ``method="blockwise"`` might work better for your problem.
         See the `flox documentation <https://flox.readthedocs.io>`_ for more.
 
         Examples
@@ -4451,8 +4415,6 @@ class DatasetResampleAggregations:
         Use the ``flox`` package to significantly speed up resampling computations,
         especially with dask arrays. Xarray will use flox by default if installed.
         Pass flox-specific keyword arguments in ``**kwargs``.
-        The default choice is ``method="cohorts"`` which generalizes the best,
-        ``method="blockwise"`` might work better for your problem.
         See the `flox documentation <https://flox.readthedocs.io>`_ for more.
 
         Non-numeric variables will be removed prior to reducing.
@@ -4576,8 +4538,6 @@ class DatasetResampleAggregations:
         Use the ``flox`` package to significantly speed up resampling computations,
         especially with dask arrays. Xarray will use flox by default if installed.
         Pass flox-specific keyword arguments in ``**kwargs``.
-        The default choice is ``method="cohorts"`` which generalizes the best,
-        ``method="blockwise"`` might work better for your problem.
         See the `flox documentation <https://flox.readthedocs.io>`_ for more.
 
         Non-numeric variables will be removed prior to reducing.
@@ -4713,8 +4673,6 @@ class DatasetResampleAggregations:
         Use the ``flox`` package to significantly speed up resampling computations,
         especially with dask arrays. Xarray will use flox by default if installed.
         Pass flox-specific keyword arguments in ``**kwargs``.
-        The default choice is ``method="cohorts"`` which generalizes the best,
-        ``method="blockwise"`` might work better for your problem.
         See the `flox documentation <https://flox.readthedocs.io>`_ for more.
 
         Non-numeric variables will be removed prior to reducing.
@@ -4847,8 +4805,6 @@ class DatasetResampleAggregations:
         Use the ``flox`` package to significantly speed up resampling computations,
         especially with dask arrays. Xarray will use flox by default if installed.
         Pass flox-specific keyword arguments in ``**kwargs``.
-        The default choice is ``method="cohorts"`` which generalizes the best,
-        ``method="blockwise"`` might work better for your problem.
         See the `flox documentation <https://flox.readthedocs.io>`_ for more.
 
         Non-numeric variables will be removed prior to reducing.
@@ -4981,8 +4937,6 @@ class DatasetResampleAggregations:
         Use the ``flox`` package to significantly speed up resampling computations,
         especially with dask arrays. Xarray will use flox by default if installed.
         Pass flox-specific keyword arguments in ``**kwargs``.
-        The default choice is ``method="cohorts"`` which generalizes the best,
-        ``method="blockwise"`` might work better for your problem.
         See the `flox documentation <https://flox.readthedocs.io>`_ for more.
 
         Non-numeric variables will be removed prior to reducing.
@@ -5111,8 +5065,6 @@ class DatasetResampleAggregations:
         Use the ``flox`` package to significantly speed up resampling computations,
         especially with dask arrays. Xarray will use flox by default if installed.
         Pass flox-specific keyword arguments in ``**kwargs``.
-        The default choice is ``method="cohorts"`` which generalizes the best,
-        ``method="blockwise"`` might work better for your problem.
         See the `flox documentation <https://flox.readthedocs.io>`_ for more.
 
         Non-numeric variables will be removed prior to reducing.
@@ -5214,8 +5166,6 @@ class DatasetResampleAggregations:
         Use the ``flox`` package to significantly speed up resampling computations,
         especially with dask arrays. Xarray will use flox by default if installed.
         Pass flox-specific keyword arguments in ``**kwargs``.
-        The default choice is ``method="cohorts"`` which generalizes the best,
-        ``method="blockwise"`` might work better for your problem.
         See the `flox documentation <https://flox.readthedocs.io>`_ for more.
 
         Non-numeric variables will be removed prior to reducing.
@@ -5315,8 +5265,6 @@ class DatasetResampleAggregations:
         Use the ``flox`` package to significantly speed up resampling computations,
         especially with dask arrays. Xarray will use flox by default if installed.
         Pass flox-specific keyword arguments in ``**kwargs``.
-        The default choice is ``method="cohorts"`` which generalizes the best,
-        ``method="blockwise"`` might work better for your problem.
         See the `flox documentation <https://flox.readthedocs.io>`_ for more.
 
         Non-numeric variables will be removed prior to reducing.
@@ -5446,8 +5394,6 @@ class DataArrayGroupByAggregations:
         Use the ``flox`` package to significantly speed up groupby computations,
         especially with dask arrays. Xarray will use flox by default if installed.
         Pass flox-specific keyword arguments in ``**kwargs``.
-        The default choice is ``method="cohorts"`` which generalizes the best,
-        other methods might work better for your problem.
         See the `flox documentation <https://flox.readthedocs.io>`_ for more.
 
         Examples
@@ -5537,8 +5483,6 @@ class DataArrayGroupByAggregations:
         Use the ``flox`` package to significantly speed up groupby computations,
         especially with dask arrays. Xarray will use flox by default if installed.
         Pass flox-specific keyword arguments in ``**kwargs``.
-        The default choice is ``method="cohorts"`` which generalizes the best,
-        other methods might work better for your problem.
         See the `flox documentation <https://flox.readthedocs.io>`_ for more.
 
         Examples
@@ -5628,8 +5572,6 @@ class DataArrayGroupByAggregations:
         Use the ``flox`` package to significantly speed up groupby computations,
         especially with dask arrays. Xarray will use flox by default if installed.
         Pass flox-specific keyword arguments in ``**kwargs``.
-        The default choice is ``method="cohorts"`` which generalizes the best,
-        other methods might work better for your problem.
         See the `flox documentation <https://flox.readthedocs.io>`_ for more.
 
         Examples
@@ -5725,8 +5667,6 @@ class DataArrayGroupByAggregations:
         Use the ``flox`` package to significantly speed up groupby computations,
         especially with dask arrays. Xarray will use flox by default if installed.
         Pass flox-specific keyword arguments in ``**kwargs``.
-        The default choice is ``method="cohorts"`` which generalizes the best,
-        other methods might work better for your problem.
         See the `flox documentation <https://flox.readthedocs.io>`_ for more.
 
         Examples
@@ -5832,8 +5772,6 @@ class DataArrayGroupByAggregations:
         Use the ``flox`` package to significantly speed up groupby computations,
         especially with dask arrays. Xarray will use flox by default if installed.
         Pass flox-specific keyword arguments in ``**kwargs``.
-        The default choice is ``method="cohorts"`` which generalizes the best,
-        other methods might work better for your problem.
         See the `flox documentation <https://flox.readthedocs.io>`_ for more.
 
         Examples
@@ -5939,8 +5877,6 @@ class DataArrayGroupByAggregations:
         Use the ``flox`` package to significantly speed up groupby computations,
         especially with dask arrays. Xarray will use flox by default if installed.
         Pass flox-specific keyword arguments in ``**kwargs``.
-        The default choice is ``method="cohorts"`` which generalizes the best,
-        other methods might work better for your problem.
         See the `flox documentation <https://flox.readthedocs.io>`_ for more.
 
         Non-numeric variables will be removed prior to reducing.
@@ -6055,8 +5991,6 @@ class DataArrayGroupByAggregations:
         Use the ``flox`` package to significantly speed up groupby computations,
         especially with dask arrays. Xarray will use flox by default if installed.
         Pass flox-specific keyword arguments in ``**kwargs``.
-        The default choice is ``method="cohorts"`` which generalizes the best,
-        other methods might work better for your problem.
         See the `flox documentation <https://flox.readthedocs.io>`_ for more.
 
         Non-numeric variables will be removed prior to reducing.
@@ -6181,8 +6115,6 @@ class DataArrayGroupByAggregations:
         Use the ``flox`` package to significantly speed up groupby computations,
         especially with dask arrays. Xarray will use flox by default if installed.
         Pass flox-specific keyword arguments in ``**kwargs``.
-        The default choice is ``method="cohorts"`` which generalizes the best,
-        other methods might work better for your problem.
         See the `flox documentation <https://flox.readthedocs.io>`_ for more.
 
         Non-numeric variables will be removed prior to reducing.
@@ -6304,8 +6236,6 @@ class DataArrayGroupByAggregations:
         Use the ``flox`` package to significantly speed up groupby computations,
         especially with dask arrays. Xarray will use flox by default if installed.
         Pass flox-specific keyword arguments in ``**kwargs``.
-        The default choice is ``method="cohorts"`` which generalizes the best,
-        other methods might work better for your problem.
         See the `flox documentation <https://flox.readthedocs.io>`_ for more.
 
         Non-numeric variables will be removed prior to reducing.
@@ -6427,8 +6357,6 @@ class DataArrayGroupByAggregations:
         Use the ``flox`` package to significantly speed up groupby computations,
         especially with dask arrays. Xarray will use flox by default if installed.
         Pass flox-specific keyword arguments in ``**kwargs``.
-        The default choice is ``method="cohorts"`` which generalizes the best,
-        other methods might work better for your problem.
         See the `flox documentation <https://flox.readthedocs.io>`_ for more.
 
         Non-numeric variables will be removed prior to reducing.
@@ -6546,8 +6474,6 @@ class DataArrayGroupByAggregations:
         Use the ``flox`` package to significantly speed up groupby computations,
         especially with dask arrays. Xarray will use flox by default if installed.
         Pass flox-specific keyword arguments in ``**kwargs``.
-        The default choice is ``method="cohorts"`` which generalizes the best,
-        other methods might work better for your problem.
         See the `flox documentation <https://flox.readthedocs.io>`_ for more.
 
         Non-numeric variables will be removed prior to reducing.
@@ -6641,8 +6567,6 @@ class DataArrayGroupByAggregations:
         Use the ``flox`` package to significantly speed up groupby computations,
         especially with dask arrays. Xarray will use flox by default if installed.
         Pass flox-specific keyword arguments in ``**kwargs``.
-        The default choice is ``method="cohorts"`` which generalizes the best,
-        other methods might work better for your problem.
         See the `flox documentation <https://flox.readthedocs.io>`_ for more.
 
         Non-numeric variables will be removed prior to reducing.
@@ -6738,8 +6662,6 @@ class DataArrayGroupByAggregations:
         Use the ``flox`` package to significantly speed up groupby computations,
         especially with dask arrays. Xarray will use flox by default if installed.
         Pass flox-specific keyword arguments in ``**kwargs``.
-        The default choice is ``method="cohorts"`` which generalizes the best,
-        other methods might work better for your problem.
         See the `flox documentation <https://flox.readthedocs.io>`_ for more.
 
         Non-numeric variables will be removed prior to reducing.
@@ -6865,8 +6787,6 @@ class DataArrayResampleAggregations:
         Use the ``flox`` package to significantly speed up resampling computations,
         especially with dask arrays. Xarray will use flox by default if installed.
         Pass flox-specific keyword arguments in ``**kwargs``.
-        The default choice is ``method="cohorts"`` which generalizes the best,
-        ``method="blockwise"`` might work better for your problem.
         See the `flox documentation <https://flox.readthedocs.io>`_ for more.
 
         Examples
@@ -6956,8 +6876,6 @@ class DataArrayResampleAggregations:
         Use the ``flox`` package to significantly speed up resampling computations,
         especially with dask arrays. Xarray will use flox by default if installed.
         Pass flox-specific keyword arguments in ``**kwargs``.
-        The default choice is ``method="cohorts"`` which generalizes the best,
-        ``method="blockwise"`` might work better for your problem.
         See the `flox documentation <https://flox.readthedocs.io>`_ for more.
 
         Examples
@@ -7047,8 +6965,6 @@ class DataArrayResampleAggregations:
         Use the ``flox`` package to significantly speed up resampling computations,
         especially with dask arrays. Xarray will use flox by default if installed.
         Pass flox-specific keyword arguments in ``**kwargs``.
-        The default choice is ``method="cohorts"`` which generalizes the best,
-        ``method="blockwise"`` might work better for your problem.
         See the `flox documentation <https://flox.readthedocs.io>`_ for more.
 
         Examples
@@ -7144,8 +7060,6 @@ class DataArrayResampleAggregations:
         Use the ``flox`` package to significantly speed up resampling computations,
         especially with dask arrays. Xarray will use flox by default if installed.
         Pass flox-specific keyword arguments in ``**kwargs``.
-        The default choice is ``method="cohorts"`` which generalizes the best,
-        ``method="blockwise"`` might work better for your problem.
         See the `flox documentation <https://flox.readthedocs.io>`_ for more.
 
         Examples
@@ -7251,8 +7165,6 @@ class DataArrayResampleAggregations:
         Use the ``flox`` package to significantly speed up resampling computations,
         especially with dask arrays. Xarray will use flox by default if installed.
         Pass flox-specific keyword arguments in ``**kwargs``.
-        The default choice is ``method="cohorts"`` which generalizes the best,
-        ``method="blockwise"`` might work better for your problem.
         See the `flox documentation <https://flox.readthedocs.io>`_ for more.
 
         Examples
@@ -7358,8 +7270,6 @@ class DataArrayResampleAggregations:
         Use the ``flox`` package to significantly speed up resampling computations,
         especially with dask arrays. Xarray will use flox by default if installed.
         Pass flox-specific keyword arguments in ``**kwargs``.
-        The default choice is ``method="cohorts"`` which generalizes the best,
-        ``method="blockwise"`` might work better for your problem.
         See the `flox documentation <https://flox.readthedocs.io>`_ for more.
 
         Non-numeric variables will be removed prior to reducing.
@@ -7474,8 +7384,6 @@ class DataArrayResampleAggregations:
         Use the ``flox`` package to significantly speed up resampling computations,
         especially with dask arrays. Xarray will use flox by default if installed.
         Pass flox-specific keyword arguments in ``**kwargs``.
-        The default choice is ``method="cohorts"`` which generalizes the best,
-        ``method="blockwise"`` might work better for your problem.
         See the `flox documentation <https://flox.readthedocs.io>`_ for more.
 
         Non-numeric variables will be removed prior to reducing.
@@ -7600,8 +7508,6 @@ class DataArrayResampleAggregations:
         Use the ``flox`` package to significantly speed up resampling computations,
         especially with dask arrays. Xarray will use flox by default if installed.
         Pass flox-specific keyword arguments in ``**kwargs``.
-        The default choice is ``method="cohorts"`` which generalizes the best,
-        ``method="blockwise"`` might work better for your problem.
         See the `flox documentation <https://flox.readthedocs.io>`_ for more.
 
         Non-numeric variables will be removed prior to reducing.
@@ -7723,8 +7629,6 @@ class DataArrayResampleAggregations:
         Use the ``flox`` package to significantly speed up resampling computations,
         especially with dask arrays. Xarray will use flox by default if installed.
         Pass flox-specific keyword arguments in ``**kwargs``.
-        The default choice is ``method="cohorts"`` which generalizes the best,
-        ``method="blockwise"`` might work better for your problem.
         See the `flox documentation <https://flox.readthedocs.io>`_ for more.
 
         Non-numeric variables will be removed prior to reducing.
@@ -7846,8 +7750,6 @@ class DataArrayResampleAggregations:
         Use the ``flox`` package to significantly speed up resampling computations,
         especially with dask arrays. Xarray will use flox by default if installed.
         Pass flox-specific keyword arguments in ``**kwargs``.
-        The default choice is ``method="cohorts"`` which generalizes the best,
-        ``method="blockwise"`` might work better for your problem.
         See the `flox documentation <https://flox.readthedocs.io>`_ for more.
 
         Non-numeric variables will be removed prior to reducing.
@@ -7965,8 +7867,6 @@ class DataArrayResampleAggregations:
         Use the ``flox`` package to significantly speed up resampling computations,
         especially with dask arrays. Xarray will use flox by default if installed.
         Pass flox-specific keyword arguments in ``**kwargs``.
-        The default choice is ``method="cohorts"`` which generalizes the best,
-        ``method="blockwise"`` might work better for your problem.
         See the `flox documentation <https://flox.readthedocs.io>`_ for more.
 
         Non-numeric variables will be removed prior to reducing.
@@ -8060,8 +7960,6 @@ class DataArrayResampleAggregations:
         Use the ``flox`` package to significantly speed up resampling computations,
         especially with dask arrays. Xarray will use flox by default if installed.
         Pass flox-specific keyword arguments in ``**kwargs``.
-        The default choice is ``method="cohorts"`` which generalizes the best,
-        ``method="blockwise"`` might work better for your problem.
         See the `flox documentation <https://flox.readthedocs.io>`_ for more.
 
         Non-numeric variables will be removed prior to reducing.
@@ -8157,8 +8055,6 @@ class DataArrayResampleAggregations:
         Use the ``flox`` package to significantly speed up resampling computations,
         especially with dask arrays. Xarray will use flox by default if installed.
         Pass flox-specific keyword arguments in ``**kwargs``.
-        The default choice is ``method="cohorts"`` which generalizes the best,
-        ``method="blockwise"`` might work better for your problem.
         See the `flox documentation <https://flox.readthedocs.io>`_ for more.
 
         Non-numeric variables will be removed prior to reducing.
diff --git a/xarray/core/coordinates.py b/xarray/core/coordinates.py
index 2adc4527..251edd1f 100644
--- a/xarray/core/coordinates.py
+++ b/xarray/core/coordinates.py
@@ -298,7 +298,7 @@ class Coordinates(AbstractCoordinates):
         else:
             variables = {}
             for name, data in coords.items():
-                var = as_variable(data, name=name)
+                var = as_variable(data, name=name, auto_convert=False)
                 if var.dims == (name,) and indexes is None:
                     index, index_vars = create_default_index_implicit(var, list(coords))
                     default_indexes.update({k: index for k in index_vars})
@@ -998,9 +998,12 @@ def create_coords_with_default_indexes(
         if isinstance(obj, DataArray):
             dataarray_coords.append(obj.coords)
 
-        variable = as_variable(obj, name=name)
+        variable = as_variable(obj, name=name, auto_convert=False)
 
         if variable.dims == (name,):
+            # still needed to convert to IndexVariable first due to some
+            # pandas multi-index edge cases.
+            variable = variable.to_index_variable()
             idx, idx_vars = create_default_index_implicit(variable, all_variables)
             indexes.update({k: idx for k in idx_vars})
             variables.update(idx_vars)
diff --git a/xarray/core/dataarray.py b/xarray/core/dataarray.py
index 7a0bdbc4..389316d6 100644
--- a/xarray/core/dataarray.py
+++ b/xarray/core/dataarray.py
@@ -159,7 +159,9 @@ def _infer_coords_and_dims(
                 dims = list(coords.keys())
             else:
                 for n, (dim, coord) in enumerate(zip(dims, coords)):
-                    coord = as_variable(coord, name=dims[n]).to_index_variable()
+                    coord = as_variable(
+                        coord, name=dims[n], auto_convert=False
+                    ).to_index_variable()
                     dims[n] = coord.name
     dims_tuple = tuple(dims)
     if len(dims_tuple) != len(shape):
@@ -179,10 +181,12 @@ def _infer_coords_and_dims(
         new_coords = {}
         if utils.is_dict_like(coords):
             for k, v in coords.items():
-                new_coords[k] = as_variable(v, name=k)
+                new_coords[k] = as_variable(v, name=k, auto_convert=False)
+                if new_coords[k].dims == (k,):
+                    new_coords[k] = new_coords[k].to_index_variable()
         elif coords is not None:
             for dim, coord in zip(dims_tuple, coords):
-                var = as_variable(coord, name=dim)
+                var = as_variable(coord, name=dim, auto_convert=False)
                 var.dims = (dim,)
                 new_coords[dim] = var.to_index_variable()
 
@@ -204,11 +208,17 @@ def _check_data_shape(
                 return data
             else:
                 data_shape = tuple(
-                    as_variable(coords[k], k).size if k in coords.keys() else 1
+                    (
+                        as_variable(coords[k], k, auto_convert=False).size
+                        if k in coords.keys()
+                        else 1
+                    )
                     for k in dims
                 )
         else:
-            data_shape = tuple(as_variable(coord, "foo").size for coord in coords)
+            data_shape = tuple(
+                as_variable(coord, "foo", auto_convert=False).size for coord in coords
+            )
         data = np.full(data_shape, data)
     return data
 
@@ -761,11 +771,15 @@ class DataArray(
     @property
     def values(self) -> np.ndarray:
         """
-        The array's data as a numpy.ndarray.
+        The array's data converted to numpy.ndarray.
+
+        This will attempt to convert the array naively using np.array(),
+        which will raise an error if the array type does not support
+        coercion like this (e.g. cupy).
 
-        If the array's data is not a numpy.ndarray this will attempt to convert
-        it naively using np.array(), which will raise an error if the array
-        type does not support coercion like this (e.g. cupy).
+        Note that this array is not copied; operations on it follow
+        numpy's rules of what generates a view vs. a copy, and changes
+        to this array may be reflected in the DataArray as well.
         """
         return self.variable.values
 
diff --git a/xarray/core/groupby.py b/xarray/core/groupby.py
index 3fbfb74d..5966c32d 100644
--- a/xarray/core/groupby.py
+++ b/xarray/core/groupby.py
@@ -28,7 +28,7 @@ from xarray.core.indexes import (
     filter_indexes_from_coords,
     safe_cast_to_index,
 )
-from xarray.core.options import _get_keep_attrs
+from xarray.core.options import OPTIONS, _get_keep_attrs
 from xarray.core.types import (
     Dims,
     QuantileMethods,
@@ -38,11 +38,13 @@ from xarray.core.types import (
 )
 from xarray.core.utils import (
     FrozenMappingWarningOnValuesAccess,
+    contains_only_chunked_or_numpy,
     either_dict_or_kwargs,
     emit_user_level_warning,
     hashable,
     is_scalar,
     maybe_wrap_array,
+    module_available,
     peek_at,
 )
 from xarray.core.variable import IndexVariable, Variable
@@ -1075,6 +1077,9 @@ class GroupBy(Generic[T_Xarray]):
                         result[var] = result[var].transpose(d, ...)
         return result
 
+    def _restore_dim_order(self, stacked):
+        raise NotImplementedError
+
     def _maybe_restore_empty_groups(self, combined):
         """Our index contained empty groups (e.g., from a resampling or binning). If we
         reduced on that dimension, we want to restore the full index.
@@ -1209,13 +1214,9 @@ class GroupBy(Generic[T_Xarray]):
                     (result.sizes[grouper.name],) + var.shape,
                 )
 
-        if isbin:
-            # Fix dimension order when binning a dimension coordinate
-            # Needed as long as we do a separate code path for pint;
-            # For some reason Datasets and DataArrays behave differently!
-            (group_dim,) = grouper.dims
-            if isinstance(self._obj, Dataset) and group_dim in self._obj.dims:
-                result = result.transpose(grouper.name, ...)
+        if not isinstance(result, Dataset):
+            # only restore dimension order for arrays
+            result = self._restore_dim_order(result)
 
         return result
 
@@ -1376,16 +1377,30 @@ class GroupBy(Generic[T_Xarray]):
             (grouper,) = self.groupers
             dim = grouper.group1d.dims
 
-        return self.map(
-            self._obj.__class__.quantile,
-            shortcut=False,
-            q=q,
-            dim=dim,
-            method=method,
-            keep_attrs=keep_attrs,
-            skipna=skipna,
-            interpolation=interpolation,
-        )
+        # Dataset.quantile does this, do it for flox to ensure same output.
+        q = np.asarray(q, dtype=np.float64)
+
+        if (
+            method == "linear"
+            and OPTIONS["use_flox"]
+            and contains_only_chunked_or_numpy(self._obj)
+            and module_available("flox", minversion="0.9.4")
+        ):
+            result = self._flox_reduce(
+                func="quantile", q=q, dim=dim, keep_attrs=keep_attrs, skipna=skipna
+            )
+            return result
+        else:
+            return self.map(
+                self._obj.__class__.quantile,
+                shortcut=False,
+                q=q,
+                dim=dim,
+                method=method,
+                keep_attrs=keep_attrs,
+                skipna=skipna,
+                interpolation=interpolation,
+            )
 
     def where(self, cond, other=dtypes.NA) -> T_Xarray:
         """Return elements from `self` or `other` depending on `cond`.
diff --git a/xarray/core/merge.py b/xarray/core/merge.py
index a689620e..cbd06c8f 100644
--- a/xarray/core/merge.py
+++ b/xarray/core/merge.py
@@ -355,7 +355,7 @@ def collect_variables_and_indexes(
                 indexes_.pop(name, None)
                 append_all(coords_, indexes_)
 
-            variable = as_variable(variable, name=name)
+            variable = as_variable(variable, name=name, auto_convert=False)
             if name in indexes:
                 append(name, variable, indexes[name])
             elif variable.dims == (name,):
diff --git a/xarray/core/variable.py b/xarray/core/variable.py
index 2ac0c04d..ec284e41 100644
--- a/xarray/core/variable.py
+++ b/xarray/core/variable.py
@@ -33,6 +33,7 @@ from xarray.core.utils import (
     decode_numpy_dict_values,
     drop_dims_from_indexers,
     either_dict_or_kwargs,
+    emit_user_level_warning,
     ensure_us_time_resolution,
     infix_dims,
     is_dict_like,
@@ -80,7 +81,9 @@ class MissingDimensionsError(ValueError):
     # TODO: move this to an xarray.exceptions module?
 
 
-def as_variable(obj: T_DuckArray | Any, name=None) -> Variable | IndexVariable:
+def as_variable(
+    obj: T_DuckArray | Any, name=None, auto_convert: bool = True
+) -> Variable | IndexVariable:
     """Convert an object into a Variable.
 
     Parameters
@@ -100,6 +103,9 @@ def as_variable(obj: T_DuckArray | Any, name=None) -> Variable | IndexVariable:
           along a dimension of this given name.
         - Variables with name matching one of their dimensions are converted
           into `IndexVariable` objects.
+    auto_convert : bool, optional
+        For internal use only! If True, convert a "dimension" variable into
+        an IndexVariable object (deprecated).
 
     Returns
     -------
@@ -150,9 +156,15 @@ def as_variable(obj: T_DuckArray | Any, name=None) -> Variable | IndexVariable:
             f"explicit list of dimensions: {obj!r}"
         )
 
-    if name is not None and name in obj.dims and obj.ndim == 1:
-        # automatically convert the Variable into an Index
-        obj = obj.to_index_variable()
+    if auto_convert:
+        if name is not None and name in obj.dims and obj.ndim == 1:
+            # automatically convert the Variable into an Index
+            emit_user_level_warning(
+                f"variable {name!r} with name matching its dimension will not be "
+                "automatically converted into an `IndexVariable` object in the future.",
+                FutureWarning,
+            )
+            obj = obj.to_index_variable()
 
     return obj
 
@@ -706,8 +718,10 @@ class Variable(NamedArray, AbstractArray, VariableArithmetic):
                 variable = (
                     value
                     if isinstance(value, Variable)
-                    else as_variable(value, name=dim)
+                    else as_variable(value, name=dim, auto_convert=False)
                 )
+                if variable.dims == (dim,):
+                    variable = variable.to_index_variable()
                 if variable.dtype.kind == "b":  # boolean indexing case
                     (variable,) = variable._nonzero()
 
diff --git a/xarray/util/generate_aggregations.py b/xarray/util/generate_aggregations.py
index 3462af28..b59dc36c 100644
--- a/xarray/util/generate_aggregations.py
+++ b/xarray/util/generate_aggregations.py
@@ -19,6 +19,7 @@ from dataclasses import dataclass, field
 
 MODULE_PREAMBLE = '''\
 """Mixin classes with reduction operations."""
+
 # This file was generated using xarray.util.generate_aggregations. Do not edit manually.
 
 from __future__ import annotations
@@ -245,13 +246,9 @@ _NUMERIC_ONLY_NOTES = "Non-numeric variables will be removed prior to reducing."
 _FLOX_NOTES_TEMPLATE = """Use the ``flox`` package to significantly speed up {kind} computations,
 especially with dask arrays. Xarray will use flox by default if installed.
 Pass flox-specific keyword arguments in ``**kwargs``.
-The default choice is ``method="cohorts"`` which generalizes the best,
-{recco} might work better for your problem.
 See the `flox documentation <https://flox.readthedocs.io>`_ for more."""
-_FLOX_GROUPBY_NOTES = _FLOX_NOTES_TEMPLATE.format(kind="groupby", recco="other methods")
-_FLOX_RESAMPLE_NOTES = _FLOX_NOTES_TEMPLATE.format(
-    kind="resampling", recco='``method="blockwise"``'
-)
+_FLOX_GROUPBY_NOTES = _FLOX_NOTES_TEMPLATE.format(kind="groupby")
+_FLOX_RESAMPLE_NOTES = _FLOX_NOTES_TEMPLATE.format(kind="resampling")
 
 ExtraKwarg = collections.namedtuple("ExtraKwarg", "docs kwarg call example")
 skipna = ExtraKwarg(
@@ -300,11 +297,13 @@ class Method:
         extra_kwargs=tuple(),
         numeric_only=False,
         see_also_modules=("numpy", "dask.array"),
+        min_flox_version=None,
     ):
         self.name = name
         self.extra_kwargs = extra_kwargs
         self.numeric_only = numeric_only
         self.see_also_modules = see_also_modules
+        self.min_flox_version = min_flox_version
         if bool_reduce:
             self.array_method = f"array_{name}"
             self.np_example_array = """
@@ -443,8 +442,8 @@ class GroupByAggregationGenerator(AggregationGenerator):
         if self.datastructure.numeric_only:
             extra_kwargs.append(f"numeric_only={method.numeric_only},")
 
-        # numpy_groupies & flox do not support median
-        # https://github.com/ml31415/numpy-groupies/issues/43
+        # median isn't enabled yet, because it would break if a single group was present in multiple
+        # chunks. The non-flox code path will just rechunk every group to a single chunk and execute the median
         method_is_not_flox_supported = method.name in ("median", "cumsum", "cumprod")
         if method_is_not_flox_supported:
             indent = 12
@@ -465,11 +464,16 @@ class GroupByAggregationGenerator(AggregationGenerator):
             **kwargs,
         )"""
 
-        else:
-            return f"""\
+        min_version_check = f"""
+            and module_available("flox", minversion="{method.min_flox_version}")"""
+
+        return (
+            """\
         if (
             flox_available
-            and OPTIONS["use_flox"]
+            and OPTIONS["use_flox"]"""
+            + (min_version_check if method.min_flox_version is not None else "")
+            + f"""
             and contains_only_chunked_or_numpy(self._obj)
         ):
             return self._flox_reduce(
@@ -486,6 +490,7 @@ class GroupByAggregationGenerator(AggregationGenerator):
                 keep_attrs=keep_attrs,
                 **kwargs,
             )"""
+        )
 
 
 class GenericAggregationGenerator(AggregationGenerator):
@@ -522,7 +527,9 @@ AGGREGATION_METHODS = (
     Method("sum", extra_kwargs=(skipna, min_count), numeric_only=True),
     Method("std", extra_kwargs=(skipna, ddof), numeric_only=True),
     Method("var", extra_kwargs=(skipna, ddof), numeric_only=True),
-    Method("median", extra_kwargs=(skipna,), numeric_only=True),
+    Method(
+        "median", extra_kwargs=(skipna,), numeric_only=True, min_flox_version="0.9.2"
+    ),
     # Cumulatives:
     Method("cumsum", extra_kwargs=(skipna,), numeric_only=True),
     Method("cumprod", extra_kwargs=(skipna,), numeric_only=True),


Test patch:
diff --git a/xarray/tests/test_backends.py b/xarray/tests/test_backends.py
index 3fb13797..1d69b3ad 100644
--- a/xarray/tests/test_backends.py
+++ b/xarray/tests/test_backends.py
@@ -3560,6 +3560,16 @@ class TestH5NetCDFData(NetCDF4Base):
             assert actual.x.encoding["compression"] == "lzf"
             assert actual.x.encoding["compression_opts"] is None
 
+    def test_decode_utf8_warning(self) -> None:
+        title = b"\xc3"
+        with create_tmp_file() as tmp_file:
+            with nc4.Dataset(tmp_file, "w") as f:
+                f.title = title
+            with pytest.warns(UnicodeWarning, match="returning bytes undecoded") as w:
+                ds = xr.load_dataset(tmp_file, engine="h5netcdf")
+                assert ds.title == title
+                assert "attribute 'title' of h5netcdf object '/'" in str(w[0].message)
+
 
 @requires_h5netcdf
 @requires_netCDF4
diff --git a/xarray/tests/test_coordinates.py b/xarray/tests/test_coordinates.py
index 68ce55b0..40743194 100644
--- a/xarray/tests/test_coordinates.py
+++ b/xarray/tests/test_coordinates.py
@@ -8,6 +8,7 @@ from xarray.core.coordinates import Coordinates
 from xarray.core.dataarray import DataArray
 from xarray.core.dataset import Dataset
 from xarray.core.indexes import PandasIndex, PandasMultiIndex
+from xarray.core.variable import IndexVariable
 from xarray.tests import assert_identical, source_ndarray
 
 
@@ -23,10 +24,12 @@ class TestCoordinates:
         assert_identical(coords.to_dataset(), expected)
         assert "x" in coords.xindexes
 
+    @pytest.mark.filterwarnings("error:IndexVariable")
     def test_init_no_default_index(self) -> None:
         # dimension coordinate with no default index (explicit)
         coords = Coordinates(coords={"x": [1, 2]}, indexes={})
         assert "x" not in coords.xindexes
+        assert not isinstance(coords["x"], IndexVariable)
 
     def test_init_from_coords(self) -> None:
         expected = Dataset(coords={"foo": ("x", [0, 1, 2])})
diff --git a/xarray/tests/test_groupby.py b/xarray/tests/test_groupby.py
index d927550e..045e1223 100644
--- a/xarray/tests/test_groupby.py
+++ b/xarray/tests/test_groupby.py
@@ -245,6 +245,51 @@ def test_da_groupby_empty() -> None:
         empty_array.groupby("dim")
 
 
+@requires_dask
+def test_dask_da_groupby_quantile() -> None:
+    # Only works when the grouped reduction can run blockwise
+    # Scalar quantile
+    expected = xr.DataArray(
+        data=[2, 5], coords={"x": [1, 2], "quantile": 0.5}, dims="x"
+    )
+    array = xr.DataArray(
+        data=[1, 2, 3, 4, 5, 6], coords={"x": [1, 1, 1, 2, 2, 2]}, dims="x"
+    )
+    with pytest.raises(ValueError):
+        array.chunk(x=1).groupby("x").quantile(0.5)
+
+    # will work blockwise with flox
+    actual = array.chunk(x=3).groupby("x").quantile(0.5)
+    assert_identical(expected, actual)
+
+    # will work blockwise with flox
+    actual = array.chunk(x=-1).groupby("x").quantile(0.5)
+    assert_identical(expected, actual)
+
+
+@requires_dask
+def test_dask_da_groupby_median() -> None:
+    expected = xr.DataArray(data=[2, 5], coords={"x": [1, 2]}, dims="x")
+    array = xr.DataArray(
+        data=[1, 2, 3, 4, 5, 6], coords={"x": [1, 1, 1, 2, 2, 2]}, dims="x"
+    )
+    with xr.set_options(use_flox=False):
+        actual = array.chunk(x=1).groupby("x").median()
+    assert_identical(expected, actual)
+
+    with xr.set_options(use_flox=True):
+        actual = array.chunk(x=1).groupby("x").median()
+    assert_identical(expected, actual)
+
+    # will work blockwise with flox
+    actual = array.chunk(x=3).groupby("x").median()
+    assert_identical(expected, actual)
+
+    # will work blockwise with flox
+    actual = array.chunk(x=-1).groupby("x").median()
+    assert_identical(expected, actual)
+
+
 def test_da_groupby_quantile() -> None:
     array = xr.DataArray(
         data=[1, 2, 3, 4, 5, 6], coords={"x": [1, 1, 1, 2, 2, 2]}, dims="x"
diff --git a/xarray/tests/test_variable.py b/xarray/tests/test_variable.py
index 061510f2..d9289aa6 100644
--- a/xarray/tests/test_variable.py
+++ b/xarray/tests/test_variable.py
@@ -1216,7 +1216,8 @@ class TestVariable(VariableSubclassobjects):
         with pytest.raises(TypeError, match=r"without an explicit list of dimensions"):
             as_variable(data)
 
-        actual = as_variable(data, name="x")
+        with pytest.warns(FutureWarning, match="IndexVariable"):
+            actual = as_variable(data, name="x")
         assert_identical(expected.to_index_variable(), actual)
 
         actual = as_variable(0)
@@ -1234,9 +1235,11 @@ class TestVariable(VariableSubclassobjects):
 
         # test datetime, timedelta conversion
         dt = np.array([datetime(1999, 1, 1) + timedelta(days=x) for x in range(10)])
-        assert as_variable(dt, "time").dtype.kind == "M"
+        with pytest.warns(FutureWarning, match="IndexVariable"):
+            assert as_variable(dt, "time").dtype.kind == "M"
         td = np.array([timedelta(days=x) for x in range(10)])
-        assert as_variable(td, "time").dtype.kind == "m"
+        with pytest.warns(FutureWarning, match="IndexVariable"):
+            assert as_variable(td, "time").dtype.kind == "m"
 
         with pytest.raises(TypeError):
             as_variable(("x", DataArray([])))