Comment on page
Transformation Functions
This document contains the list of all the transformation functions supported by Pinot SQL.
Function |
---|
Multiple string functions are supported out of the box from release-0.5.0 .
Function |
---|
SUBSTR(col, startIndex, endIndex)
Gets substring of the input string from start to endIndex. Index begins at 0. Set endIndex to -1 to calculate till end of the string |
STRPOS(col, find, N)
Find Nth instance of find string in input. Returns 0 if input string is empty. Returns -1 if the Nth instance is not found or input string is null. |
Date time functions allow you to perform transformations on columns that contain timestamps or dates.
Function |
---|
TIMECONVERT(col, fromUnit, toUnit)
Converts the value into another time unit. the column should be an epoch timestamp. |
DATETIMECONVERT(columnName, inputFormat, outputFormat, outputGranularity)
Converts the value into another date time format, and buckets time based on the given time granularity. |
DATETRUNC
Converts the value into a specified output granularity seconds since UTC epoch that is bucketed on a unit in a specified timezone. |
ToEpoch<TIME_UNIT>Rounded(timeInMillis, bucketSize)
Convert epoch milliseconds to epoch <Time Unit>, round to nearest rounding bucket(Bucket size is defined in <Time Unit>). |
ToEpoch<TIME_UNIT>Bucket(timeInMillis, bucketSize)
Convert epoch milliseconds to epoch <Time Unit>, and divided by bucket size(Bucket size is defined in <Time Unit>). |
FromEpoch<TIME_UNIT>Bucket(timeIn<Time_UNIT>, bucketSizeIn<Time_UNIT>)
Convert epoch <Bucket Size><Time Unit> to epoch milliseconds. |
ToDateTime(timeInMillis, pattern[, timezoneId])
Convert epoch millis value to DateTime string represented by pattern. |
FromDateTime(dateTimeString, pattern)
Convert DateTime string represented by pattern to epoch millis. |
yearOfWeek(tsInMillis)
Returns the year of the ISO week from the given epoch millis in UTC timezone. Alias yow is also supported. |
yearOfWeek(tsInMillis, timeZoneId)
Returns the year of the ISO week from the given epoch millis and timezone id. Alias yow is also supported. |
quarter(tsInMillis)
Returns the quarter of the year from the given epoch millis in UTC timezone. The value ranges from 1 to 4. |
quarter(tsInMillis, timeZoneId)
Returns the quarter of the year from the given epoch millis and timezone id. The value ranges from 1 to 4. |
month(tsInMillis)
Returns the month of the year from the given epoch millis in UTC timezone. The value ranges from 1 to 12. |
month(tsInMillis, timeZoneId)
Returns the month of the year from the given epoch millis and timezone id. The value ranges from 1 to 12. |
week(tsInMillis)
Returns the ISO week of the year from the given epoch millis in UTC timezone. The value ranges from 1 to 53. Alias weekOfYear is also supported. |
week(tsInMillis, timeZoneId)
Returns the ISO week of the year from the given epoch millis and timezone id. The value ranges from 1 to 53. Alias weekOfYear is also supported. |
dayOfYear(tsInMillis)
Returns the day of the year from the given epoch millis in UTC timezone. The value ranges from 1 to 366. Alias doy is also supported. |
dayOfYear(tsInMillis, timeZoneId)
Returns the day of the year from the given epoch millis and timezone id. The value ranges from 1 to 366. Alias doy is also supported. |
day(tsInMillis)
Returns the day of the month from the given epoch millis in UTC timezone. The value ranges from 1 to 31. Alias dayOfMonth is also supported. |
day(tsInMillis, timeZoneId)
Returns the day of the month from the given epoch millis and timezone id. The value ranges from 1 to 31. Alias dayOfMonth is also supported. |
dayOfWeek(tsInMillis)
Returns the day of the week from the given epoch millis in UTC timezone. The value ranges from 1(Monday) to 7(Sunday). Alias dow is also supported. |
dayOfWeek(tsInMillis, timeZoneId)
Returns the day of the week from the given epoch millis and timezone id. The value ranges from 1(Monday) to 7(Sunday). Alias dow is also supported. |
hour(tsInMillis)
Returns the hour of the day from the given epoch millis in UTC timezone. The value ranges from 0 to 23. |
hour(tsInMillis, timeZoneId)
Returns the hour of the day from the given epoch millis and timezone id. The value ranges from 0 to 23. |
minute(tsInMillis)
Returns the minute of the hour from the given epoch millis in UTC timezone. The value ranges from 0 to 59. |
minute(tsInMillis, timeZoneId)
Returns the minute of the hour from the given epoch millis and timezone id. The value ranges from 0 to 59. |
second(tsInMillis)
Returns the second of the minute from the given epoch millis in UTC timezone. The value ranges from 0 to 59. |
second(tsInMillis, timeZoneId)
Returns the second of the minute from the given epoch millis and timezone id. The value ranges from 0 to 59. |
millisecond(tsInMillis)
Returns the millisecond of the second from the given epoch millis in UTC timezone. The value ranges from 0 to 999. |
millisecond(tsInMillis, timeZoneId)
Returns the millisecond of the second from the given epoch millis and timezone id. The value ranges from 0 to 999. |
These functions can only be used in Pinot SQL queries.
Function |
---|
JSONEXTRACTSCALAR(jsonField, 'jsonPath', 'resultsType', [defaultValue])
Evaluates the 'jsonPath' on jsonField , returns the result as the type 'resultsType' , use optional defaultValue for null or parsing error. |
JSONEXTRACTKEY(jsonField, 'jsonPath')
Extracts all matched JSON field keys based on 'jsonPath' into a STRING_ARRAY. |
These functions can be used for column transformation in table ingestion configs.
Function |
---|
JSONPATH(jsonField, 'jsonPath')
Extracts the object value from jsonField based on 'jsonPath' , the result type is inferred based on JSON value. Cannot be used in query because data type is not specified. |
JSONPATHLONG(jsonField, 'jsonPath', [defaultValue])
Extracts the Long value from jsonField based on 'jsonPath' , use optional defaultValue for null or parsing error. |
JSONPATHDOUBLE(jsonField, 'jsonPath', [defaultValue])
Extracts the Double value from jsonField based on 'jsonPath' , use optional defaultValue for null or parsing error. |
JSONPATHSTRING(jsonField, 'jsonPath', [defaultValue])
Extracts the String value from jsonField based on 'jsonPath' , use optional defaultValue for null or parsing error. |
JSONPATHARRAY(jsonField, 'jsonPath')
Extracts an array from jsonField based on 'jsonPath' , the result type is inferred based on JSON value. Cannot be used in query because data type is not specified. |
JSONPATHARRAYDEFAULTEMPTY(jsonField, 'jsonPath')
Extracts an array from jsonField based on 'jsonPath' , the result type is inferred based on JSON value. Returns empty array for null or parsing error. Cannot be used in query because data type is not specified. |
Function |
---|
All of the functions mentioned till now only support single value columns. You can use the following functions to do operations on multi-value columns.
Function |
---|
MAP_VALUE
Select the value for a key from Map stored in Pinot.
MAP_VALUE(mapColumn, 'myKey', valueColumn) |
VALUEIN
The transform function will filter the value from the multi-valued column with the given constant values. The VALUEIN transform function is especially useful when the same multi-valued column is both filtering column and grouping column. |
Pinot supports Geospatial queries on columns containing text-based geographies. For more details on the queries and how to enable them, see Geospatial.
Pinot supports pattern matching on text-based columns. Only the columns mentioned as text columns in table config can be queried using this method. For more details on how to enable pattern matching, see Text search support.
Last modified 1yr ago