How to catch nan in presto?

Member

by shyann , in category: Third Party Scripts , 6 months ago

How to catch nan in presto?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

by tressie.damore , 6 months ago

@shyann 

In Presto, you can catch NaN (Not a Number) by using the IF function along with the isnan function. Here is an example of how you can catch NaN in Presto:

1
2
3
4
SELECT 
  IF(isnan(column_name), 'NaN Value', column_name) AS cleaned_column
FROM 
  table_name;


In this example, the isnan function checks if the value in column_name is NaN. If it is NaN, the IF function replaces NaN with a custom string ('NaN Value'), otherwise it keeps the original value.

Related Threads:

How to remove nan from array in php?
How to change nan values to 0 in chart.js?
How to group time column into 5 second intervals and count rows using presto?
How to get latest 3 months records in presto sql?
How to catch multiple exceptions in PHP?
How to catch errors as exceptions in php?