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

Nested JSON breaks connection to impala #7

Open
scratch28 opened this issue Jun 7, 2018 · 1 comment · May be fixed by #8
Open

Nested JSON breaks connection to impala #7

scratch28 opened this issue Jun 7, 2018 · 1 comment · May be fixed by #8

Comments

@scratch28
Copy link

Impala version 2.8
UDF breaks connection upon trying to deal with nested arrays
example JSON:
{"customer_info":[{"field_name":"family_names","field_value":"Gonzalez"},{"field_name":"given_names","field_value":"Pablo"}],"phone":null}

this works
select json_get_object('{"customer_info":[{"field_name":"family_names","field_value":"Gonzalez"},{"field_name":"given_names","field_value":"Pablo"}],"phone":null}','$.customer_info') ;

but this breaks impala
select json_get_object('{"customer_info":[{"field_name":"family_names","field_value":"Gonzalez"},{"field_name":"given_names","field_value":"Pablo"}],"phone":null}','$.customer_info.field_name') ;

@ajfg93
Copy link

ajfg93 commented Aug 13, 2021

@scratch28

replace this line

if (va.HasMember(key)) { \

to

    if (va.IsObject() && va.HasMember(key)) { \

and recompile.

IsObject() needs to be checked before calling HasMember.

See from rapidson/document.h:

#if RAPIDJSON_HAS_STDSTRING
    //! Check whether a member exists in the object with string object.
    /*!
        \param name Member name to be searched.
        \pre IsObject() == true
        \return Whether a member with that name exists.
        \note It is better to use FindMember() directly if you need the obtain the value as well.
        \note Linear time complexity.
    */
    bool HasMember(const std::basic_string<Ch>& name) const { return FindMember(name) != MemberEnd(); }
#endif

\pre IsObject() == true, I thint that means pre-condition.

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

Successfully merging a pull request may close this issue.

2 participants