From 178fd9d472df7b744cc2bf7d0adfdaea57b6af4a Mon Sep 17 00:00:00 2001 From: Tim Jenness Date: Mon, 30 Sep 2024 14:06:49 -0700 Subject: [PATCH] Allow for there to be no valid data in a arrow table string column --- python/lsst/daf/butler/formatters/parquet.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/python/lsst/daf/butler/formatters/parquet.py b/python/lsst/daf/butler/formatters/parquet.py index 5c9c952bf4..6e8937a019 100644 --- a/python/lsst/daf/butler/formatters/parquet.py +++ b/python/lsst/daf/butler/formatters/parquet.py @@ -1098,7 +1098,8 @@ def _arrow_string_to_numpy_dtype( # String/bytes length from header. strlen = int(schema.metadata[encoded]) elif numpy_column is not None and len(numpy_column) > 0: - strlen = max([len(row) for row in numpy_column if row]) + lengths = [len(row) for row in numpy_column if row] + strlen = max(lengths) if lengths else 0 dtype = f"U{strlen}" if schema.field(name).type == pa.string() else f"|S{strlen}"