{"templateId":"markdown","sharedDataIds":{"sidebar":"sidebar-sidebars.yaml"},"props":{"metadata":{"markdoc":{"tagList":[]},"redocly_category":"Products","product_name":"Data Workbench","type":"markdown"},"seo":{"title":"Presto Functions and Features Added Between 0 189 and 0 205 2018","description":"Treasure Data Product Documentation · Collect and Unify · Segment and Activate · Experiment and Analyze · Decisioning Automate with AI Scale and Trust.","siteUrl":"https://docs.treasuredata.com","lang":"en-US","llmstxt":{"hide":false,"sections":[{"title":"Table of contents","includeFiles":["**/*"],"excludeFiles":[]}],"excludeFiles":[]}},"dynamicMarkdocComponents":[],"compilationErrors":[],"ast":{"$$mdtype":"Tag","name":"article","attributes":{},"children":[{"$$mdtype":"Tag","name":"Heading","attributes":{"level":1,"id":"presto-functions-and-features-added-between-0-189-and-0-205-2018","__idx":0},"children":["Presto Functions and Features Added Between 0 189 and 0 205 2018"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/products/customer-data-platform/data-workbench/queries/archives/presto-functions-and-features-added-between-0-189-and-0-205-2018#h1_1013277974"},"children":["v0.189"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/products/customer-data-platform/data-workbench/queries/archives/presto-functions-and-features-added-between-0-189-and-0-205-2018#h1__196575608"},"children":["v0.190"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/products/customer-data-platform/data-workbench/queries/archives/presto-functions-and-features-added-between-0-189-and-0-205-2018#h1_206708919"},"children":["v0.193"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/products/customer-data-platform/data-workbench/queries/archives/presto-functions-and-features-added-between-0-189-and-0-205-2018#h1_966223806"},"children":["v0.196"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/products/customer-data-platform/data-workbench/queries/archives/presto-functions-and-features-added-between-0-189-and-0-205-2018#h1__981318810"},"children":["v0.197 and v0.198"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/products/customer-data-platform/data-workbench/queries/archives/presto-functions-and-features-added-between-0-189-and-0-205-2018#h1__1762659549"},"children":["v0.197"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/products/customer-data-platform/data-workbench/queries/archives/presto-functions-and-features-added-between-0-189-and-0-205-2018#h1_1013277973"},"children":["v0.199"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/products/customer-data-platform/data-workbench/queries/archives/presto-functions-and-features-added-between-0-189-and-0-205-2018#h1__1218212512"},"children":["v0.200"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/products/customer-data-platform/data-workbench/queries/archives/presto-functions-and-features-added-between-0-189-and-0-205-2018#h1__55413098"},"children":["v0.202"]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":1,"id":"v0189","__idx":1},"children":["v0.189"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"add-support-for-dereferencing-row-fields-in-lambda-expressions","__idx":2},"children":["Add support for dereferencing row fields in lambda expressions"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The following lambda function which uses a table alias is supported."]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"sql","header":{"controls":{"copy":{}}},"source":"select transform(array[1], x -> x + t.a) from (values 1, 2, 3) t(a);\n=> \n[\"2\"]\n[\"3\"]\n[\"4\"]\n","lang":"sql"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":1,"id":"v0190","__idx":3},"children":["v0.190"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"add-support-for-order-by-in-aggregation-functions","__idx":4},"children":["Add support for ORDER BY in aggregation functions"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Some aggregate functions such as ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["array_agg()"]}," produce different results depending on the order of input values. This ordering can be specified by writing an ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://trino.io/docs/423/sql/select.html#order-by-clause"},"children":["ORDER BY Clause"]}," within the aggregate function:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"sql","header":{"controls":{"copy":{}}},"source":"array_agg(x ORDER BY y DESC)\narray_agg(x ORDER BY x, y, z)   \n","lang":"sql"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"add-support-for-casting-to-interval-types","__idx":5},"children":["Add support for casting to INTERVAL types"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Optimized aggregations on INTERVAL types"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"sql","header":{"controls":{"copy":{}}},"source":"SELECT CAST(INTERVAL '18000' SECOND AS VARCHAR);\n=>0 05:00:00.000  \n","lang":"sql"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"add-st_buffer-geospatial-function","__idx":6},"children":["Add ST_Buffer() geospatial function"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Returns the geometry that represents all points whose distance from the specified geometry is less than or equal to the specified distance."]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"sql","header":{"controls":{"copy":{}}},"source":"    SELECT ST_BUFFER(ST_Point(1, 2), 2.0) \n    => POLYGON ((3 2, 2.9957178464772056 2.130806258460286, 2.982889722747619 2.2610523844401027, 2.9615705608064595 2.390180644032256, 2.9318516525781355 2.517638090205041, 2.8938602589902103 2.6428789306063227, 2.8477590650225726 2.765366864730179, 2.7937454830653756 2.8845773804380017, 2.7320508075688767 2.999999999999999, 2.66293922460509 3.1111404660392035, 2.58670668058247 3.217522858017441, 2.5036796149579543 3.318691630200137, 2.414213562373095 3.4142135623730945, 2.3186916302001377 3.5036796149579543, 2.217522858017441 3.58670668058247, 2.1111404660392044 3.66293922460509, 2 3.7320508075688767, 1.8845773804380026 3.7937454830653765, 1.7653668647301795 3.847759065022573, 1.6428789306063232 3.893860258990211, 1.5176380902050415 3.9318516525781364, 1.3901806440322564 3.961570560806461, 1.2610523844401031 3.982889722747621, 1.130806258460286 3.995717846477207, 1 4, 0.8691937415397142 3.9957178464772056, 0.7389476155598972 3.982889722747619, 0.6098193559677438 3.9615705608064595, 0.48236190979495897 3.9318516525781355, 0.3571210693936774 3.8938602589902103, 0.2346331352698211 3.8477590650225726, 0.11542261956199817 3.7937454830653756, 7.7715611723760960e-16 3.7320508075688767, -0.11114046603920369 3.66293922460509, -0.21752285801744065 3.58670668058247, -0.318691630200137 3.5036796149579543, -0.4142135623730945 3.414213562373095, -0.5036796149579543 3.3186916302001377, -0.5867066805824699 3.217522858017441, -0.66293922460509 3.1111404660392044, -0.732050807568877 3, -0.7937454830653763 2.8845773804380026, -0.8477590650225733 2.7653668647301792, -0.8938602589902112 2.642878930606323, -0.9318516525781366 2.5176380902050415, -0.9615705608064609 2.3901806440322564, -0.9828897227476208 2.261052384440103, -0.995717846477207 2.1308062584602863, -1 2, -0.9957178464772056 1.8691937415397142, -0.9828897227476194 1.7389476155598973, -0.9615705608064595 1.6098193559677438, -0.9318516525781353 1.482361909794959, -0.8938602589902103 1.3571210693936773, -0.8477590650225726 1.2346331352698212, -0.7937454830653756 1.1154226195619983, -0.7320508075688765 1.0000000000000009, -0.6629392246050898 0.8888595339607963, -0.5867066805824699 0.7824771419825594, -0.5036796149579543 0.681308369799863, -0.4142135623730947 0.5857864376269055, -0.31869163020013747 0.4963203850420457, -0.2175228580174411 0.4132933194175301, -0.11114046603920436 0.33706077539491, 1.1102230246251565e-16 0.26794919243112303, 0.11542261956199751 0.2062545169346237, 0.23463313526982055 0.15224093497742675, 0.35712106939367694 0.10613974100978885, 0.4823619097949585 0.06814834742186338, 0.6098193559677435 0.03842943919353914, 0.7389476155598969 0.017110277252379236, 0.8691937415397138 0.004282153522793042, 1 0, 1.1308062584602858 0.004282153522794374, 1.2610523844401027 0.017110277252380568, 1.3901806440322562 0.03842943919354047, 1.517638090205041 0.06814834742186471, 1.6428789306063227 0.10613974100978973, 1.7653668647301788 0.1522409349774274, 1.8845773804380017 0.20625451693462438, 1.9999999999999991 0.2679491924311235, 2.1111404660392035 0.3370607753949102, 2.217522858017441 0.4132933194175301, 2.318691630200137 0.4963203850420457, 2.4142135623730945 0.5857864376269053, 2.5036796149579543 0.6813083697998625, 2.58670668058247 0.7824771419825589, 2.66293922460509 0.8888595339607956, 2.7320508075688767 1, 2.7937454830653765 1.1154226195619974, 2.847759065022573 1.2346331352698205, 2.893860258990211 1.3571210693936768, 2.9318516525781364 1.4823619097949585, 2.961570560806461 1.6098193559677436, 2.982889722747621 1.7389476155598969, 2.995717846477207 1.869193741539714, 3 2))  \n","lang":"sql"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"approx_distinctfunction-now-supports-a-standard-error-in-the-range-of-00040625-026000","__idx":7},"children":["approx_distinct()function now supports a standard error in the range of [0.0040625, 0.26000]"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Returns the approximate number of distinct input values. This function provides an approximation of ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["count(DISTINCT x)"]},". Zero is returned if all input values are null."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["This function should produce a standard error of no more than ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["e"]},", which is the standard deviation of the (approximately normal) error distribution over all possible sets. It does not guarantee an upper bound on the error for any specific input set. The current implementation of this function requires that ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["e"]}," be in the range of ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["[0.0040625, 0.26000]"]},"."]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"sql","header":{"controls":{"copy":{}}},"source":"SELECT APPROX_DISTINCT(x, value) from tbl;  \n","lang":"sql"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":1,"id":"v0193","__idx":8},"children":["v0.193"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"add-map_zip_with-lambda-function","__idx":9},"children":["Add map_zip_with() lambda function"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Merges the two given maps into a single map by applying ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["function"]}," to the pair of values with the same key. For keys only presented in one map, NULL will be passed as the value for the missing key."]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"sql","header":{"controls":{"copy":{}}},"source":"    map_zip_with(map<K, V1>, map<K, V2>, function<K, V1, V2, V3>) → map<K, V3>  \n","lang":"sql"},"children":[]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"sql","header":{"controls":{"copy":{}}},"source":"    SELECT map_zip_with(MAP(ARRAY[1, 2, 3], ARRAY['a', 'b', 'c']), -- {1 -> ad, 2 -> be, 3 -> cf} \n                        MAP(ARRAY[1, 2, 3], ARRAY['d', 'e', 'f']), \n                        (k, v1, v2) -> concat(v1, v2)); \n    \n    SELECT map_zip_with(MAP(ARRAY['k1', 'k2'], ARRAY[1, 2]), -- {k1 -> ROW(1, null), k2 -> ROW(2, 4), k3 -> ROW(null, 9)} \n                        MAP(ARRAY['k2', 'k3'], ARRAY[4, 9]), \n                        (k, v1, v2) -> (v1, v2)); \n    \n    SELECT map_zip_with(MAP(ARRAY['a', 'b', 'c'], ARRAY[1, 8, 27]), -- {a -> a1, b -> b4, c -> c9} \n                        MAP(ARRAY['a', 'b', 'c'], ARRAY[1, 2, 3]), \n                        (k, v1, v2) -> k || CAST(v1/v2 AS VARCHAR));  \n","lang":"sql"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"add-normal_cdf-function","__idx":10},"children":["Add normal_cdf() function"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Returns the cumulative distribution function value for a normal distribution."]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"sql","header":{"controls":{"copy":{}}},"source":"    Normal_cdf(mean, standard deviation, value) → double  \n","lang":"sql"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":1,"id":"v0196","__idx":11},"children":["v0.196"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"add-is_json_scalar-function","__idx":12},"children":["Add is_json_scalar() function"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Determine if ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["json"]}," is a scalar (i.e. a JSON number, a JSON string, ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["true"]},",",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["false"]}," or ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["null"]},"):"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"sql","header":{"controls":{"copy":{}}},"source":"    SELECT is_json_scalar('1'); \n    => true \n    \n    SELECT is_json_scalar('[1, 2, 3]'); \n    => false  \n","lang":"sql"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"add-regexp_replacefunction-variant-that-executes-a-lambda-for-each-replacement","__idx":13},"children":["Add regexp_replace()function variant that executes a lambda for each replacement"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Replaces every instance of the substring matched by the regular expression ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["pattern"]}," in ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["string"]}," with ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["replacement"]},". ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"http://docs.oracle.com/javase/8/docs/api/java/util/regex/Pattern.md#cg"},"children":["Capturing groups"]}," can be referenced in ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["replacement"]}," using ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["$g"]}," for a numbered group or ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["${name}"]}," for a named group. A dollar sign (",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["$"]},") may be included in the replacement by escaping it with a backslash (",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["\\$"]},"):"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"sql","header":{"controls":{"copy":{}}},"source":"    SELECT regexp_replace('1a 2b 14m', '(\\d+)([ab]) ', '3c$2 '); \n    => '3ca 3cb 14m'  \n","lang":"sql"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":1,"id":"v0197-and-v0198","__idx":14},"children":["v0.197 and v0.198"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"add-date-variant-for-sequencefunction-with-an-implicit-one-day-step-increment","__idx":15},"children":["Add DATE variant for sequence()function with an implicit one-day step increment"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Generate a sequence of integers from ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["start"]}," to ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["stop"]},", incrementing by ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["1"]}," if ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["start"]}," is less than or equal to ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["stop"]},",otherwise ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["-1"]},"."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":1,"id":"v0197","__idx":16},"children":["v0.197"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"add-st_issimple-geospatial-function","__idx":17},"children":["Add ST_IsSimple() geospatial function"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"sql","header":{"controls":{"copy":{}}},"source":"    SELECT ST_IsSimple(ST_GeomFromText('POLYGON((1 2, 3 4, 5 6, 1 2))')); \n    st_issimple \n    ------------- \n    t \n    (1 row) \n    \n    SELECT ST_IsSimple(ST_GeomFromText('LINESTRING(1 1,2 2,2 3.5,1 3,1 2,2 1)')); \n    st_issimple \n    ------------- \n    f \n    (1 row)  \n","lang":"sql"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":1,"id":"v0199","__idx":18},"children":["v0.199"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"add-hmac_md5-hmac_sha1-hmac_sha256-and-hmac_sha512functions","__idx":19},"children":["Add hmac_md5(), hmac_sha1(), hmac_sha256(), and hmac_sha512()functions"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Computes HMAC with md5 or sha1 or sha256 or sha512 of ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["binary"]}," with the given ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["key"]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"sql","header":{"controls":{"copy":{}}},"source":"    hmac_md5(binary, key) → varbinaryComputes\n    \n    hmac_sha1(binary, key) → varbinaryComputes \n    \n    hmac_sha256(binary, key) → varbinaryComputes \n    \n    hmac_sha512(binary, key) → varbinaryComputes   \n","lang":"sql"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"add-array_sort-function-that-takes-a-lambda-as-a-comparator","__idx":20},"children":["Add array_sort() function that takes a lambda as a comparator"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Sorts and returns the ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["array"]}," based on the given comparator ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["function"]},". The comparator will take two nullable arguments representing two nullable elements of the ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["array"]},". It returns -1, 0, or 1 as the first nullable element is less than, equal to, or greater than the second nullable element. If the comparator function returns other values (including ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["NULL"]},"), the query will fail and raise an error"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"sql","header":{"controls":{"copy":{}}},"source":"    SELECT array_sort(ARRAY [3, 2, 5, 1, 2], (x, y) -> IF(x < y, 1, IF(x = y, 0, -1))); -- [5, 3, 2, 2, 1] \n    SELECT array_sort(ARRAY ['bc', 'ab', 'dc'], (x, y) -> IF(x < y, 1, IF(x = y, 0, -1))); -- ['dc', 'bc', 'ab'] \n    SELECT array_sort(ARRAY [3, 2, null, 5, null, 1, 2], -- sort null first with descending order \n                     (x, y) -> CASE WHEN x IS NULL THEN -1 \n                                    WHEN y IS NULL THEN 1 \n                                    WHEN x < y THEN 1 \n                                    WHEN x = y THEN 0 \n                                    ELSE -1 END); -- [null, null, 5, 3, 2, 2, 1] \n    SELECT array_sort(ARRAY [3, 2, null, 5, null, 1, 2], -- sort null last with descending order \n                     (x, y) -> CASE WHEN x IS NULL THEN 1 \n                                    WHEN y IS NULL THEN -1 \n                                    WHEN x < y THEN 1 \n                                    WHEN x = y THEN 0 \n                                    ELSE -1 END); -- [5, 3, 2, 2, 1, null, null] \n    SELECT array_sort(ARRAY ['a', 'abcd', 'abc'], -- sort by string length \n                      (x, y) -> IF(length(x) < length(y), \n                                -1, \n                                  IF(length(x) = length(y), 0, 1))); -- ['a', 'abc', 'abcd'] \n    SELECT array_sort(ARRAY [ARRAY[2, 3, 1], ARRAY[4, 2, 1, 4], ARRAY[1, 2]], -- sort by array length \n                      (x, y) -> IF(cardinality(x) < cardinality(y), \n                                 -1, \n                                   IF(cardinality(x) = cardinality(y), 0, 1))); -- [[1, 2], [2, 3, 1], [4, 2, 1, 4]]  \n","lang":"sql"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"add-line_locate_pointgeospatial-function","__idx":21},"children":["Add line_locate_point()geospatial function"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Returns a float between 0 and 1 representing the location of the closest point on the LineString to the given Point, as a fraction of total 2d line length."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Returns ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["null"]}," if a LineString or a Point is empty or ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["null"]},"."]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"sql","header":{"controls":{"copy":{}}},"source":"    SELECT LINE_LOCATE_POINT(GEOMFROMTEXT('LINESTRING(0 0, 5 5, 10 10)'), GEOMFROMTEXT('POINT(5 5)'));\n    \n    -------------\n    col1\n    -------------\n    0.500\n    -------------  \n","lang":"sql"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":1,"id":"v0200","__idx":22},"children":["v0.200"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"add-st_geometrytype-geospatial-function","__idx":23},"children":["Add ST_GeometryType() geospatial function"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Returns the type of the geometry."]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"sql","header":{"controls":{"copy":{}}},"source":"    SELECT ST_GeometryType(ST_GeomFromText('LINESTRING(77.29 29.07,77.42 29.26,77.27 29.31,77.29 29.07)'));\n    \n    => ST_LineString  \n","lang":"sql"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":1,"id":"v0202","__idx":24},"children":["v0.202"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"add-multimap_from_entriesfunction","__idx":25},"children":["Add multimap_from_entries()function"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Returns a map created from the given array of entries."]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"sql","header":{"controls":{"copy":{}}},"source":"    SELECT multimap_from_entries(ARRAY[(1, 'x'), (2, 'y'), (1, 'z')]); -- {1 -> ['x', 'z'], 2 -> ['y']}  \n","lang":"sql"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"add-bing_tiles_aroundgeospatial-functions","__idx":26},"children":["Add bing_tiles_around()geospatial functions"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Returns a collection of Bing tiles that surround the point specified by the latitude and longitude arguments at a given zoom level."]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"sql","header":{"controls":{"copy":{}}},"source":"bing_tiles_around(latitude, longitude, zoom_level) → array<BingTile>  \n","lang":"sql"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"add-st_numgeometries-geospatial-functions","__idx":27},"children":["Add ST_NumGeometries() geospatial functions"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Returns the number of geometries in the collection. If the geometry is a collection of geometries (e.g., GEOMETRYCOLLECTION or MULTI*), returns the number of geometries, for single geometries returns 1, for empty geometries returns 0."]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"sql","header":{"controls":{"copy":{}}},"source":"    ST_NumGeometries(Geometry) → bigint  \n","lang":"sql"},"children":[]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"sql","header":{"controls":{"copy":{}}},"source":"    SELECT ST_NumGeometries(ST_GeomFromEWKT('GEOMETRYCOLLECTION(MULTIPOINT(-2 3 , -2 2), \n    LINESTRING(5 5 ,10 10), \n    POLYGON((-7 4.2,-7.1 5,-7.1 4.3,-7 4.2)))'));  \n","lang":"sql"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"add-st_geometryn-geospatial-functions","__idx":28},"children":["Add ST_GeometryN() geospatial functions"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Returns the geometry element at a given index (indices start at 1). If the geometry is a collection of geometries (e.g., GEOMETRYCOLLECTION or MULTI*), returns the geometry at a given index. If the given index is less than 1 or greater than the total number of elements in the collection, returns ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["NULL"]},".Use :func:",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["ST_NumGeometries"]}," to find out the total number of elements. Singular geometries (e.g., POINT, LINESTRING, POLYGON), are treated as collections of one element. Empty geometries are treated as empty collections."]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"sql","header":{"controls":{"copy":{}}},"source":"    SELECT gid, n, ST_GeometryN(the_geom, n)\n    FROM tbl CROSS JOIN generate_series(1,100) n WHERE n <= ST_NumGeometries(the_geom);  \n","lang":"sql"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"add-st_convexhull-geospatial-functions","__idx":29},"children":["Add ST_ConvexHull() geospatial functions"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Returns the minimum convex geometry that encloses all input geometries. This function doesn’t support geometry collections."]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"sql","header":{"controls":{"copy":{}}},"source":"    SELECT t.tbl_type, ST_ConvexHull(ST_Collect(t.the_geom)) As the_geom \n    FROM tbl As t \n    GROUP BY t.tbl_type;  \n","lang":"sql"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"add-wilson_interval_lower-and-wilson_interval_upper-functions","__idx":30},"children":["Add wilson_interval_lower() and wilson_interval_upper() functions"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Returns the lower bound of the Wilson score interval of a Bernoulli trial process at a confidence specified by the z-score Z."]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"sql","header":{"controls":{"copy":{}}},"source":"    assertFunction(\"ST_AsText(ST_EnvelopeAsPts(ST_GeometryFromText('MULTIPOINT (1 2, 2 4, 3 6, 4 8)')))\", \n    VARCHAR, \"MULTIPOINT ((1 2), (4 8))\");   \n","lang":"sql"},"children":[]}]},"headings":[{"value":"Presto Functions and Features Added Between 0 189 and 0 205 2018","id":"presto-functions-and-features-added-between-0-189-and-0-205-2018","depth":1},{"value":"v0.189","id":"v0189","depth":1},{"value":"Add support for dereferencing row fields in lambda expressions","id":"add-support-for-dereferencing-row-fields-in-lambda-expressions","depth":2},{"value":"v0.190","id":"v0190","depth":1},{"value":"Add support for ORDER BY in aggregation functions","id":"add-support-for-order-by-in-aggregation-functions","depth":2},{"value":"Add support for casting to INTERVAL types","id":"add-support-for-casting-to-interval-types","depth":2},{"value":"Add ST_Buffer() geospatial function","id":"add-st_buffer-geospatial-function","depth":2},{"value":"approx_distinct()function now supports a standard error in the range of [0.0040625, 0.26000]","id":"approx_distinctfunction-now-supports-a-standard-error-in-the-range-of-00040625-026000","depth":2},{"value":"v0.193","id":"v0193","depth":1},{"value":"Add map_zip_with() lambda function","id":"add-map_zip_with-lambda-function","depth":2},{"value":"Add normal_cdf() function","id":"add-normal_cdf-function","depth":2},{"value":"v0.196","id":"v0196","depth":1},{"value":"Add is_json_scalar() function","id":"add-is_json_scalar-function","depth":2},{"value":"Add regexp_replace()function variant that executes a lambda for each replacement","id":"add-regexp_replacefunction-variant-that-executes-a-lambda-for-each-replacement","depth":2},{"value":"v0.197 and v0.198","id":"v0197-and-v0198","depth":1},{"value":"Add DATE variant for sequence()function with an implicit one-day step increment","id":"add-date-variant-for-sequencefunction-with-an-implicit-one-day-step-increment","depth":2},{"value":"v0.197","id":"v0197","depth":1},{"value":"Add ST_IsSimple() geospatial function","id":"add-st_issimple-geospatial-function","depth":2},{"value":"v0.199","id":"v0199","depth":1},{"value":"Add hmac_md5(), hmac_sha1(), hmac_sha256(), and hmac_sha512()functions","id":"add-hmac_md5-hmac_sha1-hmac_sha256-and-hmac_sha512functions","depth":2},{"value":"Add array_sort() function that takes a lambda as a comparator","id":"add-array_sort-function-that-takes-a-lambda-as-a-comparator","depth":2},{"value":"Add line_locate_point()geospatial function","id":"add-line_locate_pointgeospatial-function","depth":2},{"value":"v0.200","id":"v0200","depth":1},{"value":"Add ST_GeometryType() geospatial function","id":"add-st_geometrytype-geospatial-function","depth":2},{"value":"v0.202","id":"v0202","depth":1},{"value":"Add multimap_from_entries()function","id":"add-multimap_from_entriesfunction","depth":2},{"value":"Add bing_tiles_around()geospatial functions","id":"add-bing_tiles_aroundgeospatial-functions","depth":2},{"value":"Add ST_NumGeometries() geospatial functions","id":"add-st_numgeometries-geospatial-functions","depth":2},{"value":"Add ST_GeometryN() geospatial functions","id":"add-st_geometryn-geospatial-functions","depth":2},{"value":"Add ST_ConvexHull() geospatial functions","id":"add-st_convexhull-geospatial-functions","depth":2},{"value":"Add wilson_interval_lower() and wilson_interval_upper() functions","id":"add-wilson_interval_lower-and-wilson_interval_upper-functions","depth":2}],"frontmatter":{"seo":{"title":"Presto Functions and Features Added Between 0 189 and 0 205 2018"}},"lastModified":"2026-03-09T02:59:36.000Z","pagePropGetterError":{"message":"","name":""}},"slug":"/products/customer-data-platform/data-workbench/queries/archives/presto-functions-and-features-added-between-0-189-and-0-205-2018","userData":{"isAuthenticated":false,"teams":["anonymous"]},"isPublic":true}