Skip to content

Semi-structured accessor functions return incorrect value #1907

Description

@rampage644

Here is the difference between Snowflake and embucket:

CREATE OR REPLACE TABLE variant_test_embucket (
      id INT,
      data VARIANT
  );

INSERT INTO variant_test_embucket SELECT 1, PARSE_JSON('{"name": "test", "id": "1d110fd7-0f54-4452-8dc6-c4a3eac02024"}');

 > select data:name as n, length(n), data:id as i, length(i) from variant_test;
+-------------------------------------------------------------------------+
| N      | LENGTH(N) | I                                      | LENGTH(I) |
|--------+-----------+----------------------------------------+-----------|
| "test" | 4         | "1d110fd7-0f54-4452-8dc6-c4a3eac02024" | 36        |
+-------------------------------------------------------------------------+
CREATE OR REPLACE TEMPORARY TABLE variant_test (
         id INT,
         data VARIANT
     );

     INSERT INTO variant_test SELECT 1, PARSE_JSON('{"name": "test", "id": "1d110fd7-0f54-4452-8dc6-c4a3eac02024"}');
+-------+
| count |
|-------|
| 0     |
+-------+

+-------+
| count |
|-------|
| 1     |
+-------+

 > select data:name as n, length(n), data:id as i, length(i) from variant_test;
+-------------------------------------------------------------------------------------------------------------------------------------------------------------+
|        | length(variant_element(embucket.public.variant_test |                                        | length(variant_element(embucket.public.variant_test |
| n      | .data,Utf8("$.name"),Boolean(true)))                | i                                      | .data,Utf8("$.id"),Boolean(true)))                  |
|--------+-----------------------------------------------------+----------------------------------------+-----------------------------------------------------|
| "test" | 6                                                   | "1d110fd7-0f54-4452-8dc6-c4a3eac02024" | 38                                                  |
+-------------------------------------------------------------------------------------------------------------------------------------------------------------+

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions