...
"cast( data ->> 'temperature' as DOUBLE PRECISION)" is to find the 'temperature' in data and convert it to double format. Using the following SQL can make it more responsive ( just running once):
Code Block | ||
---|---|---|
| ||
create or replace function cast_to_double(text) returns DOUBLE PRECISION as |
...
Code Block | ||
---|---|---|
| ||
$$
begin
-- Note the double casting to avoid infinite recursion.
return cast($1::varchar as DOUBLE PRECISION);
exception
when invalid_text_representation then
return 0.0;
end;
$$ language plpgsql immutable;
create cast (text as DOUBLE PRECISION) with function cast_to_double(text); |
...