Skip to content

UNION on json columns doesn't work #35260

@gabcbrown

Description

@gabcbrown

Describe the problem
Came across this while trying to union two selects that contained a json column, and narrowed it down to the json column. The following example fails:

To Reproduce

> CREATE TABLE t1 (j JSON);
> CREATE TABLE t2 (j JSON);
> INSERT INTO t1 VALUES ('{"a": "b"}');
> INSERT INTO t2 VALUES ('{"c": "d"}');
> (SELECT j FROM t1) UNION (SELECT j FROM t2);

Output is pq: unable to encode table key: *tree.DJSON

Expected behavior
If this is related to #24436 (not key-encoding JSON values) then a clearer error message. Otherwise I would expect:

       j         
+------------+
  {"a": "b"}
  {"c": "d"}  
(2 rows)

Environment:

  • CockroachDB version: 2.1.4
  • Server OS: MacOS High Sierra
  • Client app:cockroach sql

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCode not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.docs-known-limitation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions