This is an automated email from the ASF dual-hosted git repository. mblow pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/asterixdb.git
commit dc8efead794f3b5a949ee593ff272d66a28b9d5a Author: Simon Dew <[email protected]> AuthorDate: Thu Feb 25 00:24:28 2021 +0000 [NO ISSUE][DOC] Chunk type function documentation - Split type function documentation into chunks for content reuse - Update POM for AQL and SQL++ functions Change-Id: Ic7bc0d92d4278ccb7ce044068e7cdbd652efe986 Reviewed-on: https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/10186 Integration-Tests: Jenkins <[email protected]> Reviewed-by: Dmitry Lychagin <[email protected]> Reviewed-by: Hussain Towaileb <[email protected]> Tested-by: Jenkins <[email protected]> --- asterixdb/asterix-doc/pom.xml | 4 +- .../src/main/markdown/builtins/11_type_common.md | 328 +++++++++++ .../main/markdown/builtins/11_type_conversion.md | 279 +++++++++ .../builtins/{11_type.md => 11_type_delta.md} | 629 +-------------------- 4 files changed, 639 insertions(+), 601 deletions(-) diff --git a/asterixdb/asterix-doc/pom.xml b/asterixdb/asterix-doc/pom.xml index 7c21486..c58d983 100644 --- a/asterixdb/asterix-doc/pom.xml +++ b/asterixdb/asterix-doc/pom.xml @@ -55,10 +55,10 @@ <filelist dir="${project.basedir}/src/main/markdown/sqlpp" files="0_toc.md,1_intro.md,2_expr_title.md,2_expr.md,3_query_title.md,3_query.md,4_windowfunctions_title.md,4_windowfunctions.md,5_error_title.md,5_error.md,6_sql_diff_title.md,6_sql_diff.md,7_ddl_head.md,7_ddl_dml.md,appendix_1_title.md,appendix_1_keywords.md,appendix_2_title.md,appendix_2_parameters.md,appendix_2_parallel_sort.md,appendix_2_index_only.md,appendix_2_hints.md,appendix_3_title.md,appendix_3_resol [...] </concat> <concat destfile="${project.build.directory}/generated-site/markdown/sqlpp/builtins.md"> - <filelist dir="${project.basedir}/src/main/markdown/builtins" files="0_toc.md,0_toc_sqlpp.md,0_toc_common.md,1_numeric_common.md,1_numeric_delta.md,2_string_common.md,2_string_delta.md,3_binary.md,4_spatial.md,5_similarity.md,6_tokenizing.md,7_temporal.md,7_allens.md,8_record.md,9_aggregate_sql.md,10_comparison.md,11_type.md,13_conditional.md,12_misc.md,15_bitwise.md,14_window.md" /> + <filelist dir="${project.basedir}/src/main/markdown/builtins" files="0_toc.md,0_toc_sqlpp.md,0_toc_common.md,1_numeric_common.md,1_numeric_delta.md,2_string_common.md,2_string_delta.md,3_binary.md,4_spatial.md,5_similarity.md,6_tokenizing.md,7_temporal.md,7_allens.md,8_record.md,9_aggregate_sql.md,10_comparison.md,11_type_common.md,11_type_delta.md,11_type_conversion.md,13_conditional.md,12_misc.md,15_bitwise.md,14_window.md" /> </concat> <concat destfile="${project.build.directory}/generated-site/markdown/aql/builtins.md"> - <filelist dir="${project.basedir}/src/main/markdown/builtins" files="0_toc.md,0_toc_aql.md,0_toc_common.md,1_numeric_common.md,1_numeric_delta.md,2_string_common.md,2_string_delta.md,3_binary.md,4_spatial.md,5_similarity.md,6_tokenizing.md,7_temporal.md,7_allens.md,8_record.md,9_aggregate_sql.md,10_comparison.md,11_type.md,13_conditional.md,12_misc.md" /> + <filelist dir="${project.basedir}/src/main/markdown/builtins" files="0_toc.md,0_toc_aql.md,0_toc_common.md,1_numeric_common.md,1_numeric_delta.md,2_string_common.md,2_string_delta.md,3_binary.md,4_spatial.md,5_similarity.md,6_tokenizing.md,7_temporal.md,7_allens.md,8_record.md,9_aggregate_sql.md,10_comparison.md,11_type_common.md,11_type_delta.md,11_type_conversion.md,13_conditional.md,12_misc.md" /> </concat> <concat destfile="${project.build.directory}/generated-site/markdown/datamodel.md"> <filelist dir="${project.basedir}/src/main/markdown/datamodel" files="datamodel_header.md,datamodel_primitive_common.md,datamodel_primitive_delta.md,datamodel_incomplete.md,datamodel_composite.md" /> diff --git a/asterixdb/asterix-doc/src/main/markdown/builtins/11_type_common.md b/asterixdb/asterix-doc/src/main/markdown/builtins/11_type_common.md new file mode 100644 index 0000000..5cbef2c --- /dev/null +++ b/asterixdb/asterix-doc/src/main/markdown/builtins/11_type_common.md @@ -0,0 +1,328 @@ +<!-- + ! Licensed to the Apache Software Foundation (ASF) under one + ! or more contributor license agreements. See the NOTICE file + ! distributed with this work for additional information + ! regarding copyright ownership. The ASF licenses this file + ! to you under the Apache License, Version 2.0 (the + ! "License"); you may not use this file except in compliance + ! with the License. You may obtain a copy of the License at + ! + ! http://www.apache.org/licenses/LICENSE-2.0 + ! + ! Unless required by applicable law or agreed to in writing, + ! software distributed under the License is distributed on an + ! "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + ! KIND, either express or implied. See the License for the + ! specific language governing permissions and limitations + ! under the License. + !--> + +## <a id="TypeFunctions">Type Functions</a> ## + +### is_array ### + * Syntax: + + is_array(expr) + + * Checks whether the given expression is evaluated to be an `array` value. + * Arguments: + * `expr` : an expression (any type is allowed). + * Return Value: + * a `boolean` on whether the argument is an `array` value or not, + * a `missing` if the argument is a `missing` value, + * a `null` if the argument is a `null` value. + + * Example: + + { + "a": is_array(true), + "b": is_array(false), + "c": isarray(null), + "d": isarray(missing), + "e": isarray("d"), + "f": isarray(4.0), + "g": isarray(5), + "h": isarray(["1", 2]), + "i": isarray({"a":1}) + }; + + + * The expected result is: + + { "a": false, "b": false, "c": null, "e": false, "f": false, "g": false, "h": true, "i": false } + + The function has an alias `isarray`. + +### is_multiset ### + * Syntax: + + is_multiset(expr) + + * Checks whether the given expression is evaluated to be an `multiset` value. + * Arguments: + * `expr` : an expression (any type is allowed). + * Return Value: + * a `boolean` on whether the argument is an `multiset` value or not, + * a `missing` if the argument is a `missing` value, + * a `null` if the argument is a `null` value. + + * Example: + + { + "a": is_multiset(true), + "b": is_multiset(false), + "c": is_multiset(null), + "d": is_multiset(missing), + "e": is_multiset("d"), + "f": ismultiset(4.0), + "g": ismultiset(["1", 2]), + "h": ismultiset({"a":1}), + "i": ismultiset({{"hello", 9328, "world", [1, 2, null]}}) + }; + + + * The expected result is: + + { "a": false, "b": false, "c": null, "e": false, "f": false, "g": false, "h": false, "i": true } + + The function has an alias `ismultiset`. + +### is_atomic (is_atom) ### + * Syntax: + + is_atomic(expr) + + * Checks whether the given expression is evaluated to be a value of a [primitive](../datamodel.html#PrimitiveTypes) type. + * Arguments: + * `expr` : an expression (any type is allowed). + * Return Value: + * a `boolean` on whether the argument is a primitive type or not, + * a `missing` if the argument is a `missing` value, + * a `null` if the argument is a `null` value. + + * Example: + + { + "a": is_atomic(true), + "b": is_atomic(false), + "c": isatomic(null), + "d": isatomic(missing), + "e": isatomic("d"), + "f": isatom(4.0), + "g": isatom(5), + "h": isatom(["1", 2]), + "i": isatom({"a":1}) + }; + +* The expected result is: + + { "a": true, "b": true, "c": null, "e": true, "f": true, "g": true, "h": false, "i": false } + + The function has three aliases: `isatomic`, `is_atom`, and `isatom`. + +### is_boolean (is_bool) ### + * Syntax: + + is_boolean(expr) + + * Checks whether the given expression is evaluated to be a `boolean` value. + * Arguments: + * `expr` : an expression (any type is allowed). + * Return Value: + * a `boolean` on whether the argument is a `boolean` value or not, + * a `missing` if the argument is a `missing` value, + * a `null` if the argument is a `null` value. + + * Example: + + { + "a": isboolean(true), + "b": isboolean(false), + "c": is_boolean(null), + "d": is_boolean(missing), + "e": isbool("d"), + "f": isbool(4.0), + "g": isbool(5), + "h": isbool(["1", 2]), + "i": isbool({"a":1}) + }; + + + * The expected result is: + + { "a": true, "b": true, "c": null, "e": false, "f": false, "g": false, "h": false, "i": false } + + The function has three aliases: `isboolean`, `is_bool`, and `isbool`. + + +### is_number (is_num) ### + * Syntax: + + is_number(expr) + + * Checks whether the given expression is evaluated to be a numeric value. + * Arguments: + * `expr` : an expression (any type is allowed). + * Return Value: + * a `boolean` on whether the argument is a `smallint`/`tinyint`/`integer`/`bigint`/`float`/`double` + value or not, + * a `missing` if the argument is a `missing` value, + * a `null` if the argument is a `null` value. + + * Example: + + { + "a": is_number(true), + "b": is_number(false), + "c": isnumber(null), + "d": isnumber(missing), + "e": isnumber("d"), + "f": isnum(4.0), + "g": isnum(5), + "h": isnum(["1", 2]), + "i": isnum({"a":1}) + }; + + + * The expected result is: + + { "a": false, "b": false, "c": null, "e": false, "f": true, "g": true, "h": false, "i": false } + + The function has three aliases: `isnumber`, `is_num`, and `isnum`. + +### is_object (is_obj) ### + * Syntax: + + is_object(expr) + + * Checks whether the given expression is evaluated to be a `object` value. + * Arguments: + * `expr` : an expression (any type is allowed). + * Return Value: + * a `boolean` on whether the argument is a `object` value or not, + * a `missing` if the argument is a `missing` value, + * a `null` if the argument is a `null` value. + + * Example: + + { + "a": is_object(true), + "b": is_object(false), + "c": isobject(null), + "d": isobject(missing), + "e": isobj("d"), + "f": isobj(4.0), + "g": isobj(5), + "h": isobj(["1", 2]), + "i": isobj({"a":1}) + }; + + + * The expected result is: + + { "a": false, "b": false, "c": null, "e": false, "f": false, "g": false, "h": false, "i": true } + + The function has three aliases: `isobject`, `is_obj`, and `isobj`. + + +### is_string (is_str) ### + * Syntax: + + is_string(expr) + + * Checks whether the given expression is evaluated to be a `string` value. + * Arguments: + * `expr` : an expression (any type is allowed). + * Return Value: + * a `boolean` on whether the argument is a `string` value or not, + * a `missing` if the argument is a `missing` value, + * a `null` if the argument is a `null` value. + + * Example: + + { + "a": is_string(true), + "b": isstring(false), + "c": isstring(null), + "d": isstr(missing), + "e": isstr("d"), + "f": isstr(4.0), + "g": isstr(5), + "h": isstr(["1", 2]), + "i": isstr({"a":1}) + }; + + + * The expected result is: + + { "a": false, "b": false, "c": null, "e": true, "f": false, "g": false, "h": false, "i": false } + + The function has three aliases: `isstring`, `is_str`, and `isstr`. + +### is_null ### + * Syntax: + + is_null(expr) + + * Checks whether the given expression is evaluated to be a `null` value. + * Arguments: + * `expr` : an expression (any type is allowed). + * Return Value: + * a `boolean` on whether the variable is a `null` or not, + * a `missing` if the input is `missing`. + + * Example: + + { "v1": is_null(null), "v2": is_null(1), "v3": is_null(missing) }; + + + * The expected result is: + + { "v1": true, "v2": false } + + The function has an alias `isnull`. + +### is_missing ### + * Syntax: + + is_missing(expr) + + * Checks whether the given expression is evaluated to be a `missing` value. + * Arguments: + * `expr` : an expression (any type is allowed). + * Return Value: + * a `boolean` on whether the variable is a `missing` or not. + + * Example: + + { "v1": is_missing(null), "v2": is_missing(1), "v3": is_missing(missing) }; + + + * The expected result is: + + { "v1": false, "v2": false, "v3": true } + + The function has an alias `ismissing`. + +### is_unknown ### + * Syntax: + + is_unknown(expr) + + * Checks whether the given variable is a `null` value or a `missing` value. + * Arguments: + * `expr` : an expression (any type is allowed). + * Return Value: + * a `boolean` on whether the variable is a `null`/``missing` value (`true`) or not (`false`). + + * Example: + + { "v1": is_unknown(null), "v2": is_unknown(1), "v3": is_unknown(missing) }; + + + * The expected result is: + + { "v1": true, "v2": false, "v3": true } + + The function has an alias `isunknown`. + diff --git a/asterixdb/asterix-doc/src/main/markdown/builtins/11_type_conversion.md b/asterixdb/asterix-doc/src/main/markdown/builtins/11_type_conversion.md new file mode 100644 index 0000000..70195ec --- /dev/null +++ b/asterixdb/asterix-doc/src/main/markdown/builtins/11_type_conversion.md @@ -0,0 +1,279 @@ +<!-- + ! Licensed to the Apache Software Foundation (ASF) under one + ! or more contributor license agreements. See the NOTICE file + ! distributed with this work for additional information + ! regarding copyright ownership. The ASF licenses this file + ! to you under the Apache License, Version 2.0 (the + ! "License"); you may not use this file except in compliance + ! with the License. You may obtain a copy of the License at + ! + ! http://www.apache.org/licenses/LICENSE-2.0 + ! + ! Unless required by applicable law or agreed to in writing, + ! software distributed under the License is distributed on an + ! "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + ! KIND, either express or implied. See the License for the + ! specific language governing permissions and limitations + ! under the License. + !--> + +### to_array ### + * Syntax: + + to_array(expr) + + * Converts input value to an `array` value + * Arguments: + * `expr` : an expression + * Return Value: + * if the argument is `missing` then `missing` is returned + * if the argument is `null` then `null` is returned + * if the argument is of `array` type then it is returned as is + * if the argument is of `multiset` type then it is returned as an `array` with elements in an undefined order + * otherwise an `array` containing the input expression as its single item is returned + + * Example: + + { + "v1": to_array("asterix"), + "v2": to_array(["asterix"]), + }; + + * The expected result is: + + { "v1": ["asterix"], "v2": ["asterix"] } + + The function has an alias `toarray`. + +### to_atomic (to_atom) ### + * Syntax: + + to_atomic(expr) + + * Converts input value to a [primitive](../datamodel.html#PrimitiveTypes) value + * Arguments: + * `expr` : an expression + * Return Value: + * if the argument is `missing` then `missing` is returned + * if the argument is `null` then `null` is returned + * if the argument is of primitive type then it is returned as is + * if the argument is of `array` or `multiset` type and has only one element then the result of invoking + to_atomic() on that element is returned + * if the argument is of `object` type and has only one field then the result of invoking to_atomic() on the + value of that field is returned + * otherwise `null` is returned + + * Example: + + { + "v1": to_atomic("asterix"), + "v2": to_atomic(["asterix"]), + "v3": to_atomic([0, 1]), + "v4": to_atomic({"value": "asterix"}), + "v5": to_number({"x": 1, "y": 2}) + }; + + * The expected result is: + + { "v1": "asterix", "v2": "asterix", "v3": null, "v4": "asterix", "v5": null } + + The function has three aliases: `toatomic`, `to_atom`, and `toatom`. + +### to_boolean (to_bool) ### + * Syntax: + + to_boolean(expr) + + * Converts input value to a `boolean` value + * Arguments: + * `expr` : an expression + * Return Value: + * if the argument is `missing` then `missing` is returned + * if the argument is `null` then `null` is returned + * if the argument is of `boolean` type then it is returned as is + * if the argument is of numeric type then `false` is returned if it is `0` or `NaN`, otherwise `true` + * if the argument is of `string` type then `false` is returned if it's empty, otherwise `true` + * if the argument is of `array` or `multiset` type then `false` is returned if it's size is `0`, otherwise `true` + * if the argument is of `object` type then `false` is returned if it has no fields, otherwise `true` + * type error is raised for all other input types + + * Example: + + { + "v1": to_boolean(0), + "v2": to_boolean(1), + "v3": to_boolean(""), + "v4": to_boolean("asterix") + }; + + * The expected result is: + + { "v1": false, "v2": true, "v3": false, "v4": true } + + The function has three aliases: `toboolean`, `to_bool`, and `tobool`. + +### to_bigint ### + * Syntax: + + to_bigint(expr) + + * Converts input value to an integer value + * Arguments: + * `expr` : an expression + * Return Value: + * if the argument is `missing` then `missing` is returned + * if the argument is `null` then `null` is returned + * if the argument is of `boolean` type then `1` is returned if it is `true`, `0` if it is `false` + * if the argument is of numeric integer type then it is returned as the same value of `bigint` type + * if the argument is of numeric `float`/`double` type then it is converted to `bigint` type + * if the argument is of `string` type and can be parsed as integer then that integer value is returned, + otherwise `null` is returned + * if the argument is of `array`/`multiset`/`object` type then `null` is returned + * type error is raised for all other input types + + * Example: + + { + "v1": to_bigint(false), + "v2": to_bigint(true), + "v3": to_bigint(10), + "v4": to_bigint(float("1e100")), + "v5": to_bigint(double("1e1000")), + "v6": to_bigint("20") + }; + + * The expected result is: + + { "v1": 0, "v2": 1, "v3": 10, "v4": 9223372036854775807, "v5": 9223372036854775807, "v6": 20 } + + The function has an alias `tobigint`. + +### to_double ### + * Syntax: + + to_double(expr) + + * Converts input value to a `double` value + * Arguments: + * `expr` : an expression + * Return Value: + * if the argument is `missing` then `missing` is returned + * if the argument is `null` then `null` is returned + * if the argument is of `boolean` type then `1.0` is returned if it is `true`, `0.0` if it is `false` + * if the argument is of numeric type then it is returned as the value of `double` type + * if the argument is of `string` type and can be parsed as `double` then that `double` value is returned, + otherwise `null` is returned + * if the argument is of `array`/`multiset`/`object` type then `null` is returned + * type error is raised for all other input types + + * Example: + + { + "v1": to_double(false), + "v2": to_double(true), + "v3": to_double(10), + "v4": to_double(11.5), + "v5": to_double("12.5") + }; + + * The expected result is: + + { "v1": 0.0, "v2": 1.0, "v3": 10.0, "v4": 11.5, "v5": 12.5 } + + The function has an alias `todouble`. + +### to_number (to_num) ### + * Syntax: + + to_number(expr) + + * Converts input value to a numeric value + * Arguments: + * `expr` : an expression + * Return Value: + * if the argument is `missing` then `missing` is returned + * if the argument is `null` then `null` is returned + * if the argument is of numeric type then it is returned as is + * if the argument is of `boolean` type then `1` is returned if it is `true`, `0` if it is `false` + * if the argument is of `string` type and can be parsed as `bigint` then that `bigint` value is returned, + otherwise if it can be parsed as `double` then that `double` value is returned, + otherwise `null` is returned + * if the argument is of `array`/`multiset`/`object` type then `null` is returned + * type error is raised for all other input types + + * Example: + + { + "v1": to_number(false), + "v2": to_number(true), + "v3": to_number(10), + "v4": to_number(11.5), + "v5": to_number("12.5") + }; + + * The expected result is: + + { "v1": 0, "v2": 1, "v3": 10, "v4": 11.5, "v5": 12.5 } + + The function has three aliases: `tonumber`, `to_num`, and `tonum`. + +### to_object (to_obj) ### + * Syntax: + + to_object(expr) + + * Converts input value to an `object` value + * Arguments: + * `expr` : an expression + * Return Value: + * if the argument is `missing` then `missing` is returned + * if the argument is `null` then `null` is returned + * if the argument is of `object` type then it is returned as is + * otherwise an empty `object` is returned + + * Example: + + { + "v1": to_object({"value": "asterix"}), + "v2": to_object("asterix") + }; + + * The expected result is: + + { "v1": {"value": "asterix"}, "v2": {} } + + The function has three aliases: `toobject`, `to_obj`, and `toobj`. + +### to_string (to_str) ### + * Syntax: + + to_string(expr) + + * Converts input value to a string value + * Arguments: + * `expr` : an expression + * Return Value: + * if the argument is `missing` then `missing` is returned + * if the argument is `null` then `null` is returned + * if the argument is of `boolean` type then `"true"` is returned if it is `true`, `"false"` if it is `false` + * if the argument is of numeric type then its string representation is returned + * if the argument is of `string` type then it is returned as is + * if the argument is of `array`/`multiset`/`object` type then `null` is returned + * type error is raised for all other input types + + * Example: + + { + "v1": to_string(false), + "v2": to_string(true), + "v3": to_string(10), + "v4": to_string(11.5), + "v5": to_string("asterix") + }; + + * The expected result is: + + { "v1": "false", "v2": "true", "v3": "10", "v4": "11.5", "v5": "asterix" } + + The function has three aliases: `tostring`, `to_str`, and `tostr`. + diff --git a/asterixdb/asterix-doc/src/main/markdown/builtins/11_type.md b/asterixdb/asterix-doc/src/main/markdown/builtins/11_type_delta.md similarity index 50% rename from asterixdb/asterix-doc/src/main/markdown/builtins/11_type.md rename to asterixdb/asterix-doc/src/main/markdown/builtins/11_type_delta.md index 72291a6..e9b89f8 100644 --- a/asterixdb/asterix-doc/src/main/markdown/builtins/11_type.md +++ b/asterixdb/asterix-doc/src/main/markdown/builtins/11_type_delta.md @@ -17,174 +17,6 @@ ! under the License. !--> -## <a id="TypeFunctions">Type Functions</a> ## - -### get_type ### - * Syntax: - - get_type(expr) - - * Returns a string describing the type of the given `expr`. This includes incomplete information types (i.e. `missing` and `null`). - * Arguments: - * `expr` : an expression (any type is allowed). - - * Example: - - { - "a": get_type(true), - "b": get_type(false), - "c": get_type(null), - "d": get_type(missing), - "e": get_type("d"), - "f": gettype(4.0), - "g": gettype(5), - "h": gettype(["1", 2]), - "i": gettype({"a":1}) - }; - - - * The expected result is: - - { "a": "boolean", "b": "boolean", "c": "null", "d": "missing", "e": "string", "f": "double", "g": "bigint", "h": "array", "i": "object" } - - The function has an alias `gettype`. - -### is_array ### - * Syntax: - - is_array(expr) - - * Checks whether the given expression is evaluated to be an `array` value. - * Arguments: - * `expr` : an expression (any type is allowed). - * Return Value: - * a `boolean` on whether the argument is an `array` value or not, - * a `missing` if the argument is a `missing` value, - * a `null` if the argument is a `null` value. - - * Example: - - { - "a": is_array(true), - "b": is_array(false), - "c": isarray(null), - "d": isarray(missing), - "e": isarray("d"), - "f": isarray(4.0), - "g": isarray(5), - "h": isarray(["1", 2]), - "i": isarray({"a":1}) - }; - - - * The expected result is: - - { "a": false, "b": false, "c": null, "e": false, "f": false, "g": false, "h": true, "i": false } - - The function has an alias `isarray`. - -### is_multiset ### - * Syntax: - - is_multiset(expr) - - * Checks whether the given expression is evaluated to be an `multiset` value. - * Arguments: - * `expr` : an expression (any type is allowed). - * Return Value: - * a `boolean` on whether the argument is an `multiset` value or not, - * a `missing` if the argument is a `missing` value, - * a `null` if the argument is a `null` value. - - * Example: - - { - "a": is_multiset(true), - "b": is_multiset(false), - "c": is_multiset(null), - "d": is_multiset(missing), - "e": is_multiset("d"), - "f": ismultiset(4.0), - "g": ismultiset(["1", 2]), - "h": ismultiset({"a":1}), - "i": ismultiset({{"hello", 9328, "world", [1, 2, null]}}) - }; - - - * The expected result is: - - { "a": false, "b": false, "c": null, "e": false, "f": false, "g": false, "h": false, "i": true } - - The function has an alias `ismultiset`. - -### is_atomic (is_atom) ### - * Syntax: - - is_atomic(expr) - - * Checks whether the given expression is evaluated to be a value of a [primitive](../datamodel.html#PrimitiveTypes) type. - * Arguments: - * `expr` : an expression (any type is allowed). - * Return Value: - * a `boolean` on whether the argument is a primitive type or not, - * a `missing` if the argument is a `missing` value, - * a `null` if the argument is a `null` value. - - * Example: - - { - "a": is_atomic(true), - "b": is_atomic(false), - "c": isatomic(null), - "d": isatomic(missing), - "e": isatomic("d"), - "f": isatom(4.0), - "g": isatom(5), - "h": isatom(["1", 2]), - "i": isatom({"a":1}) - }; - -* The expected result is: - - { "a": true, "b": true, "c": null, "e": true, "f": true, "g": true, "h": false, "i": false } - - The function has three aliases: `isatomic`, `is_atom`, and `isatom`. - -### is_boolean (is_bool) ### - * Syntax: - - is_boolean(expr) - - * Checks whether the given expression is evaluated to be a `boolean` value. - * Arguments: - * `expr` : an expression (any type is allowed). - * Return Value: - * a `boolean` on whether the argument is a `boolean` value or not, - * a `missing` if the argument is a `missing` value, - * a `null` if the argument is a `null` value. - - * Example: - - { - "a": isboolean(true), - "b": isboolean(false), - "c": is_boolean(null), - "d": is_boolean(missing), - "e": isbool("d"), - "f": isbool(4.0), - "g": isbool(5), - "h": isbool(["1", 2]), - "i": isbool({"a":1}) - }; - - - * The expected result is: - - { "a": true, "b": true, "c": null, "e": false, "f": false, "g": false, "h": false, "i": false } - - The function has three aliases: `isboolean`, `is_bool`, and `isbool`. - - ### is_binary (is_bin) ### * Syntax: @@ -219,40 +51,37 @@ The function has three aliases: `isbinary`, `is_bin`, and `isbin`. -### is_number (is_num) ### +### is_uuid ### * Syntax: - is_number(expr) + is_uuid(expr) - * Checks whether the given expression is evaluated to be a numeric value. + * Checks whether the given expression is evaluated to be a `uuid` value. * Arguments: * `expr` : an expression (any type is allowed). * Return Value: - * a `boolean` on whether the argument is a `smallint`/`tinyint`/`integer`/`bigint`/`float`/`double` - value or not, + * a `boolean` on whether the argument is a `uuid` value or not, * a `missing` if the argument is a `missing` value, * a `null` if the argument is a `null` value. * Example: - { - "a": is_number(true), - "b": is_number(false), - "c": isnumber(null), - "d": isnumber(missing), - "e": isnumber("d"), - "f": isnum(4.0), - "g": isnum(5), - "h": isnum(["1", 2]), - "i": isnum({"a":1}) + { + "a": is_uuid(true), + "b": is_uuid(false), + "c": is_uuid(null), + "d": is_uuid(missing), + "e": isuuid(4.0), + "f": isuuid(date("2013-01-01")), + "g": isuuid(uuid("5c848e5c-6b6a-498f-8452-8847a2957421")) }; * The expected result is: - { "a": false, "b": false, "c": null, "e": false, "f": true, "g": true, "h": false, "i": false } + { "a": false, "b": false, "c": null, "e": false, "f": false, "g": true } - The function has three aliases: `isnumber`, `is_num`, and `isnum`. + The function has an alias `isuuid`. ### is_point ### * Syntax: @@ -463,7 +292,7 @@ { "a": false, "b": false, "c": null, "e": true, "f": true, "g": true, "h": true, "i": true, "j": false } The function has an alias `isspatial`. - + ### is_date ### * Syntax: @@ -679,432 +508,34 @@ { "a": false, "b": false, "c": null, "e": true, "f": true, "g": true, "h": true, "i": true, "j": true, "k": false } The function has an alias `istemporal`. - -### is_object (is_obj) ### - * Syntax: - - is_object(expr) - - * Checks whether the given expression is evaluated to be a `object` value. - * Arguments: - * `expr` : an expression (any type is allowed). - * Return Value: - * a `boolean` on whether the argument is a `object` value or not, - * a `missing` if the argument is a `missing` value, - * a `null` if the argument is a `null` value. - - * Example: - - { - "a": is_object(true), - "b": is_object(false), - "c": isobject(null), - "d": isobject(missing), - "e": isobj("d"), - "f": isobj(4.0), - "g": isobj(5), - "h": isobj(["1", 2]), - "i": isobj({"a":1}) - }; - - - * The expected result is: - - { "a": false, "b": false, "c": null, "e": false, "f": false, "g": false, "h": false, "i": true } - - The function has three aliases: `isobject`, `is_obj`, and `isobj`. - - -### is_string (is_str) ### - * Syntax: - - is_string(expr) - - * Checks whether the given expression is evaluated to be a `string` value. - * Arguments: - * `expr` : an expression (any type is allowed). - * Return Value: - * a `boolean` on whether the argument is a `string` value or not, - * a `missing` if the argument is a `missing` value, - * a `null` if the argument is a `null` value. - - * Example: - - { - "a": is_string(true), - "b": isstring(false), - "c": isstring(null), - "d": isstr(missing), - "e": isstr("d"), - "f": isstr(4.0), - "g": isstr(5), - "h": isstr(["1", 2]), - "i": isstr({"a":1}) - }; - - - * The expected result is: - - { "a": false, "b": false, "c": null, "e": true, "f": false, "g": false, "h": false, "i": false } - - The function has three aliases: `isstring`, `is_str`, and `isstr`. - -### is_uuid ### - * Syntax: - - is_uuid(expr) - * Checks whether the given expression is evaluated to be a `uuid` value. - * Arguments: - * `expr` : an expression (any type is allowed). - * Return Value: - * a `boolean` on whether the argument is a `uuid` value or not, - * a `missing` if the argument is a `missing` value, - * a `null` if the argument is a `null` value. - - * Example: - - { - "a": is_uuid(true), - "b": is_uuid(false), - "c": is_uuid(null), - "d": is_uuid(missing), - "e": isuuid(4.0), - "f": isuuid(date("2013-01-01")), - "g": isuuid(uuid("5c848e5c-6b6a-498f-8452-8847a2957421")) - }; - - - * The expected result is: - - { "a": false, "b": false, "c": null, "e": false, "f": false, "g": true } - - The function has an alias `isuuid`. - - -### is_null ### - * Syntax: - - is_null(expr) - - * Checks whether the given expression is evaluated to be a `null` value. - * Arguments: - * `expr` : an expression (any type is allowed). - * Return Value: - * a `boolean` on whether the variable is a `null` or not, - * a `missing` if the input is `missing`. - - * Example: - - { "v1": is_null(null), "v2": is_null(1), "v3": is_null(missing) }; - - - * The expected result is: - - { "v1": true, "v2": false } - - The function has an alias `isnull`. - -### is_missing ### - * Syntax: - - is_missing(expr) - - * Checks whether the given expression is evaluated to be a `missing` value. - * Arguments: - * `expr` : an expression (any type is allowed). - * Return Value: - * a `boolean` on whether the variable is a `missing` or not. - - * Example: - - { "v1": is_missing(null), "v2": is_missing(1), "v3": is_missing(missing) }; - - - * The expected result is: - - { "v1": false, "v2": false, "v3": true } - - The function has an alias `ismissing`. - -### is_unknown ### +### get_type ### * Syntax: - is_unknown(expr) + get_type(expr) - * Checks whether the given variable is a `null` value or a `missing` value. + * Returns a string describing the type of the given `expr`. This includes incomplete information types (i.e. `missing` and `null`). * Arguments: * `expr` : an expression (any type is allowed). - * Return Value: - * a `boolean` on whether the variable is a `null`/``missing` value (`true`) or not (`false`). - - * Example: - - { "v1": is_unknown(null), "v2": is_unknown(1), "v3": is_unknown(missing) }; - - - * The expected result is: - - { "v1": true, "v2": false, "v3": true } - - The function has an alias `isunknown`. - -### to_array ### - * Syntax: - - to_array(expr) - - * Converts input value to an `array` value - * Arguments: - * `expr` : an expression - * Return Value: - * if the argument is `missing` then `missing` is returned - * if the argument is `null` then `null` is returned - * if the argument is of `array` type then it is returned as is - * if the argument is of `multiset` type then it is returned as an `array` with elements in an undefined order - * otherwise an `array` containing the input expression as its single item is returned - - * Example: - - { - "v1": to_array("asterix"), - "v2": to_array(["asterix"]), - }; - - * The expected result is: - - { "v1": ["asterix"], "v2": ["asterix"] } - - The function has an alias `toarray`. - -### to_atomic (to_atom) ### - * Syntax: - - to_atomic(expr) - - * Converts input value to a [primitive](../datamodel.html#PrimitiveTypes) value - * Arguments: - * `expr` : an expression - * Return Value: - * if the argument is `missing` then `missing` is returned - * if the argument is `null` then `null` is returned - * if the argument is of primitive type then it is returned as is - * if the argument is of `array` or `multiset` type and has only one element then the result of invoking - to_atomic() on that element is returned - * if the argument is of `object` type and has only one field then the result of invoking to_atomic() on the - value of that field is returned - * otherwise `null` is returned - - * Example: - - { - "v1": to_atomic("asterix"), - "v2": to_atomic(["asterix"]), - "v3": to_atomic([0, 1]), - "v4": to_atomic({"value": "asterix"}), - "v5": to_number({"x": 1, "y": 2}) - }; - - * The expected result is: - - { "v1": "asterix", "v2": "asterix", "v3": null, "v4": "asterix", "v5": null } - - The function has three aliases: `toatomic`, `to_atom`, and `toatom`. - -### to_boolean (to_bool) ### - * Syntax: - - to_boolean(expr) - - * Converts input value to a `boolean` value - * Arguments: - * `expr` : an expression - * Return Value: - * if the argument is `missing` then `missing` is returned - * if the argument is `null` then `null` is returned - * if the argument is of `boolean` type then it is returned as is - * if the argument is of numeric type then `false` is returned if it is `0` or `NaN`, otherwise `true` - * if the argument is of `string` type then `false` is returned if it's empty, otherwise `true` - * if the argument is of `array` or `multiset` type then `false` is returned if it's size is `0`, otherwise `true` - * if the argument is of `object` type then `false` is returned if it has no fields, otherwise `true` - * type error is raised for all other input types - - * Example: - - { - "v1": to_boolean(0), - "v2": to_boolean(1), - "v3": to_boolean(""), - "v4": to_boolean("asterix") - }; - - * The expected result is: - - { "v1": false, "v2": true, "v3": false, "v4": true } - - The function has three aliases: `toboolean`, `to_bool`, and `tobool`. - -### to_bigint ### - * Syntax: - - to_bigint(expr) - - * Converts input value to an integer value - * Arguments: - * `expr` : an expression - * Return Value: - * if the argument is `missing` then `missing` is returned - * if the argument is `null` then `null` is returned - * if the argument is of `boolean` type then `1` is returned if it is `true`, `0` if it is `false` - * if the argument is of numeric integer type then it is returned as the same value of `bigint` type - * if the argument is of numeric `float`/`double` type then it is converted to `bigint` type - * if the argument is of `string` type and can be parsed as integer then that integer value is returned, - otherwise `null` is returned - * if the argument is of `array`/`multiset`/`object` type then `null` is returned - * type error is raised for all other input types - - * Example: - - { - "v1": to_bigint(false), - "v2": to_bigint(true), - "v3": to_bigint(10), - "v4": to_bigint(float("1e100")), - "v5": to_bigint(double("1e1000")), - "v6": to_bigint("20") - }; - - * The expected result is: - - { "v1": 0, "v2": 1, "v3": 10, "v4": 9223372036854775807, "v5": 9223372036854775807, "v6": 20 } - - The function has an alias `tobigint`. - -### to_double ### - * Syntax: - - to_double(expr) - - * Converts input value to a `double` value - * Arguments: - * `expr` : an expression - * Return Value: - * if the argument is `missing` then `missing` is returned - * if the argument is `null` then `null` is returned - * if the argument is of `boolean` type then `1.0` is returned if it is `true`, `0.0` if it is `false` - * if the argument is of numeric type then it is returned as the value of `double` type - * if the argument is of `string` type and can be parsed as `double` then that `double` value is returned, - otherwise `null` is returned - * if the argument is of `array`/`multiset`/`object` type then `null` is returned - * type error is raised for all other input types - - * Example: - - { - "v1": to_double(false), - "v2": to_double(true), - "v3": to_double(10), - "v4": to_double(11.5), - "v5": to_double("12.5") - }; - - * The expected result is: - - { "v1": 0.0, "v2": 1.0, "v3": 10.0, "v4": 11.5, "v5": 12.5 } - - The function has an alias `todouble`. - -### to_number (to_num) ### - * Syntax: - - to_number(expr) - - * Converts input value to a numeric value - * Arguments: - * `expr` : an expression - * Return Value: - * if the argument is `missing` then `missing` is returned - * if the argument is `null` then `null` is returned - * if the argument is of numeric type then it is returned as is - * if the argument is of `boolean` type then `1` is returned if it is `true`, `0` if it is `false` - * if the argument is of `string` type and can be parsed as `bigint` then that `bigint` value is returned, - otherwise if it can be parsed as `double` then that `double` value is returned, - otherwise `null` is returned - * if the argument is of `array`/`multiset`/`object` type then `null` is returned - * type error is raised for all other input types * Example: { - "v1": to_number(false), - "v2": to_number(true), - "v3": to_number(10), - "v4": to_number(11.5), - "v5": to_number("12.5") - }; - - * The expected result is: - - { "v1": 0, "v2": 1, "v3": 10, "v4": 11.5, "v5": 12.5 } - - The function has three aliases: `tonumber`, `to_num`, and `tonum`. - -### to_object (to_obj) ### - * Syntax: - - to_object(expr) - - * Converts input value to an `object` value - * Arguments: - * `expr` : an expression - * Return Value: - * if the argument is `missing` then `missing` is returned - * if the argument is `null` then `null` is returned - * if the argument is of `object` type then it is returned as is - * otherwise an empty `object` is returned - - * Example: - - { - "v1": to_object({"value": "asterix"}), - "v2": to_object("asterix") + "a": get_type(true), + "b": get_type(false), + "c": get_type(null), + "d": get_type(missing), + "e": get_type("d"), + "f": gettype(4.0), + "g": gettype(5), + "h": gettype(["1", 2]), + "i": gettype({"a":1}) }; - * The expected result is: - - { "v1": {"value": "asterix"}, "v2": {} } - - The function has three aliases: `toobject`, `to_obj`, and `toobj`. - -### to_string (to_str) ### - * Syntax: - - to_string(expr) - - * Converts input value to a string value - * Arguments: - * `expr` : an expression - * Return Value: - * if the argument is `missing` then `missing` is returned - * if the argument is `null` then `null` is returned - * if the argument is of `boolean` type then `"true"` is returned if it is `true`, `"false"` if it is `false` - * if the argument is of numeric type then its string representation is returned - * if the argument is of `string` type then it is returned as is - * if the argument is of `array`/`multiset`/`object` type then `null` is returned - * type error is raised for all other input types - - * Example: - - { - "v1": to_string(false), - "v2": to_string(true), - "v3": to_string(10), - "v4": to_string(11.5), - "v5": to_string("asterix") - }; * The expected result is: - { "v1": "false", "v2": "true", "v3": "10", "v4": "11.5", "v5": "asterix" } + { "a": "boolean", "b": "boolean", "c": "null", "d": "missing", "e": "string", "f": "double", "g": "bigint", "h": "array", "i": "object" } + + The function has an alias `gettype`. - The function has three aliases: `tostring`, `to_str`, and `tostr`.
