Details

    • Type: New Feature
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 0.4.0
    • Fix Version/s: 0.4.0
    • Component/s: None
    • Labels:
      None

      Description

      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.

        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.

        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.

        Attachments

        1. DRILL_259.yash.patch.txt
          40 kB
          Jinfeng Ni
        2. DRILL_259.jinfeng.patch.3.txt
          110 kB
          Jinfeng Ni
        3. DRILL_259.combined.patch.3.txt
          89 kB
          Jinfeng Ni

          Activity

            People

            • Assignee:
              jni Jinfeng Ni
              Reporter:
              yash360@gmail.com Yash Sharma
            • Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: