SELECT * FROM test_return_array_int('[[1,2,3],[4,5,6]]');
test_return_array_int
-----------------------
{{1,2,3},{4,5,6}}
(1 row)
-- Error conditions
-- Multi-dimensional array with non-fixed dimension sizes
SELECT test_return_array_int('[[1,2,3],[1,2]]');
ERROR: Multidimensional arrays must have array expressions with matching dimensions. PL/Python function return value has sequence length 2 while expected 3 (plpython.c:4865)
CONTEXT: while creating return value
PL/Python function "test_return_array_int"
SELECT * FROM test_return_array_int('[[1,2,3],[1,2]]');
ERROR: Multidimensional arrays must have array expressions with matching dimensions. PL/Python function return value has sequence length 2 while expected 3 (plpython.c:4865)
CONTEXT: while creating return value
PL/Python function "test_return_array_int"
-- Multi-dimensional array with mix of arrays and atomic elements
ERROR: Multidimensional arrays must have array expressions with matching dimensions. PL/Python function return value has sequence length -1 while expected 3 (plpython.c:4865)
DETAIL: TypeError: object of type 'NoneType' has no len()
CONTEXT: while creating return value
PL/Python function "test_return_array_int"
SELECT * FROM test_return_array_int('[[1,2,3],None,[4,5,6]]');
ERROR: Multidimensional arrays must have array expressions with matching dimensions. PL/Python function return value has sequence length -1 while expected 3 (plpython.c:4865)
DETAIL: TypeError: object of type 'NoneType' has no len()
CONTEXT: while creating return value
PL/Python function "test_return_array_int"
--
-- Case 5: Return array of texts
--
-- Test returning arrays of variable-width elements from PL/Python functions
--
-- From Python None
SELECT test_return_array_text('None');
test_return_array_text
------------------------
(1 row)
SELECT * FROM test_return_array_text('None');
test_return_array_text
------------------------
(1 row)
-- From Python empty list
SELECT test_return_array_text('[]');
test_return_array_text
------------------------
{}
(1 row)
SELECT * FROM test_return_array_text('[]');
test_return_array_text
------------------------
{}
(1 row)
-- From Python non-empty list
SELECT test_return_array_text('["abc","def"]');
test_return_array_text
------------------------
{abc,def}
(1 row)
SELECT * FROM test_return_array_text('["abc","def"]');
ERROR: Multidimensional arrays must have array expressions with matching dimensions. PL/Python function return value has sequence length 4 while expected 3 (plpython.c:4865)
CONTEXT: while creating return value
PL/Python function "test_return_array_text"
SELECT * FROM test_return_array_text('[["a","bcd","ef"],[None,"gh","ijklm","ERROR"]]');
ERROR: Multidimensional arrays must have array expressions with matching dimensions. PL/Python function return value has sequence length 4 while expected 3 (plpython.c:4865)
CONTEXT: while creating return value
PL/Python function "test_return_array_text"
-- Multi-dimensional array with mix of arrays and atomic elements
ERROR: Multidimensional arrays must have array expressions with matching dimensions. PL/Python function return value has sequence length 2 while expected 1 (plpython.c:4865)
CONTEXT: while creating return value
PL/Python function "test_return_array_text"
SELECT * FROM test_return_array_text('[[["a"],"b"],["c",["d","e"]]]');
ERROR: Multidimensional arrays must have array expressions with matching dimensions. PL/Python function return value has sequence length 2 while expected 1 (plpython.c:4865)
CONTEXT: while creating return value
PL/Python function "test_return_array_text"
-- Multi-dimensional array with missing dimensions
ERROR: Multidimensional arrays must have array expressions with matching dimensions. PL/Python function return value has sequence length -1 while expected 2 (plpython.c:4865)
DETAIL: TypeError: object of type 'NoneType' has no len()
CONTEXT: while creating return value
PL/Python function "test_return_array_text"
SELECT * FROM test_return_array_text('[["abc","def"],None,["ghij","k"]]');
ERROR: Multidimensional arrays must have array expressions with matching dimensions. PL/Python function return value has sequence length -1 while expected 2 (plpython.c:4865)
DETAIL: TypeError: object of type 'NoneType' has no len()