All native Presto functions can also be used on Treasure Data. For a complete list of functions, see Presto Function and Operators pages. Show
SignatureTD_APPROX_MOST_FREQUENT(long num_buckets, long/varchar values, long capacity) ExampleSELECT TD_APPROX_MOST_FREQUENT(3, values, 10); DescriptionThis function picks the frequent distinct items from the collection of values. This selection is approximate. The top `num_buckets` elements are obtained `values`. It returns a map whose keys are elements and values are estimated frequencies in the collection. Unlike a normal histogram, it selects the frequent values online to significantly save memory resources. The error rate is bounded by the capacity parameter controlling the size of the internal data structure. For convenience, we recommend using TD_INTERVAL instead of TD_TIME_RANGE. Signatureboolean TD_TIME_RANGE(int/long unix_timestamp, int/long/string start_time, int/long/string end_time [, string default_timezone = 'UTC']) ExampleThis example selects records with timestamps ‘2013-01-01 00:00:00 PDT’ or later. The time of day ('00:00:00') can be omitted. Alternately, the time of day can be specified up to seconds. In general, the time string should be formatted as 'YYYY-MM-DD' or 'YYYY-MM-DD hh:mm:ss'. For example, '2013-01-01' or '1999-01-01 07:00:00'. SELECT ... WHERE TD_TIME_RANGE(time, '2013-01-01 PDT') # OK SELECT ... WHERE TD_TIME_RANGE(time, '2013-01-01', '2013-01-02','PDT') # OK SELECT ... WHERE TD_TIME_RANGE(time, NULL, '2013-01-01', 'PDT') # OK SELECT ... WHERE TD_TIME_RANGE(time, '2013-01-01', NULL, 'PDT') # OK SELECT ... WHERE TD_TIME_RANGE(time, '2013-01-01', 'PDT') # NG DescriptionWe strongly recommend that you take advantage of time-based partitioning. Refer to Performance Tuning for more information. This UDF returns true if the unix_timestamp is equal to or later than the start_time and older than the end_time (start_time <= time && time < end_time). If end_time is omitted or NULL, the UDF assumes it’s infinite. If start_time is NULL, the UDF assumes it’s 0. start_time and end_time can be a string that represents a time (e.g. ‘2012-01-01 00:00:00 +0900’) or a UNIX timestamp (e.g. 1325343600). If the format of start_time or end_time strings is invalid, the UDF returns NULL. default_timezone is used to interpret the timezone of start_time or end_time. If start_time or end_time themselves specify a timezone (e.g. ‘2012-01-01 +0700’), then the default_timezone is ignored. If default_timezone is not specified and start_time or end_time does not indicate a timezone, then the UDF uses ‘UTC’ as the timezone for start_time or end_time. A list of supported time zones. SignatureDescriptionThis UDF returns the exact time when the job was scheduled by the scheduled query feature. The returned value can differ from SELECT ... WHERE TD_TIME_RANGE(time, '2013-01-01', TD_TIME_ADD('2013-01-01', '1d'))0 because the actual query start time might be delayed. If the query is not a scheduled query, the UDF returns the time when the job was issued. You can use this UDF with SELECT ... WHERE TD_TIME_RANGE(time, '2013-01-01', TD_TIME_ADD('2013-01-01', '1d'))1 for incremental aggregation. TD_INTERVAL() is a companion function to TD_TIME_RANGE(). Both are especially useful in WHERE clauses, to make sure that your queries take advantage of time-based partitioning. TD_INTERVAL is used to compute relative time ranges that would otherwise require complex date manipulation. (TD_TIME_RANGE is used for absolute time ranges.) SignatureTD_INTERVAL(time, interval_string, default_timezone) boolean TD_INTERVAL(int/long time, string interval_string, [, string default_timezone = 'UTC']) ExampleThese examples assume that the scheduled_time (or query start time) is 2018-08-14 01:23:45 (Tue, UTC): # The last 7 days [2018-08-07 00:00:00, 2018-08-14 00:00:00) SELECT ... WHERE TD_INTERVAL(time, '-7d') # The last week. Monday is the beginning of the week (ISO standard) [2018-08-05 00:00:00, 2018-08-13 00:00:00) SELECT ... WHERE TD_INTERVAL(time, '-1w') # Today [2018-08-14 00:00:00, 2018-08-15 00:00:00) SELECT ... WHERE TD_INTERVAL(time, '1d') # The last month [2018-07-01 00:00:00, 2018-08-01 00:00:00) SELECT ... WHERE TD_INTERVAL(time, '-1M') # This month [2018-08-01 00:00:00, 2018-09-01 00:00:00) SELECT ... WHERE TD_INTERVAL(time, '1M') # This year [2018-01-01 00:00:00, 2019-01-01 00:00:00) SELECT ... WHERE TD_INTERVAL(time, '1y') # The last 15 minutes [2018-08-14 00:08:00, 2018-08-14 01:23:00) SELECT ... WHERE TD_INTERVAL(time, '-15m') # The last 30 seconds [2018-08-14 01:23:15, 2018-08-14 01:23:45) SELECT ... WHERE TD_INTERVAL(time, '-30s') # The last hour [2018-08-14 00:00:00, 2018-08-14 01:00:00) SELECT ... WHERE TD_INTERVAL(time, '-1h') # From the last hour to now [2018-08-14 00:00:00, 2018-08-14 01:23:45) SELECT ... WHERE TD_INTERVAL(time, '-1h/now') # The last hour since the beginning of today [2018-08-13 23:00:00, 2018-08-14 00:00:00) SELECT ... WHERE TD_INTERVAL(time, '-1h/0d') # The last 7 days since 2015-12-25 [2015-12-18 00:00:00, 2015-12-25 00:00:00) SELECT ... WHERE TD_INTERVAL(time, '-7d/2015-12-25') # The last 10 days since the beginning of the last month [2018-06-21 00:00:00, 2018-07-01 00:00:00) SELECT ... WHERE TD_INTERVAL(time, '-10d/-1M') # The last 7 days in JST SELECT ... WHERE TD_INTERVAL(time, '-7d', 'JST') DescriptionTD_INTERVAL() is a companion function to TD_TIME_RANGE(). Both are especially useful in WHERE clauses, to make sure that your queries take advantage of time-based partitioning. TD_INTERVAL is used to compute relative time ranges that would otherwise require complex date manipulation. (TD_TIME_RANGE is used for absolute time ranges.) We strongly recommend that you take advantage of time-based partitioning. Refer to the Performance Tuning article for more information. Not using time-based filtering in SQL SELECT statements can cause inefficient full table scans that affect query performance. This UDF returns true if time value is within the interval which is represented by interval_string (state time <= time < end time). interval_string must be a 'duration/offset' formatted string. The offset is optional and the UDF assumes offset is the current time (the job scheduled time actually) based on your browser timezone, if the offset is omitted. Also, support 'q' for quarters. For example, '-1d' means yesterday and '-3M' means the last 3 months. The interval is calculated in the specified time unit. This means '-30m' ls the last 30 minutes from the beginning of the latest minute, not from just now. Offset can be specified relatively (e.g. '3d/-1y') and specifically (e.g. '1y/2018-01-01'). For example, '3d/-1y' means the first 3 days of the last year and '-1M/2018-04-01' means the last 1 month before '2018-04-01'. In other words, '2018-03-01' to '2018-03-31'. Offset can be specified as '/now' (e.g. '-7d/now'). Note the difference from '/0d' or '/0h' illustrated in the following figure: default_timezone is used to interpret the timezone of interval_string. If interval_string specifies a timezone (e.g. '-1h/2017-01-23 01:00:00 +0700'), then the default_timezone is ignored. If default_timezone is not specified and interval_string does not have a timezone, then UDF uses 'UTC' as the timezone. A list of supported time zones can be found here. SignatureTD_INTERVAL_RANGE(‘interval string’, ‘time zone’) DescriptionTD_INTERVAL_RANGE can be used to confirm the time range of TD_INTERVAL. TD_INTERVAL_RANGE returns an ARRAY[(start time), (end time)]. interval_string must be a 'duration/offset' formatted string. The offset is optional and the UDF assumes offset is the current time (the job scheduled time actually) based on your browser timezone, if the offset is omitted. Also, support 'q' for quarters. time zone is used to interpret the timezone of interval_string. If interval_string specifies a timezone (e.g. '-1h/2017-01-23 01:00:00 +0700'), then time zone is ignored. If the time zone is not specified and interval_string does not have a timezone, then UDF uses 'UTC' as the timezone. A list of supported time zones can be found here. Signaturelong TD_TIME_ADD(int/long/string time, string duration [, string default_timezone = 'UTC']) ExampleThis example selects records with timestamps ‘2013-01-01 00:00:00 UTC’ or later but older than ‘2013-01-02 00:00:00 UTC’. SELECT ... WHERE TD_TIME_RANGE(time, '2013-01-01', TD_TIME_ADD('2013-01-01', '1d')) DescriptionTD_TIME_ADD returns a timestamp equal to time offset by duration. The UDF supports the following formats for the duration:
The formats above can be combined. For example, ‘1h30m’ means ‘after 1 hour and 30 minutes’. default_timezone is used to interpret time. If time has timezone (e.g. ‘2012-01-01 +0700’), then default_timezone is ignored. If default_timezone is not specified and time does not specify a timezone, then the UDF uses ‘UTC’ as the timezone for time. A list of supported time zones can be found here. If the formats of the time or duration strings are invalid, the UDF returns NULL. 'year' and 'month' durations are NOT supported, because to do so would adversely impact performance. A month can be 28, 29, 30, or 31 days, and a year could be 365 or 366 days. For convenience, we recommend using TD_TIME_STRING instead of TD_TIME_FORMAT. Signaturestring TD_TIME_FORMAT(long unix_timestamp, string format [, string timezone = 'UTC']) ExampleThis example formats a UNIX timestamp into a date formatted string: SELECT TD_TIME_FORMAT(time, 'yyyy-MM-dd HH:mm:ss z') ... FROM ... SELECT TD_TIME_FORMAT(time, 'yyyy-MM-dd HH:mm:ss z', 'PST') ... FROM ... SELECT TD_TIME_FORMAT(time, 'yyyy-MM-dd HH:mm:ss z', 'JST') ... FROM ... DescriptionTD_TIME_FORMAT converts a UNIX timestamp to a string with the specified format (see the Supported time formats in TD_TIME_FORMAT UDF page for available formats). For example, ‘yyyy-MM-dd HH:mm:ss z’ converts 1325376000 to ‘2012-01-01 00:00:00 UTC’. If no timezone is specified, the UDF uses UTC. How does TD_TIME_FORMAT handle Leap Second?SELECT TD_APPROX_MOST_FREQUENT(3, values, 10);0 SignatureSELECT TD_APPROX_MOST_FREQUENT(3, values, 10);1 DescriptionThis UDF converts a time string into a UNIX timestamp. default_timezone is used to interpret time. If time has timezone (e.g. ‘2012-01-01 +0700’), then default_timezone is ignored. If default_timezone is not specified and time does not specify a timezone, then the UDF uses ‘UTC’ as the timezone for time. A list of supported time zones can be found here. If the format of the time string is invalid, the UDF returns NULL. For convenience, we recommend TD_TIME_STRING over TD_TIME_FORMAT. SELECT TD_APPROX_MOST_FREQUENT(3, values, 10);2
If the format string has SELECT ... WHERE TD_TIME_RANGE(time, '2013-01-01', TD_TIME_ADD('2013-01-01', '1d'))2 as the suffix, it truncates the date time string at the specified unit. format string format example y yyyy-MM-dd HH:mm:ssZ 2018-01-01 00:00:00+0700 q yyyy-MM-dd HH:mm:ssZ 2018-04-01 00:00:00+0700 M yyyy-MM-dd HH:mm:ssZ 2018-09-01 00:00:00+0700 w yyyy-MM-dd HH:mm:ssZ 2018-09-09 00:00:00+0700 d yyyy-MM-dd HH:mm:ssZ 2018-09-13 00:00:00+0700 h yyyy-MM-dd HH:mm:ssZ 2018-09-13 16:00:00+0700 m yyyy-MM-dd HH:mm:ssZ 2018-09-13 16:45:00+0700 s yyyy-MM-dd HH:mm:ssZ 2018-09-13 16:45:34+0700 y! yyyy 2018 q! yyyy-MM 2018-04 M! yyyy-MM 2018-09 w! yyyy-MM-dd 2018-09-09 d! yyyy-MM-dd 2018-09-13 h! yyyy-MM-dd HH 2018-09-13 16 m! yyyy-MM-dd HH:mm 2018-09-13 16:45 s! yyyy-MM-dd HH:mm:ss 2018-09-13 16:45:34 If there is no SELECT ... WHERE TD_TIME_RANGE(time, '2013-01-01', TD_TIME_ADD('2013-01-01', '1d'))2, the return value should be the same as: SELECT TD_APPROX_MOST_FREQUENT(3, values, 10);3 SignatureSELECT TD_APPROX_MOST_FREQUENT(3, values, 10);4 DescriptionThis UDF performs a timestamp truncation at the level specified by the ‘unit’ parameter. The supported units are:
An optional ‘timezone’ parameter can be specified to indicate an alternative reference timezone for the ‘unit’. If the input ‘time’ is in global UNIX time format, in different timezones, the start of a day corresponds to different times. This function mimics the functionality of native Presto’s SELECT ... WHERE TD_TIME_RANGE(time, '2013-01-01', TD_TIME_ADD('2013-01-01', '1d'))4 function. However, Presto’s SELECT ... WHERE TD_TIME_RANGE(time, '2013-01-01', TD_TIME_ADD('2013-01-01', '1d'))4 does not allow specification of the timezone. ExampleSELECT TD_APPROX_MOST_FREQUENT(3, values, 10);5 with SELECT ... WHERE TD_TIME_RANGE(time, '2013-01-01', TD_TIME_ADD('2013-01-01', '1d'))6 equal SELECT ... WHERE TD_TIME_RANGE(time, '2013-01-01', TD_TIME_ADD('2013-01-01', '1d'))7 corresponding to ‘ SELECT ... WHERE TD_TIME_RANGE(time, '2013-01-01', TD_TIME_ADD('2013-01-01', '1d'))8’ returns SELECT ... WHERE TD_TIME_RANGE(time, '2013-01-01', TD_TIME_ADD('2013-01-01', '1d'))9 corresponding to ‘ string TD_TIME_FORMAT(long unix_timestamp, string format [, string timezone = 'UTC'])0’. With the same value and timezone ‘PST’ instead, SELECT TD_APPROX_MOST_FREQUENT(3, values, 10);6 the function returns 1416729600 because the start of the day for the ‘PST’ timezone is 8 hours behind the start of the day for ‘UTC’. SignatureSELECT TD_APPROX_MOST_FREQUENT(3, values, 10);7 DescriptionSessionization of a table of event data groups a series of event rows associated with users into individual sessions for analysis. The series of events to be grouped into a session must be associated with the same user identifier (typically IP address, email, cookie, or similar identifier) and events are separated by no more than a chosen timeout interval. TD_SESSIONIZE_WINDOW is a UDF window function used for sessionization. It replaces TD_SESSIONIZE. TD_SESSIONIZE_WINDOW provides consistent results and better performance. TD_SESSIONIZE_WINDOW takes two arguments:
Other usage notes:
ExampleThe following example is equivalent to the SELECT statement example in the deprecated TD_SESSIONIZE. SELECT TD_APPROX_MOST_FREQUENT(3, values, 10);8 SignatureSELECT TD_APPROX_MOST_FREQUENT(3, values, 10);9 DescriptionThis UDF returns the result of parsing a user agent string. The user agent is parsed on the basis of rules. Where options are: Options Accepts Returns os sting JSON os_family string string os_major string string os_minor string string ua string JSON ua_family string string ua_major string string ua_minor string string device string string ExampleThe example shows the result of parsing user agent from access log. boolean TD_TIME_RANGE(int/long unix_timestamp, int/long/string start_time, int/long/string end_time [, string default_timezone = 'UTC'])0 This UDF returns a Map value of results to parse a user agent string. The UDF is implemented by Woothee. Signatureboolean TD_TIME_RANGE(int/long unix_timestamp, int/long/string start_time, int/long/string end_time [, string default_timezone = 'UTC'])1 ExampleThe example shows the result of parsing the user agent from an access log. If you want to extract a specific ‘key’ from the user agent map. TD recommends using the string TD_TIME_FORMAT(long unix_timestamp, string format [, string timezone = 'UTC'])1 presto function because it is tolerant of non-existent keys. Extracting keys with the string TD_TIME_FORMAT(long unix_timestamp, string format [, string timezone = 'UTC'])2 operator (e.g. string TD_TIME_FORMAT(long unix_timestamp, string format [, string timezone = 'UTC'])3 will throw an error if the sought after the key is not present in the map. boolean TD_TIME_RANGE(int/long unix_timestamp, int/long/string start_time, int/long/string end_time [, string default_timezone = 'UTC'])2 SignatureDescriptionThis UDF calculates the MD5 hash digest from a given string. Exampleboolean TD_TIME_RANGE(int/long unix_timestamp, int/long/string start_time, int/long/string end_time [, string default_timezone = 'UTC'])3 TD_URL_DECODE supports URL decoding for a given string and euc-kr (extended unix code for Korean). URL DecodingSignatureboolean TD_TIME_RANGE(int/long unix_timestamp, int/long/string start_time, int/long/string end_time [, string default_timezone = 'UTC'])4 Descriptionstring TD_TIME_FORMAT(long unix_timestamp, string format [, string timezone = 'UTC'])4applies URL decoding for a given string. This UDF returns string TD_TIME_FORMAT(long unix_timestamp, string format [, string timezone = 'UTC'])5 if a character is string TD_TIME_FORMAT(long unix_timestamp, string format [, string timezone = 'UTC'])6 or string TD_TIME_FORMAT(long unix_timestamp, string format [, string timezone = 'UTC'])7, or string TD_TIME_FORMAT(long unix_timestamp, string format [, string timezone = 'UTC'])8. This UDF is similar to URL_DECODE(col). Exampleboolean TD_TIME_RANGE(int/long unix_timestamp, int/long/string start_time, int/long/string end_time [, string default_timezone = 'UTC'])5 URL EUC-KRSignatureboolean TD_TIME_RANGE(int/long unix_timestamp, int/long/string start_time, int/long/string end_time [, string default_timezone = 'UTC'])6 Descriptionstring TD_TIME_FORMAT(long unix_timestamp, string format [, string timezone = 'UTC'])4applies URL decoding for a given URL. Example boolean TD_TIME_RANGE(int/long unix_timestamp, int/long/string start_time, int/long/string end_time [, string default_timezone = 'UTC'])7 Signatureboolean TD_TIME_RANGE(int/long unix_timestamp, int/long/string start_time, int/long/string end_time [, string default_timezone = 'UTC'])8 DescriptionThis UDF calculates the variable-length digest from a given string. It usually generates 6-10 characters of digest from the given string. Due to the higher compression ratio, there is a higher collision ratio, around 5% on average. If you want to avoid the collisions, increase the value of the weight parameter. Exampleboolean TD_TIME_RANGE(int/long unix_timestamp, int/long/string start_time, int/long/string end_time [, string default_timezone = 'UTC'])9 SignatureSELECT ... WHERE TD_TIME_RANGE(time, '2013-01-01 PDT') # OK SELECT ... WHERE TD_TIME_RANGE(time, '2013-01-01', '2013-01-02','PDT') # OK SELECT ... WHERE TD_TIME_RANGE(time, NULL, '2013-01-01', 'PDT') # OK SELECT ... WHERE TD_TIME_RANGE(time, '2013-01-01', NULL, 'PDT') # OK SELECT ... WHERE TD_TIME_RANGE(time, '2013-01-01', 'PDT') # NG0 DescriptionThis UDF converts currency for the specific date, by accessing the currency exchange rate database. ExampleSELECT ... WHERE TD_TIME_RANGE(time, '2013-01-01 PDT') # OK SELECT ... WHERE TD_TIME_RANGE(time, '2013-01-01', '2013-01-02','PDT') # OK SELECT ... WHERE TD_TIME_RANGE(time, NULL, '2013-01-01', 'PDT') # OK SELECT ... WHERE TD_TIME_RANGE(time, '2013-01-01', NULL, 'PDT') # OK SELECT ... WHERE TD_TIME_RANGE(time, '2013-01-01', 'PDT') # NG1 Both Hive and Presto UDFs use a geolocation database supplied by Maxmind. Due to release schedules, the release level of the Maxmind database used by Hive and Presto might be different. This might cause inconsistent results between Hive and Presto geolocation functions. An example of different results is as follows: jobid type td_ip_to_city_name_v6 td_ip_to_latitude_v6 td_ip_to_longitude_v6 td_ip_to_postal_code_v6 218018944 hive Tokyo 35.685 139.7514 102-0082 218019099 presto 35.6594 139.8533 134-0087 SignatureSELECT ... WHERE TD_TIME_RANGE(time, '2013-01-01 PDT') # OK SELECT ... WHERE TD_TIME_RANGE(time, '2013-01-01', '2013-01-02','PDT') # OK SELECT ... WHERE TD_TIME_RANGE(time, NULL, '2013-01-01', 'PDT') # OK SELECT ... WHERE TD_TIME_RANGE(time, '2013-01-01', NULL, 'PDT') # OK SELECT ... WHERE TD_TIME_RANGE(time, '2013-01-01', 'PDT') # NG2 DescriptionThis UDF converts IP address to country code. This UDF supports IPv4 and IPv6. ExampleSELECT ... WHERE TD_TIME_RANGE(time, '2013-01-01 PDT') # OK SELECT ... WHERE TD_TIME_RANGE(time, '2013-01-01', '2013-01-02','PDT') # OK SELECT ... WHERE TD_TIME_RANGE(time, NULL, '2013-01-01', 'PDT') # OK SELECT ... WHERE TD_TIME_RANGE(time, '2013-01-01', NULL, 'PDT') # OK SELECT ... WHERE TD_TIME_RANGE(time, '2013-01-01', 'PDT') # NG3 The function returns SELECT TD_TIME_FORMAT(time, 'yyyy-MM-dd HH:mm:ss z') ... FROM ... SELECT TD_TIME_FORMAT(time, 'yyyy-MM-dd HH:mm:ss z', 'PST') ... FROM ... SELECT TD_TIME_FORMAT(time, 'yyyy-MM-dd HH:mm:ss z', 'JST') ... FROM ...0 in this example. SignatureSELECT ... WHERE TD_TIME_RANGE(time, '2013-01-01 PDT') # OK SELECT ... WHERE TD_TIME_RANGE(time, '2013-01-01', '2013-01-02','PDT') # OK SELECT ... WHERE TD_TIME_RANGE(time, NULL, '2013-01-01', 'PDT') # OK SELECT ... WHERE TD_TIME_RANGE(time, '2013-01-01', NULL, 'PDT') # OK SELECT ... WHERE TD_TIME_RANGE(time, '2013-01-01', 'PDT') # NG4 DescriptionThis UDF converts IP address to country code. This UDF supports IPv4 and IPv6. ExampleSELECT ... WHERE TD_TIME_RANGE(time, '2013-01-01 PDT') # OK SELECT ... WHERE TD_TIME_RANGE(time, '2013-01-01', '2013-01-02','PDT') # OK SELECT ... WHERE TD_TIME_RANGE(time, NULL, '2013-01-01', 'PDT') # OK SELECT ... WHERE TD_TIME_RANGE(time, '2013-01-01', NULL, 'PDT') # OK SELECT ... WHERE TD_TIME_RANGE(time, '2013-01-01', 'PDT') # NG5 The function returns SELECT TD_TIME_FORMAT(time, 'yyyy-MM-dd HH:mm:ss z') ... FROM ... SELECT TD_TIME_FORMAT(time, 'yyyy-MM-dd HH:mm:ss z', 'PST') ... FROM ... SELECT TD_TIME_FORMAT(time, 'yyyy-MM-dd HH:mm:ss z', 'JST') ... FROM ...1 in this example. SignatureSELECT ... WHERE TD_TIME_RANGE(time, '2013-01-01 PDT') # OK SELECT ... WHERE TD_TIME_RANGE(time, '2013-01-01', '2013-01-02','PDT') # OK SELECT ... WHERE TD_TIME_RANGE(time, NULL, '2013-01-01', 'PDT') # OK SELECT ... WHERE TD_TIME_RANGE(time, '2013-01-01', NULL, 'PDT') # OK SELECT ... WHERE TD_TIME_RANGE(time, '2013-01-01', 'PDT') # NG6 DescriptionThis UDF converts IP address to a list of subdivisions (e.g. US states, JP prefectures, etc). This UDF supports IPv4 and IPv6. ExampleSELECT ... WHERE TD_TIME_RANGE(time, '2013-01-01 PDT') # OK SELECT ... WHERE TD_TIME_RANGE(time, '2013-01-01', '2013-01-02','PDT') # OK SELECT ... WHERE TD_TIME_RANGE(time, NULL, '2013-01-01', 'PDT') # OK SELECT ... WHERE TD_TIME_RANGE(time, '2013-01-01', NULL, 'PDT') # OK SELECT ... WHERE TD_TIME_RANGE(time, '2013-01-01', 'PDT') # NG7 SignatureSELECT ... WHERE TD_TIME_RANGE(time, '2013-01-01 PDT') # OK SELECT ... WHERE TD_TIME_RANGE(time, '2013-01-01', '2013-01-02','PDT') # OK SELECT ... WHERE TD_TIME_RANGE(time, NULL, '2013-01-01', 'PDT') # OK SELECT ... WHERE TD_TIME_RANGE(time, '2013-01-01', NULL, 'PDT') # OK SELECT ... WHERE TD_TIME_RANGE(time, '2013-01-01', 'PDT') # NG8 DescriptionThis UDF converts IP address to the most specific subdivisions (e.g. US states, JP prefectures, etc). This UDF supports IPv4 and IPv6. ExampleSELECT ... WHERE TD_TIME_RANGE(time, '2013-01-01 PDT') # OK SELECT ... WHERE TD_TIME_RANGE(time, '2013-01-01', '2013-01-02','PDT') # OK SELECT ... WHERE TD_TIME_RANGE(time, NULL, '2013-01-01', 'PDT') # OK SELECT ... WHERE TD_TIME_RANGE(time, '2013-01-01', NULL, 'PDT') # OK SELECT ... WHERE TD_TIME_RANGE(time, '2013-01-01', 'PDT') # NG9 Signatureboolean TD_INTERVAL(int/long time, string interval_string, [, string default_timezone = 'UTC'])0 DescriptionThis UDF converts IP address to the least specific subdivisions (e.g. US states, JP prefectures, etc). This UDF supports IPv4 and IPv6. Exampleboolean TD_INTERVAL(int/long time, string interval_string, [, string default_timezone = 'UTC'])1 Signatureboolean TD_INTERVAL(int/long time, string interval_string, [, string default_timezone = 'UTC'])2 DescriptionThis UDF converts IP address to city name. This UDF supports IPv4 and IPv6. Exampleboolean TD_INTERVAL(int/long time, string interval_string, [, string default_timezone = 'UTC'])3 Signatureboolean TD_INTERVAL(int/long time, string interval_string, [, string default_timezone = 'UTC'])4 DescriptionThis UDF converts IP address to latitude. This UDF supports IPv4 and IPv6. Exampleboolean TD_INTERVAL(int/long time, string interval_string, [, string default_timezone = 'UTC'])5 Signatureboolean TD_INTERVAL(int/long time, string interval_string, [, string default_timezone = 'UTC'])6 DescriptionThis UDF converts IP address to longitude. This UDF supports IPv4 and IPv6. Exampleboolean TD_INTERVAL(int/long time, string interval_string, [, string default_timezone = 'UTC'])7 Signatureboolean TD_INTERVAL(int/long time, string interval_string, [, string default_timezone = 'UTC'])8 DescriptionThis UDF converts IP address to metro code (US Only). This UDF supports IPv4 and IPv6. Exampleboolean TD_INTERVAL(int/long time, string interval_string, [, string default_timezone = 'UTC'])9 Signature# The last 7 days [2018-08-07 00:00:00, 2018-08-14 00:00:00) SELECT ... WHERE TD_INTERVAL(time, '-7d') # The last week. Monday is the beginning of the week (ISO standard) [2018-08-05 00:00:00, 2018-08-13 00:00:00) SELECT ... WHERE TD_INTERVAL(time, '-1w') # Today [2018-08-14 00:00:00, 2018-08-15 00:00:00) SELECT ... WHERE TD_INTERVAL(time, '1d') # The last month [2018-07-01 00:00:00, 2018-08-01 00:00:00) SELECT ... WHERE TD_INTERVAL(time, '-1M') # This month [2018-08-01 00:00:00, 2018-09-01 00:00:00) SELECT ... WHERE TD_INTERVAL(time, '1M') # This year [2018-01-01 00:00:00, 2019-01-01 00:00:00) SELECT ... WHERE TD_INTERVAL(time, '1y') # The last 15 minutes [2018-08-14 00:08:00, 2018-08-14 01:23:00) SELECT ... WHERE TD_INTERVAL(time, '-15m') # The last 30 seconds [2018-08-14 01:23:15, 2018-08-14 01:23:45) SELECT ... WHERE TD_INTERVAL(time, '-30s') # The last hour [2018-08-14 00:00:00, 2018-08-14 01:00:00) SELECT ... WHERE TD_INTERVAL(time, '-1h') # From the last hour to now [2018-08-14 00:00:00, 2018-08-14 01:23:45) SELECT ... WHERE TD_INTERVAL(time, '-1h/now') # The last hour since the beginning of today [2018-08-13 23:00:00, 2018-08-14 00:00:00) SELECT ... WHERE TD_INTERVAL(time, '-1h/0d') # The last 7 days since 2015-12-25 [2015-12-18 00:00:00, 2015-12-25 00:00:00) SELECT ... WHERE TD_INTERVAL(time, '-7d/2015-12-25') # The last 10 days since the beginning of the last month [2018-06-21 00:00:00, 2018-07-01 00:00:00) SELECT ... WHERE TD_INTERVAL(time, '-10d/-1M') # The last 7 days in JST SELECT ... WHERE TD_INTERVAL(time, '-7d', 'JST')0 DescriptionThis UDF converts IP address to time zone. This UDF supports IPv4 and IPv6. Example# The last 7 days [2018-08-07 00:00:00, 2018-08-14 00:00:00) SELECT ... WHERE TD_INTERVAL(time, '-7d') # The last week. Monday is the beginning of the week (ISO standard) [2018-08-05 00:00:00, 2018-08-13 00:00:00) SELECT ... WHERE TD_INTERVAL(time, '-1w') # Today [2018-08-14 00:00:00, 2018-08-15 00:00:00) SELECT ... WHERE TD_INTERVAL(time, '1d') # The last month [2018-07-01 00:00:00, 2018-08-01 00:00:00) SELECT ... WHERE TD_INTERVAL(time, '-1M') # This month [2018-08-01 00:00:00, 2018-09-01 00:00:00) SELECT ... WHERE TD_INTERVAL(time, '1M') # This year [2018-01-01 00:00:00, 2019-01-01 00:00:00) SELECT ... WHERE TD_INTERVAL(time, '1y') # The last 15 minutes [2018-08-14 00:08:00, 2018-08-14 01:23:00) SELECT ... WHERE TD_INTERVAL(time, '-15m') # The last 30 seconds [2018-08-14 01:23:15, 2018-08-14 01:23:45) SELECT ... WHERE TD_INTERVAL(time, '-30s') # The last hour [2018-08-14 00:00:00, 2018-08-14 01:00:00) SELECT ... WHERE TD_INTERVAL(time, '-1h') # From the last hour to now [2018-08-14 00:00:00, 2018-08-14 01:23:45) SELECT ... WHERE TD_INTERVAL(time, '-1h/now') # The last hour since the beginning of today [2018-08-13 23:00:00, 2018-08-14 00:00:00) SELECT ... WHERE TD_INTERVAL(time, '-1h/0d') # The last 7 days since 2015-12-25 [2015-12-18 00:00:00, 2015-12-25 00:00:00) SELECT ... WHERE TD_INTERVAL(time, '-7d/2015-12-25') # The last 10 days since the beginning of the last month [2018-06-21 00:00:00, 2018-07-01 00:00:00) SELECT ... WHERE TD_INTERVAL(time, '-10d/-1M') # The last 7 days in JST SELECT ... WHERE TD_INTERVAL(time, '-7d', 'JST')1 Signature# The last 7 days [2018-08-07 00:00:00, 2018-08-14 00:00:00) SELECT ... WHERE TD_INTERVAL(time, '-7d') # The last week. Monday is the beginning of the week (ISO standard) [2018-08-05 00:00:00, 2018-08-13 00:00:00) SELECT ... WHERE TD_INTERVAL(time, '-1w') # Today [2018-08-14 00:00:00, 2018-08-15 00:00:00) SELECT ... WHERE TD_INTERVAL(time, '1d') # The last month [2018-07-01 00:00:00, 2018-08-01 00:00:00) SELECT ... WHERE TD_INTERVAL(time, '-1M') # This month [2018-08-01 00:00:00, 2018-09-01 00:00:00) SELECT ... WHERE TD_INTERVAL(time, '1M') # This year [2018-01-01 00:00:00, 2019-01-01 00:00:00) SELECT ... WHERE TD_INTERVAL(time, '1y') # The last 15 minutes [2018-08-14 00:08:00, 2018-08-14 01:23:00) SELECT ... WHERE TD_INTERVAL(time, '-15m') # The last 30 seconds [2018-08-14 01:23:15, 2018-08-14 01:23:45) SELECT ... WHERE TD_INTERVAL(time, '-30s') # The last hour [2018-08-14 00:00:00, 2018-08-14 01:00:00) SELECT ... WHERE TD_INTERVAL(time, '-1h') # From the last hour to now [2018-08-14 00:00:00, 2018-08-14 01:23:45) SELECT ... WHERE TD_INTERVAL(time, '-1h/now') # The last hour since the beginning of today [2018-08-13 23:00:00, 2018-08-14 00:00:00) SELECT ... WHERE TD_INTERVAL(time, '-1h/0d') # The last 7 days since 2015-12-25 [2015-12-18 00:00:00, 2015-12-25 00:00:00) SELECT ... WHERE TD_INTERVAL(time, '-7d/2015-12-25') # The last 10 days since the beginning of the last month [2018-06-21 00:00:00, 2018-07-01 00:00:00) SELECT ... WHERE TD_INTERVAL(time, '-10d/-1M') # The last 7 days in JST SELECT ... WHERE TD_INTERVAL(time, '-7d', 'JST')2 DescriptionThis UDF converts IP address to postal code. This UDF supports IPv4 and IPv6. Example# The last 7 days [2018-08-07 00:00:00, 2018-08-14 00:00:00) SELECT ... WHERE TD_INTERVAL(time, '-7d') # The last week. Monday is the beginning of the week (ISO standard) [2018-08-05 00:00:00, 2018-08-13 00:00:00) SELECT ... WHERE TD_INTERVAL(time, '-1w') # Today [2018-08-14 00:00:00, 2018-08-15 00:00:00) SELECT ... WHERE TD_INTERVAL(time, '1d') # The last month [2018-07-01 00:00:00, 2018-08-01 00:00:00) SELECT ... WHERE TD_INTERVAL(time, '-1M') # This month [2018-08-01 00:00:00, 2018-09-01 00:00:00) SELECT ... WHERE TD_INTERVAL(time, '1M') # This year [2018-01-01 00:00:00, 2019-01-01 00:00:00) SELECT ... WHERE TD_INTERVAL(time, '1y') # The last 15 minutes [2018-08-14 00:08:00, 2018-08-14 01:23:00) SELECT ... WHERE TD_INTERVAL(time, '-15m') # The last 30 seconds [2018-08-14 01:23:15, 2018-08-14 01:23:45) SELECT ... WHERE TD_INTERVAL(time, '-30s') # The last hour [2018-08-14 00:00:00, 2018-08-14 01:00:00) SELECT ... WHERE TD_INTERVAL(time, '-1h') # From the last hour to now [2018-08-14 00:00:00, 2018-08-14 01:23:45) SELECT ... WHERE TD_INTERVAL(time, '-1h/now') # The last hour since the beginning of today [2018-08-13 23:00:00, 2018-08-14 00:00:00) SELECT ... WHERE TD_INTERVAL(time, '-1h/0d') # The last 7 days since 2015-12-25 [2015-12-18 00:00:00, 2015-12-25 00:00:00) SELECT ... WHERE TD_INTERVAL(time, '-7d/2015-12-25') # The last 10 days since the beginning of the last month [2018-06-21 00:00:00, 2018-07-01 00:00:00) SELECT ... WHERE TD_INTERVAL(time, '-10d/-1M') # The last 7 days in JST SELECT ... WHERE TD_INTERVAL(time, '-7d', 'JST')3 Signature# The last 7 days [2018-08-07 00:00:00, 2018-08-14 00:00:00) SELECT ... WHERE TD_INTERVAL(time, '-7d') # The last week. Monday is the beginning of the week (ISO standard) [2018-08-05 00:00:00, 2018-08-13 00:00:00) SELECT ... WHERE TD_INTERVAL(time, '-1w') # Today [2018-08-14 00:00:00, 2018-08-15 00:00:00) SELECT ... WHERE TD_INTERVAL(time, '1d') # The last month [2018-07-01 00:00:00, 2018-08-01 00:00:00) SELECT ... WHERE TD_INTERVAL(time, '-1M') # This month [2018-08-01 00:00:00, 2018-09-01 00:00:00) SELECT ... WHERE TD_INTERVAL(time, '1M') # This year [2018-01-01 00:00:00, 2019-01-01 00:00:00) SELECT ... WHERE TD_INTERVAL(time, '1y') # The last 15 minutes [2018-08-14 00:08:00, 2018-08-14 01:23:00) SELECT ... WHERE TD_INTERVAL(time, '-15m') # The last 30 seconds [2018-08-14 01:23:15, 2018-08-14 01:23:45) SELECT ... WHERE TD_INTERVAL(time, '-30s') # The last hour [2018-08-14 00:00:00, 2018-08-14 01:00:00) SELECT ... WHERE TD_INTERVAL(time, '-1h') # From the last hour to now [2018-08-14 00:00:00, 2018-08-14 01:23:45) SELECT ... WHERE TD_INTERVAL(time, '-1h/now') # The last hour since the beginning of today [2018-08-13 23:00:00, 2018-08-14 00:00:00) SELECT ... WHERE TD_INTERVAL(time, '-1h/0d') # The last 7 days since 2015-12-25 [2015-12-18 00:00:00, 2015-12-25 00:00:00) SELECT ... WHERE TD_INTERVAL(time, '-7d/2015-12-25') # The last 10 days since the beginning of the last month [2018-06-21 00:00:00, 2018-07-01 00:00:00) SELECT ... WHERE TD_INTERVAL(time, '-10d/-1M') # The last 7 days in JST SELECT ... WHERE TD_INTERVAL(time, '-7d', 'JST')4 DescriptionThis UDF converts IP address to connection type. This UDF supports IPv4 and IPv6. Example# The last 7 days [2018-08-07 00:00:00, 2018-08-14 00:00:00) SELECT ... WHERE TD_INTERVAL(time, '-7d') # The last week. Monday is the beginning of the week (ISO standard) [2018-08-05 00:00:00, 2018-08-13 00:00:00) SELECT ... WHERE TD_INTERVAL(time, '-1w') # Today [2018-08-14 00:00:00, 2018-08-15 00:00:00) SELECT ... WHERE TD_INTERVAL(time, '1d') # The last month [2018-07-01 00:00:00, 2018-08-01 00:00:00) SELECT ... WHERE TD_INTERVAL(time, '-1M') # This month [2018-08-01 00:00:00, 2018-09-01 00:00:00) SELECT ... WHERE TD_INTERVAL(time, '1M') # This year [2018-01-01 00:00:00, 2019-01-01 00:00:00) SELECT ... WHERE TD_INTERVAL(time, '1y') # The last 15 minutes [2018-08-14 00:08:00, 2018-08-14 01:23:00) SELECT ... WHERE TD_INTERVAL(time, '-15m') # The last 30 seconds [2018-08-14 01:23:15, 2018-08-14 01:23:45) SELECT ... WHERE TD_INTERVAL(time, '-30s') # The last hour [2018-08-14 00:00:00, 2018-08-14 01:00:00) SELECT ... WHERE TD_INTERVAL(time, '-1h') # From the last hour to now [2018-08-14 00:00:00, 2018-08-14 01:23:45) SELECT ... WHERE TD_INTERVAL(time, '-1h/now') # The last hour since the beginning of today [2018-08-13 23:00:00, 2018-08-14 00:00:00) SELECT ... WHERE TD_INTERVAL(time, '-1h/0d') # The last 7 days since 2015-12-25 [2015-12-18 00:00:00, 2015-12-25 00:00:00) SELECT ... WHERE TD_INTERVAL(time, '-7d/2015-12-25') # The last 10 days since the beginning of the last month [2018-06-21 00:00:00, 2018-07-01 00:00:00) SELECT ... WHERE TD_INTERVAL(time, '-10d/-1M') # The last 7 days in JST SELECT ... WHERE TD_INTERVAL(time, '-7d', 'JST')5 Possible values are SELECT TD_TIME_FORMAT(time, 'yyyy-MM-dd HH:mm:ss z') ... FROM ... SELECT TD_TIME_FORMAT(time, 'yyyy-MM-dd HH:mm:ss z', 'PST') ... FROM ... SELECT TD_TIME_FORMAT(time, 'yyyy-MM-dd HH:mm:ss z', 'JST') ... FROM ...2, SELECT TD_TIME_FORMAT(time, 'yyyy-MM-dd HH:mm:ss z') ... FROM ... SELECT TD_TIME_FORMAT(time, 'yyyy-MM-dd HH:mm:ss z', 'PST') ... FROM ... SELECT TD_TIME_FORMAT(time, 'yyyy-MM-dd HH:mm:ss z', 'JST') ... FROM ...3, SELECT TD_TIME_FORMAT(time, 'yyyy-MM-dd HH:mm:ss z') ... FROM ... SELECT TD_TIME_FORMAT(time, 'yyyy-MM-dd HH:mm:ss z', 'PST') ... FROM ... SELECT TD_TIME_FORMAT(time, 'yyyy-MM-dd HH:mm:ss z', 'JST') ... FROM ...4 or SELECT TD_TIME_FORMAT(time, 'yyyy-MM-dd HH:mm:ss z') ... FROM ... SELECT TD_TIME_FORMAT(time, 'yyyy-MM-dd HH:mm:ss z', 'PST') ... FROM ... SELECT TD_TIME_FORMAT(time, 'yyyy-MM-dd HH:mm:ss z', 'JST') ... FROM ...5. Signature# The last 7 days [2018-08-07 00:00:00, 2018-08-14 00:00:00) SELECT ... WHERE TD_INTERVAL(time, '-7d') # The last week. Monday is the beginning of the week (ISO standard) [2018-08-05 00:00:00, 2018-08-13 00:00:00) SELECT ... WHERE TD_INTERVAL(time, '-1w') # Today [2018-08-14 00:00:00, 2018-08-15 00:00:00) SELECT ... WHERE TD_INTERVAL(time, '1d') # The last month [2018-07-01 00:00:00, 2018-08-01 00:00:00) SELECT ... WHERE TD_INTERVAL(time, '-1M') # This month [2018-08-01 00:00:00, 2018-09-01 00:00:00) SELECT ... WHERE TD_INTERVAL(time, '1M') # This year [2018-01-01 00:00:00, 2019-01-01 00:00:00) SELECT ... WHERE TD_INTERVAL(time, '1y') # The last 15 minutes [2018-08-14 00:08:00, 2018-08-14 01:23:00) SELECT ... WHERE TD_INTERVAL(time, '-15m') # The last 30 seconds [2018-08-14 01:23:15, 2018-08-14 01:23:45) SELECT ... WHERE TD_INTERVAL(time, '-30s') # The last hour [2018-08-14 00:00:00, 2018-08-14 01:00:00) SELECT ... WHERE TD_INTERVAL(time, '-1h') # From the last hour to now [2018-08-14 00:00:00, 2018-08-14 01:23:45) SELECT ... WHERE TD_INTERVAL(time, '-1h/now') # The last hour since the beginning of today [2018-08-13 23:00:00, 2018-08-14 00:00:00) SELECT ... WHERE TD_INTERVAL(time, '-1h/0d') # The last 7 days since 2015-12-25 [2015-12-18 00:00:00, 2015-12-25 00:00:00) SELECT ... WHERE TD_INTERVAL(time, '-7d/2015-12-25') # The last 10 days since the beginning of the last month [2018-06-21 00:00:00, 2018-07-01 00:00:00) SELECT ... WHERE TD_INTERVAL(time, '-10d/-1M') # The last 7 days in JST SELECT ... WHERE TD_INTERVAL(time, '-7d', 'JST')6 DescriptionThis UDF converts IP address to domain. This UDF supports IPv4 and IPv6. Example# The last 7 days [2018-08-07 00:00:00, 2018-08-14 00:00:00) SELECT ... WHERE TD_INTERVAL(time, '-7d') # The last week. Monday is the beginning of the week (ISO standard) [2018-08-05 00:00:00, 2018-08-13 00:00:00) SELECT ... WHERE TD_INTERVAL(time, '-1w') # Today [2018-08-14 00:00:00, 2018-08-15 00:00:00) SELECT ... WHERE TD_INTERVAL(time, '1d') # The last month [2018-07-01 00:00:00, 2018-08-01 00:00:00) SELECT ... WHERE TD_INTERVAL(time, '-1M') # This month [2018-08-01 00:00:00, 2018-09-01 00:00:00) SELECT ... WHERE TD_INTERVAL(time, '1M') # This year [2018-01-01 00:00:00, 2019-01-01 00:00:00) SELECT ... WHERE TD_INTERVAL(time, '1y') # The last 15 minutes [2018-08-14 00:08:00, 2018-08-14 01:23:00) SELECT ... WHERE TD_INTERVAL(time, '-15m') # The last 30 seconds [2018-08-14 01:23:15, 2018-08-14 01:23:45) SELECT ... WHERE TD_INTERVAL(time, '-30s') # The last hour [2018-08-14 00:00:00, 2018-08-14 01:00:00) SELECT ... WHERE TD_INTERVAL(time, '-1h') # From the last hour to now [2018-08-14 00:00:00, 2018-08-14 01:23:45) SELECT ... WHERE TD_INTERVAL(time, '-1h/now') # The last hour since the beginning of today [2018-08-13 23:00:00, 2018-08-14 00:00:00) SELECT ... WHERE TD_INTERVAL(time, '-1h/0d') # The last 7 days since 2015-12-25 [2015-12-18 00:00:00, 2015-12-25 00:00:00) SELECT ... WHERE TD_INTERVAL(time, '-7d/2015-12-25') # The last 10 days since the beginning of the last month [2018-06-21 00:00:00, 2018-07-01 00:00:00) SELECT ... WHERE TD_INTERVAL(time, '-10d/-1M') # The last 7 days in JST SELECT ... WHERE TD_INTERVAL(time, '-7d', 'JST')7 Signature# The last 7 days [2018-08-07 00:00:00, 2018-08-14 00:00:00) SELECT ... WHERE TD_INTERVAL(time, '-7d') # The last week. Monday is the beginning of the week (ISO standard) [2018-08-05 00:00:00, 2018-08-13 00:00:00) SELECT ... WHERE TD_INTERVAL(time, '-1w') # Today [2018-08-14 00:00:00, 2018-08-15 00:00:00) SELECT ... WHERE TD_INTERVAL(time, '1d') # The last month [2018-07-01 00:00:00, 2018-08-01 00:00:00) SELECT ... WHERE TD_INTERVAL(time, '-1M') # This month [2018-08-01 00:00:00, 2018-09-01 00:00:00) SELECT ... WHERE TD_INTERVAL(time, '1M') # This year [2018-01-01 00:00:00, 2019-01-01 00:00:00) SELECT ... WHERE TD_INTERVAL(time, '1y') # The last 15 minutes [2018-08-14 00:08:00, 2018-08-14 01:23:00) SELECT ... WHERE TD_INTERVAL(time, '-15m') # The last 30 seconds [2018-08-14 01:23:15, 2018-08-14 01:23:45) SELECT ... WHERE TD_INTERVAL(time, '-30s') # The last hour [2018-08-14 00:00:00, 2018-08-14 01:00:00) SELECT ... WHERE TD_INTERVAL(time, '-1h') # From the last hour to now [2018-08-14 00:00:00, 2018-08-14 01:23:45) SELECT ... WHERE TD_INTERVAL(time, '-1h/now') # The last hour since the beginning of today [2018-08-13 23:00:00, 2018-08-14 00:00:00) SELECT ... WHERE TD_INTERVAL(time, '-1h/0d') # The last 7 days since 2015-12-25 [2015-12-18 00:00:00, 2015-12-25 00:00:00) SELECT ... WHERE TD_INTERVAL(time, '-7d/2015-12-25') # The last 10 days since the beginning of the last month [2018-06-21 00:00:00, 2018-07-01 00:00:00) SELECT ... WHERE TD_INTERVAL(time, '-10d/-1M') # The last 7 days in JST SELECT ... WHERE TD_INTERVAL(time, '-7d', 'JST')8 DescriptionThis UDF converts geolocation information (latitude/longitude) to the country name. Example# The last 7 days [2018-08-07 00:00:00, 2018-08-14 00:00:00) SELECT ... WHERE TD_INTERVAL(time, '-7d') # The last week. Monday is the beginning of the week (ISO standard) [2018-08-05 00:00:00, 2018-08-13 00:00:00) SELECT ... WHERE TD_INTERVAL(time, '-1w') # Today [2018-08-14 00:00:00, 2018-08-15 00:00:00) SELECT ... WHERE TD_INTERVAL(time, '1d') # The last month [2018-07-01 00:00:00, 2018-08-01 00:00:00) SELECT ... WHERE TD_INTERVAL(time, '-1M') # This month [2018-08-01 00:00:00, 2018-09-01 00:00:00) SELECT ... WHERE TD_INTERVAL(time, '1M') # This year [2018-01-01 00:00:00, 2019-01-01 00:00:00) SELECT ... WHERE TD_INTERVAL(time, '1y') # The last 15 minutes [2018-08-14 00:08:00, 2018-08-14 01:23:00) SELECT ... WHERE TD_INTERVAL(time, '-15m') # The last 30 seconds [2018-08-14 01:23:15, 2018-08-14 01:23:45) SELECT ... WHERE TD_INTERVAL(time, '-30s') # The last hour [2018-08-14 00:00:00, 2018-08-14 01:00:00) SELECT ... WHERE TD_INTERVAL(time, '-1h') # From the last hour to now [2018-08-14 00:00:00, 2018-08-14 01:23:45) SELECT ... WHERE TD_INTERVAL(time, '-1h/now') # The last hour since the beginning of today [2018-08-13 23:00:00, 2018-08-14 00:00:00) SELECT ... WHERE TD_INTERVAL(time, '-1h/0d') # The last 7 days since 2015-12-25 [2015-12-18 00:00:00, 2015-12-25 00:00:00) SELECT ... WHERE TD_INTERVAL(time, '-7d/2015-12-25') # The last 10 days since the beginning of the last month [2018-06-21 00:00:00, 2018-07-01 00:00:00) SELECT ... WHERE TD_INTERVAL(time, '-10d/-1M') # The last 7 days in JST SELECT ... WHERE TD_INTERVAL(time, '-7d', 'JST')9 This function is not supported. Signaturelong TD_TIME_ADD(int/long/string time, string duration [, string default_timezone = 'UTC'])0 DescriptionThis UDF returns the concatenation of SELECT TD_TIME_FORMAT(time, 'yyyy-MM-dd HH:mm:ss z') ... FROM ... SELECT TD_TIME_FORMAT(time, 'yyyy-MM-dd HH:mm:ss z', 'PST') ... FROM ... SELECT TD_TIME_FORMAT(time, 'yyyy-MM-dd HH:mm:ss z', 'JST') ... FROM ...6 with SELECT TD_TIME_FORMAT(time, 'yyyy-MM-dd HH:mm:ss z') ... FROM ... SELECT TD_TIME_FORMAT(time, 'yyyy-MM-dd HH:mm:ss z', 'PST') ... FROM ... SELECT TD_TIME_FORMAT(time, 'yyyy-MM-dd HH:mm:ss z', 'JST') ... FROM ...7 ordered by SELECT TD_TIME_FORMAT(time, 'yyyy-MM-dd HH:mm:ss z') ... FROM ... SELECT TD_TIME_FORMAT(time, 'yyyy-MM-dd HH:mm:ss z', 'PST') ... FROM ... SELECT TD_TIME_FORMAT(time, 'yyyy-MM-dd HH:mm:ss z', 'JST') ... FROM ...8in a group of values. Examplelong TD_TIME_ADD(int/long/string time, string duration [, string default_timezone = 'UTC'])1 Geometry types are the building blocks of geospatial queries and calculations. They are used as arguments for geospatial functions. Geometry type is the product of a constructor function. ST_Point and ST_Polygon are examples of geospatial functions used to obtain binary representations of a point, `line, or polygon. You can also use them to convert a geometry data type to text. Signaturelong TD_TIME_ADD(int/long/string time, string duration [, string default_timezone = 'UTC'])2 DescriptionA constructor function that returns a geometry type point object with the given coordinate values. Examplelong TD_TIME_ADD(int/long/string time, string duration [, string default_timezone = 'UTC'])3 The above query returns a list of schools that are within a geographic area stored in the counties table. The ‘st_point’ constructor is used to create the point that is being used. RESULT: School Phone Pelham H.S. (212) 948 5300 Midrand M.S. (212) 233 3587 Signaturelong TD_TIME_ADD(int/long/string time, string duration [, string default_timezone = 'UTC'])4 DescriptionReturns a geometry type polygon object from WKT representation. Examplelong TD_TIME_ADD(int/long/string time, string duration [, string default_timezone = 'UTC'])5 The above query returns a list of reservoirs that are within a geographic area of a park in the parks table. The ‘ST_Polygon’ constructor is used to create the polygon that is being used. RESULT: Park Area Hope Fountain 4000 Hot Springs 5156 ST_Intersection and ST_Intersects are examples of Geospatial Relationship Functions. Relationship functions allow you to find relationships between two different geometric inputs. They return a boolean result type. Signaturelong TD_TIME_ADD(int/long/string time, string duration [, string default_timezone = 'UTC'])6 DescriptionReturns the geometry value that represents the point set intersection of two geometries. Examplelong TD_TIME_ADD(int/long/string time, string duration [, string default_timezone = 'UTC'])7 RESULT: POINT(1 0) (1 row) Returns the intersection of 2 points as text coordinates. Signaturelong TD_TIME_ADD(int/long/string time, string duration [, string default_timezone = 'UTC'])8 RESULT: true (1 row) DescriptionReturns true if the given geometries spatially intersect in two dimensions (share any portion of space) and false if they do not (they are disjoint). What is Presto map?Presto map is a place for mystery shoppers to find mystery shops based off their geographic location. Shoppers can go on Prestomap.com and use their location or put in another address to find mystery shops in their area.
How do you find the length of an array in Presto?In order to get the length or size of an array in Presto, you can use the cardinality function. cardinality takes in an array and will output the size or length of an array. Running this should give me all the rows in my table where my_array is a non-empty array.
|