Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Just load first element when the json is an array #239

Open
wangxia514 opened this issue Aug 7, 2023 · 0 comments
Open

Just load first element when the json is an array #239

wangxia514 opened this issue Aug 7, 2023 · 0 comments

Comments

@wangxia514
Copy link

wangxia514 commented Aug 7, 2023

data

[{"key1":"value1a","key2":"value2a",...},{"key1":"value1b","key2":"value2b",...}]

create external table

CREATE EXTERNAL TABLE IF NOT EXISTS testdata.trynum85 (
  data array<struct<`key1`:string,
                    `key2`:string>>
)
ROW FORMAT SERDE 'org.openx.data.jsonserde.JsonSerDe' 
WITH SERDEPROPERTIES (
  'serialization.format' = '1',
  'strip.outer.array'='false'
) LOCATION 's3://mys3/new-json-structure/'
TBLPROPERTIES ('has_encrypted_data'='false');

result: the logic only finds the first object in the array

SELECT stuff.key1
FROM "testdata"."trynum85 ", UNNEST(data) AS t(stuff)
returns
key1
----
value1a

Hi @rcongiu , would you please have a look, thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant