-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Add json_array_contains Presto Json function #2299
Conversation
eb5eff2
to
e1a8bfd
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi Pramod, Thank you for adding this function!
71c614b
to
2093a6e
Compare
2093a6e
to
889024e
Compare
915dfbd
to
6c63db3
Compare
6c63db3
to
385a07d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks Pramod for the changes. One comment related to tests.
✅ Deploy Preview for meta-velox canceled.
|
39f7880
to
d65345e
Compare
bool valueInt = std::is_same_v<TInput, int64_t>; | ||
bool valueDouble = std::is_same_v<TInput, double>; | ||
for (const auto& v : parsedJson) { | ||
if (valueBool && v.isBool() && v == value) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
std::is_same_v<TInput, bool>
can be determined at compile time, so it's better not to do runtime checks on it. (Same for int64_t and double.) With the current code, valueBool, valueInt, and valueDouble are computed and checked at runtime. Consider using if constexpr (...)
for type checks and do the value comparison inside. The rest looks good to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks this is a good suggestion. Agree its best to handle this in compilation. Otherwise choosing to write the templated code while taking these runtime hits is not worth the tradeoff.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the suggestion, changed accordingly
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thank you very much for iterating on it! I'm going to import this PR and will let you know if there are further changes needed.
@kagamiori has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
Adds Json function json_array_contains to determine if value exists in
json
(a string containing a JSON array).