Yash Sharma created DRILL-259:
---------------------------------
Summary: Proposal for CAST mechanism
Key: DRILL-259
URL: https://issues.apache.org/jira/browse/DRILL-259
Project: Apache Drill
Issue Type: New Feature
Affects Versions: M2
Reporter: Yash Sharma
*Proposal for implementing a CAST mechanism in Drill.*
===============================================
The casting mechanism would be of two types
- Implicit type casting
- Explicit type casting
*Details:*
* The Implicit type cast would take care of the casting of the lower datatype
holders to the higher datatype holders automatically.
bq. Eg. IntHolder would be casted to Float4Holder/Float8Holder directly.
* The explicit type casting would enable the user to use a CAST() function to
cast some value to another datatype by specifying the type. The cast function
would be a function exposed with syntax similar to standard SQL format.
bq. Eg. SELECT CAST (somevalue AS INT) FROM sometable;
*Type conversion rules:*
Conversion rules have to be similar to SQL standards.
_Implicit type conversion:_
* For arithmetic & comparison operators (+, -, *, /, <, >, =, etc) -
** If both operands types are different, Strings would be converted to Double,
and then both the operands would be converted to the same type by choosing the
type with higher precision.
* For values passed to a Function/UDF -
** The values would be converted to the parameter accepted by the Function.
** In case of multiple overloaded functions are present, the function with
least number of conversions would be selected.
** In case there are multiple functions with least number of conversions, there
would be an error returned to user for ambiguous function.
_Explicit Type Conversion_
* User would use the CAST Function for converting types to another specified
type.
* For nonconvertible types user gets an error back.
--
This message was sent by Atlassian JIRA
(v6.1#6144)