diff --git a/src/ports/postgres/modules/linalg/matrix_ops.py_in b/src/ports/postgres/modules/linalg/matrix_ops.py_in index 9f3215c41..4fc9a1584 100644 --- a/src/ports/postgres/modules/linalg/matrix_ops.py_in +++ b/src/ports/postgres/modules/linalg/matrix_ops.py_in @@ -227,7 +227,6 @@ def matrix_ndims(schema_madlib, matrix_in, in_args, is_block): def get_dims(matrix, matrix_args, is_block=False): - if is_block: block_dim = plpy.execute(""" SELECT @@ -287,12 +286,15 @@ def get_dims(matrix, matrix_args, is_block=False): if row_dim != 0: rv = plpy.execute(""" SELECT - (array_upper({matrix_args[val]}::float8[], 1) - - array_lower({matrix_args[val]}::float8[], 1) + 1) + DISTINCT(array_upper({matrix_args[val]}::float8[], 1) - + array_lower({matrix_args[val]}::float8[], 1) + 1) AS col_dim FROM {matrix} """.format(matrix=matrix, matrix_args=matrix_args)) + _assert(rv and len(rv) == 1, + "dimensions mismatch: row_array.size() != vec.size(). " + "Data contains different sized arrays") col_dim = rv[0]['col_dim'] else: col_dim = 0