[
https://issues.apache.org/jira/browse/DRILL-259?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Jinfeng Ni updated DRILL-259:
-----------------------------
Attachment: (was: DRILL_259.combined.patch.txt)
> 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: 1.0.0-milestone-2
> Reporter: Yash Sharma
> Attachments: DRILL_259.jinfeng.patch.2.txt, DRILL_259.yash.patch.txt
>
>
> *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.5#6160)