在Greenplum中自定义操作符

2021-12-07 12:29:26 浏览数 (2)

Greenplum中null是不可比较的,因此也没有类似Hive中的<=>,所谓完全相等比较符。但是,Greenplum中可以创建自定义操作符,实现也很简单:

代码语言:javascript复制
CREATE OR REPLACE FUNCTION fn_exactly_equal(left_o anyelement, right_o anyelement) RETURNS BOOLEAN AS
$$
  SELECT left_o = right_o or left_o is null and right_o is null
$$
LANGUAGE sql;
CREATE OPERATOR <=> (PROCEDURE = fn_exactly_equal, LEFTARG = anyelement, RIGHTARG = anyelement, COMMUTATOR = <=>);

0 人点赞