Skip to main content
The gettype function returns the runtime type of its argument as a string. Use this function when you need to determine the data type of fields, validate data structures, or debug type-related issues in your queries.

For users of other query languages

If you come from other query languages, this section explains how to adjust your existing queries to achieve the same results in APL.
In Splunk SPL, you use typeof to check types. APL’s gettype provides similar functionality with consistent type names.
| eval field_type=typeof(field_name)
In ANSI SQL, type checking varies by database. APL’s gettype provides a standardized approach to runtime type detection.
SELECT TYPEOF(field_name) AS field_type FROM logs;

Usage

Syntax

gettype(expression)

Parameters

NameTypeRequiredDescription
expressionanyYesThe expression whose type you want to determine.

Returns

Returns a string representing the runtime type: string, int, long, real, bool, datetime, timespan, dynamic, array, dictionary, or null.

Use case examples

  • Log analysis
  • OpenTelemetry traces
  • Security logs
Identify the data types of fields to ensure proper query operations and data validation.Query
['sample-http-logs']
| extend status_type = gettype(status), 
         duration_type = gettype(req_duration_ms),
         time_type = gettype(_time)
| project status, status_type, req_duration_ms, duration_type, _time, time_type
| limit 10
Run in PlaygroundOutput
statusstatus_typereq_duration_msduration_type_timetime_type
200string145long2024-11-06T10:00:00Zdatetime
404string89long2024-11-06T10:01:00Zdatetime
500string234long2024-11-06T10:02:00Zdatetime
This query identifies the data types of key fields in HTTP logs, helping ensure that data is in the expected format for analysis and troubleshooting type-related query issues.
  • isnull: Checks if a value is null. Use this to specifically test for null values rather than getting the type.
  • isnotnull: Checks if a value is not null. Use this in filters when you need to exclude null values.
  • parse_json: Parses JSON strings into dynamic types. Use this before gettype when working with JSON data.