Skip to content

Commit 4a27928

Browse files
committed
Tighten up table_schema handling
1 parent d48762f commit 4a27928

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

daskms/columns.py

+15-3
Original file line numberDiff line numberDiff line change
@@ -222,11 +222,23 @@ def column_metadata(column, table_proxy, table_schema, chunks, exemplar_row=0):
222222
"match shape of exemplar=%s" % (ndim, shape)
223223
)
224224

225-
# Extract dimension schema
225+
# Get the column schema, or create a default
226226
try:
227-
dims = table_schema[column]["dims"]
227+
column_schema = table_schema[column]
228228
except KeyError:
229-
dims = tuple("%s-%d" % (column, i) for i in range(1, len(shape) + 1))
229+
column_schema = {
230+
"dims": tuple("%s-%d" % (column, i) for i in range(1, len(shape) + 1))
231+
}
232+
233+
try:
234+
dims = column_schema["dims"]
235+
except KeyError:
236+
raise ColumnMetadataError(
237+
f"Column schema {column_schema} does not contain required 'dims' attribute"
238+
)
239+
240+
if not isinstance(dims, tuple) or not all(isinstance(d, str) for d in dims):
241+
raise ColumnMetadataError(f"Dimensions {dims} is not a tuple of strings")
230242

231243
dim_chunks = []
232244

0 commit comments

Comments
 (0)