From 6fcd873421fd845bf25e70f0eba9185ceb4527b2 Mon Sep 17 00:00:00 2001 From: Deepak Cherian Date: Thu, 2 May 2024 15:53:17 -0600 Subject: [PATCH] Zarr: optimize appending --- xarray/backends/api.py | 43 +++-------------------------------------- xarray/backends/zarr.py | 32 ++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 40 deletions(-) diff --git a/xarray/backends/api.py b/xarray/backends/api.py index 1c0537b5d10..21163227e88 100644 --- a/xarray/backends/api.py +++ b/xarray/backends/api.py @@ -1521,42 +1521,6 @@ def save_mfdataset( ) -def _validate_datatypes_for_zarr_append(zstore, dataset): - """If variable exists in the store, confirm dtype of the data to append is compatible with - existing dtype. - """ - - existing_vars = zstore.get_variables() - - def check_dtype(vname, var): - if ( - vname not in existing_vars - or np.issubdtype(var.dtype, np.number) - or np.issubdtype(var.dtype, np.datetime64) - or np.issubdtype(var.dtype, np.bool_) - or var.dtype == object - ): - # We can skip dtype equality checks under two conditions: (1) if the var to append is - # new to the dataset, because in this case there is no existing var to compare it to; - # or (2) if var to append's dtype is known to be easy-to-append, because in this case - # we can be confident appending won't cause problems. Examples of dtypes which are not - # easy-to-append include length-specified strings of type `|S*` or `