typeof()
typeof() 함수는 인수로 전달된 값의 데이터 타입 이름을 문자열로 반환합니다.
문법
typeof(EXPR)
매개변수
EXPR- 타입을 확인할 필드 이름 또는 표현식.
설명
typeof() 함수는 EXPR을 평가한 결과의 데이터 타입에 따라 다음 문자열 중 하나를 반환합니다.
| 반환값 | 설명 |
|---|---|
"string" | 문자열 |
"int" | 32비트 정수 |
"long" | 64비트 정수 |
"short" | 16비트 정수 |
"double" | 64비트 실수 |
"float" | 32비트 실수 |
"bool" | 불리언 |
"ipv4" | IPv4 주소 |
"ipv6" | IPv6 주소 |
"date" | 날짜 |
"map" | 맵 |
"list" | 리스트 |
"byte[]" | 바이트 배열 |
"int[]" | 32비트 정수 배열 |
"long[]" | 64비트 정수 배열 |
"short[]" | 16비트 정수 배열 |
"double[]" | 64비트 실수 배열 |
"float[]" | 32비트 실수 배열 |
"bool[]" | 불리언 배열 |
"object[]" | 객체 배열 |
EXPR의 평가 결과가 null이면 null을 반환합니다.
오류 코드
해당 사항 없음
사용 예
이 사용 예에서 조회하는 WEB_APACHE_SAMPLE 테이블을 준비하려면 쿼리 실습용 데이터를 참고하세요.
-
문자열 타입인
method필드의 타입 확인table limit=5 WEB_APACHE_SAMPLE | eval result = typeof(method) | fields method, result | # result: "string" -
정수 타입인
status필드의 타입 확인table limit=5 WEB_APACHE_SAMPLE | eval result = typeof(status) | fields status, result | # result: "int" -
IP 주소 타입인
src_ip필드의 타입 확인table limit=5 WEB_APACHE_SAMPLE | eval result = typeof(src_ip) | fields src_ip, result | # result: "ipv4" -
날짜 타입인
_time필드의 타입 확인table limit=5 WEB_APACHE_SAMPLE | eval result = typeof(_time) | fields _time, result | # result: "date" -
NULL 입력
json "{'val': null}" | eval result = typeof(val) | # result: null
호환성
typeof() 함수는 소나 4.0 이전 버전부터 제공되었습니다.