没有函数匹配您可能需要添加显式类型转换的给定名称和参数类型

时间:2014-05-23 13:53:36

标签: python arrays postgresql aggregate-functions psycopg2

代码中的以下语句给出了一个错误:

cur.execute("
   update %s as A
   set fm = foo.fm
   from (
      select src_id as id, agg_bit_or(fm) as fm
      from %s, %s where dst_id = id
      group by src_id) as foo
   where A.id = foo.id" %(tmp_table, edge_table, vertex_table))

agg_bit_or()是Postgres中用户定义的聚合函数,定义为:

CREATE AGGREGATE agg_bit_or(bit[])
(
    sfunc = bit_or,
    stype = bit[]   
);

错误消息是:

File "radius.py", line 47, in update_bitstring
cur.execute("update %s as A set fm = foo.fm from (select src_id as id, agg_b
it_or(fm)  from %s, %s where dst_id = id group by src_id) as foo where A.id = fo
o.id" %(tmp_table, edge_table, vertex_table))

psycopg2.ProgrammingError: function agg_bit_or(integer[]) does not exist
LINE 1: ...v as A set fm = foo.fm from (select src_id as id, agg_bit_or...
                                                         ^
HINT:  No function matches the given name and argument types. You might need to
add explicit type casts.

1 个答案:

答案 0 :(得分:1)

错误消息显示:

  

psycopg2.ProgrammingError:函数agg_bit_or( integer [] )不存在

定义了您的聚合函数:

  

CREATE AGGREGATE agg_bit_or( bit []

大胆强调我的。您需要兼容的类型。