Uploaded image for project: 'Apache Drill'
  1. Apache Drill
  2. DRILL-1164

Casting of a timestamp to date fails with complilation error

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 0.4.0
    • Component/s: Functions - Drill
    • Labels:
      None

      Description

      git.commit.id.abbrev=e5c2da0

      I have the following data as timestamp:
      0: jdbc:drill:schema=dfs> select create_time from student_v where student_id=15;
      -------------

      create_time

      -------------

      2014-11-12 12:38:15.0

      -------------

      It fails with compilation error when I cast the create_time column to a date:

      0: jdbc:drill:schema=dfs> select cast(create_time as date) from student_v where student_id=15;
      Query failed: org.apache.drill.exec.rpc.RpcException: Remote failure while running query.[error_id: "5645a2df-cf15-4e14-aa88-c10559169348"
      endpoint {
      address: "qa-node64.qa.lab"
      user_port: 31010
      control_port: 31011
      data_port: 31012
      }
      error_type: 0
      message: "Screen received stop request sent. < SchemaChangeException:[ Failure while attempting to load generated class ] < ClassTransformationException:[ Failure generating transformation classes for value:

      package org.apache.drill.exec.test.generated;

      import org.apache.drill.exec.exception.SchemaChangeException;
      import org.apache.drill.exec.expr.holders.BitHolder;
      import org.apache.drill.exec.expr.holders.NullableDateHolder;
      import org.apache.drill.exec.expr.holders.NullableTimeStampHolder;
      import org.apache.drill.exec.expr.holders.NullableVarBinaryHolder;
      import org.apache.drill.exec.ops.FragmentContext;
      import org.apache.drill.exec.record.RecordBatch;
      import org.apache.drill.exec.vector.NullableDateVector;
      import org.apache.drill.exec.vector.NullableVarBinaryVector;

      public class ProjectorGen94 {

      NullableVarBinaryVector vv0;
      NullableDateVector vv6;

      public void doSetup(FragmentContext context, RecordBatch incoming, RecordBatch outgoing)
      throws SchemaChangeException
      {
      {
      int[] fieldIds1 = new int[ 1 ] ;
      fieldIds1 [ 0 ] = 1;
      Object tmp2 = (incoming).getValueAccessorById(NullableVarBinaryVector.class, fieldIds1).getValueVector();
      if (tmp2 == null)

      { throw new SchemaChangeException("Failure while loading vector vv0 with id: org.apache.drill.exec.record.TypedFieldId@c2277e8e."); }

      vv0 = ((NullableVarBinaryVector) tmp2);
      /** start SETUP for function castTIMESTAMP **/
      {
      {}
      }
      /** end SETUP for function castTIMESTAMP **/
      /** start SETUP for function castDATE **/
      {
      {}
      }
      /** end SETUP for function castDATE **/
      int[] fieldIds7 = new int[ 1 ] ;
      fieldIds7 [ 0 ] = 0;
      Object tmp8 = (outgoing).getValueAccessorById(NullableDateVector.class, fieldIds7).getValueVector();
      if (tmp8 == null)

      { throw new SchemaChangeException("Failure while loading vector vv6 with id: org.apache.drill.exec.record.TypedFieldId@8cbf8a9."); }

      vv6 = ((NullableDateVector) tmp8);
      }
      }

      public boolean doEval(int inIndex, int outIndex)
      throws SchemaChangeException
      {
      {
      NullableVarBinaryHolder out3 = new NullableVarBinaryHolder();
      out3 .isSet = vv0 .getAccessor().isSet((inIndex));
      if (out3 .isSet == 1) {

      { vv0 .getAccessor().get((inIndex), out3); }

      }
      //---- start of eval portion of castTIMESTAMP function. ----//
      NullableTimeStampHolder out4 = new NullableTimeStampHolder();
      {
      if (out3 .isSet == 0)

      { out4 .isSet = 0; }

      else {
      final NullableTimeStampHolder out = new NullableTimeStampHolder();
      NullableVarBinaryHolder in = out3;

      CastVarCharToTimeStamp_eval:

      { byte[] buf = new byte[in.end - in.start]; in.buffer.getBytes(in.start, buf, 0, in.end - in.start); String input = new String(buf, com.google.common.base.Charsets.UTF_8); org.joda.time.format.DateTimeFormatter f = org.apache.drill.exec.expr.fn.impl.DateUtility.getDateTimeFormatter(); out.value = org.joda.time.DateTime.parse(input, f).withZoneRetainFields(org.joda.time.DateTimeZone.UTC).getMillis(); } out.isSet = 1; out4 = out; out.isSet = 1; }

      }
      //---- end of eval portion of castTIMESTAMP function. ----//
      //---- start of eval portion of castDATE function. ----//
      NullableDateHolder out5 = new NullableDateHolder();
      {
      if (out4 .isSet == 0)

      { out5 .isSet = 0; }

      else {
      final NullableDateHolder out = new NullableDateHolder();
      NullableTimeStampHolder in = out4;

      CastTimeStampToDate_eval:

      { out.value = (new DateMidnight(in.value, DateTimeZone.UTC)).getMillis(); } out.isSet = 1; out5 = out; out.isSet = 1; }

      }
      //---- end of eval portion of castDATE function. ----//
      BitHolder out9 = new BitHolder();
      out9 .value = 1;
      if (!(out5 .isSet == 0)) {
      if (!vv6 .getMutator().setSafe((outIndex), out5 .value))

      { out9 .value = 0; }
      } else {
      if (!vv6 .getMutator().isSafe((outIndex))) { out9 .value = 0; }

      }
      if (out9 .value == 0)

      { return false; }

      }

      { return true; }

      }

      }
      ] < CompileException:[ Line 97, Column 34: Cannot determine simple type name "DateMidnight" ]"
      ]Error: exception while executing query (state=,code=0)

        Attachments

          Activity

            People

            • Assignee:
              DrillCommitter DrillCommitter
              Reporter:
              knguyen Krystal
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: