(최초 작성한 글이 날아갔다. 아...)

 

 

현재 진행 중인 프로젝트에서 표에 평균값을 표시하는 화면을 구현 중이었다.

 

하나의 칸이 NaN으로 표시되길래, 원인을 추적했다.

해당 컬럼의 데이터 타입은 FLOAT이다. 그 컬럼에서 수백 개의 데이터 중 딱 하나가 NaN으로 들어가있었다.

 

내가 해결한 방법은 Impala의 내장 함수 중 IS_NAN을 사용했다.

 

 

https://docs.cloudera.com/runtime/7.0.3/impala-sql-reference/topics/impala-math-functions.html#math_functions__is_nan

 

Impala mathematical functions

Mathematical functions, or arithmetic functions, perform numeric calculations that are typically more complex than basic addition, subtraction, multiplication, and division. For example, these functions include trigonometric, logarithmic, and base conversi

docs.cloudera.com

 

NaN이 있으면 true, 없으면 false를 반환한다.

 

이것을 이용해서, NaN이 포함되어 있으면 0을, 없으면 원래 값을 출력했다.

 

[예시 쿼리]

1
2
SELECT DECODE(IS_NAN(superman), true0, superman)
FROM crypton

 

 

끗.

 

+ Recent posts