![]() ![]() If you invoke date_add() with two STRINGs, Databricks crosscasts the first STRING to DATE and the second STRING to an INTEGER. If the argument type is a STRING and the expected parameter type is a simple type, Databricks crosscasts the string argument to the widest supported parameter type.įor example, date_add(date, days) expects a DATE and an INTEGER. Instead, you can pass a numeric or datetime type. If the expected parameter type is a STRING and the argument is a simple type Databricks crosscasts the argument to the string parameter type.įor example, substr(str, start, len) expects str to be a STRING. ![]() In most cases the function description explicitly states the supported types or chain, such as “any numeric type”.įor example, sin(expr) operates on DOUBLE but will accept any numeric. ![]() If a supported parameter type is part of the argument’s type precedence graph, Databricks promotes the argument to that parameter type. Given a resolved function or operator, the following rules apply, in the order they are listed, for each parameter and argument pair: If any of the contributing types is an exact numeric type ( TINYINT, SMALLINT, INTEGER, BIGINT, or DECIMAL) the least common type is pushed to DOUBLE to avoid potential loss of digits. Special rules are applied if the least common type resolves to FLOAT. Such as coalesce, in, least, or greatest.ĭerive the operand types for operators such as arithmetic operations or comparisons.ĭerive the result type for expressions such as the case expression.ĭerive the element, key, or value types for array and map constructors.ĭerive the result type of UNION, INTERSECT, or EXCEPT set operators. The least common type resolution is used to:ĭecide whether a function that expects a parameter of a given type can be invoked using an argument of a narrower type.ĭerive the argument type for a function that expects a shared argument type for multiple parameters, The least common type from a set of types is the narrowest type reachable from the type precedence graph by all elements of the set of types.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |