【发布时间】:2019-12-28 22:19:32
【问题描述】:
我将这个新函数包含到this S2geometry "plug" 中,该函数调用this Python API... 这很简单,但我无法调试和发现正确的 Python 对象属性和数组数据类型,以转换为 PostgreSQL basic类型。
CREATE FUNCTION s2_token_get_vertex(token text, k int, OUT debug text)
AS $f$
import s2sphere
point = s2sphere.Cell( s2sphere.CellId.from_token(token) ).get_vertex(k)
return ''.join(map(str,point))
$f$ LANGUAGE plpython3u IMMUTABLE;
-
return type(point)是s2sphere.sphere.Point -
return point.__dict__是{'_Point__point': (0.20907532445858387, -0.7283167971253012, 0.6525658217587561)} -
return map(str,point)是0.20907532445858387-0.72831679712530120.6525658217587561 -
return str( point[1] )是<class 'float'>
但return point 是我为 PostgreSQL 测试的许多替代方案中的任何一个返回的错误:float[]、float4[] 和 (OUT x float, OUT y float, OUT z float) 的元组...
如何判断point.attribute及其正确的函数返回?
所有线索都说,最接近正确的是在 Python 代码处使用 return point,并在 PostgreSQL 函数返回处使用 OUT r float[]。但是:
ERROR: invalid memory alloc request size 18446744073709551608
CONTEXT: while creating return value
【问题讨论】:
标签: python postgresql introspection