\set ECHO 0 -- You should write your tests SELECT variant('foo', 'bar'); variant --------- (foo,bar) (1 row) SELECT 'foo' #? 'bar' AS arrowop; arrowop ----------- (foo,bar) (1 row) CREATE TABLE ab ( a_field variant ); INSERT INTO ab VALUES('foo' #? 'bar'); SELECT (a_field).a, (a_field).b FROM ab; a | b -----+----- foo | bar (1 row) SELECT (variant('foo', 'bar')).a; a ----- foo (1 row) SELECT (variant('foo', 'bar')).b; b ----- bar (1 row) SELECT ('foo' #? 'bar').a; a ----- foo (1 row) SELECT ('foo' #? 'bar').b; b ----- bar (1 row) ROLLBACK;