1

Suppose this query

select gestimate, (get(parse_json(gestimate) :duration,'value')) / 60.0  AS rc_estimate 
from mytable;

blows up because 120M rows in, there is an unparseable row. How to adjust this query so it places a 0 into rc_estimate if it is unparseable?

1 Answer 1

3

Using TRY_PARSE_JSON:

select gestimate, (get(try_parse_json(gestimate) :duration,'value')) / 60.0  AS rc_estimate 
from mytable;

COALESCE(expr, 0), ZEROIFNULL(expr) could be used to change the result from NULL to 0.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.