Examples of MinorType


Examples of org.apache.drill.common.types.TypeProtos.MinorType

    String fullFieldName = ref != null ? ref.getPath() + "." + field.getFullFieldName() : field.getFullFieldName();
    VectorHolder holder = valueVectorMap.get(fullFieldName);

    if (holder == null) {
      MajorType type = field.getFieldType();
      MinorType minorType = type.getMinorType();

      if (minorType.equals(MinorType.MAP) || minorType.equals(MinorType.LATE)) {
        return null;
      }

      MaterializedField f = MaterializedField.create(new SchemaPath(fullFieldName, ExpressionPosition.UNKNOWN), type);
View Full Code Here

Examples of org.apache.drill.common.types.TypeProtos.MinorType

      LogicalExpression newCondition = conditions.condition.accept(this, registry);
      LogicalExpression newExpr = conditions.expression.accept(this, registry);
      conditions = new IfExpression.IfCondition(newCondition, newExpr);

      MinorType thenType = conditions.expression.getMajorType().getMinorType();
      MinorType elseType = newElseExpr.getMajorType().getMinorType();

      // Check if we need a cast
      if (thenType != elseType && !(thenType == MinorType.NULL || elseType == MinorType.NULL)) {

        MinorType leastRestrictive = TypeCastRules.getLeastRestrictiveType((Arrays.asList(thenType, elseType)));
        if (leastRestrictive != thenType) {
          // Implicitly cast the then expression
          conditions = new IfExpression.IfCondition(newCondition,
              addCastExpression(conditions.expression, newElseExpr.getMajorType(), registry));
        } else if (leastRestrictive != elseType) {
          // Implicitly cast the else expression
          newElseExpr = addCastExpression(newElseExpr, conditions.expression.getMajorType(), registry);
        } else {
          assert false: "Incorrect least restrictive type computed, leastRestrictive: " +
              leastRestrictive.toString() + " thenType: " + thenType.toString() + " elseType: " + elseType;
        }
      }

      // Resolve NullExpression into TypedNullConstant by visiting all conditions
      // We need to do this because we want to give the correct MajorType to the Null constant
View Full Code Here

Examples of org.apache.drill.common.types.TypeProtos.MinorType

      // if the cast is pointless, remove it.
      LogicalExpression input = e.getInput().accept(this,  value);

      MajorType newMajor = e.getMajorType();
      MinorType newMinor = input.getMajorType().getMinorType();

      if(castEqual(e.getPosition(), newMajor, input.getMajorType())) return input; // don't do pointless cast.

      if(newMinor == MinorType.LATE){
        // if the type still isn't fully bound, leave as cast expression.
View Full Code Here

Examples of org.apache.drill.common.types.TypeProtos.MinorType

   * Function checks if casting is allowed from the 'from' -> 'to' minor type. If its allowed
   * we also check if the precedence map allows such a cast and return true if both cases are satisfied
   */
  public static MinorType getLeastRestrictiveType(List<MinorType> types) {
    assert types.size() >= 2;
    MinorType result = types.get(0);
    int resultPrec = ResolverTypePrecedence.precedenceMap.get(result);

    for (int i = 1; i < types.size(); i++) {
      MinorType next = types.get(i);
      if (next == result) {
        // both args are of the same type; continue
        continue;
      }

View Full Code Here

Examples of org.apache.drill.common.types.TypeProtos.MinorType

    gen.flush();
  }

  private void writeValue(FieldReader reader) throws JsonGenerationException, IOException{
    final DataMode m = reader.getType().getMode();
    final MinorType mt = reader.getType().getMinorType();

    switch(m){
    case OPTIONAL:
      if(!reader.isSet()){
        gen.writeNull();
View Full Code Here

Examples of org.apache.drill.common.types.TypeProtos.MinorType

  private void newSchema() throws IOException {
    List<Type> types = Lists.newArrayList();
    for (MaterializedField field : batchSchema) {
      String name = field.getAsSchemaPath().getAsUnescapedPath();
      MinorType minorType = field.getType().getMinorType();
      PrimitiveTypeName primitiveTypeName = ParquetTypeHelper.getPrimitiveTypeNameForMinorType(minorType);
      Repetition repetition = ParquetTypeHelper.getRepetitionForDataMode(field.getDataMode());
      OriginalType originalType = ParquetTypeHelper.getOriginalTypeForMinorType(minorType);
      DecimalMetadata decimalMetadata = ParquetTypeHelper.getDecimalMetadataForField(field);
      int length = ParquetTypeHelper.getLengthForMinorType(minorType);
View Full Code Here

Examples of org.apache.drill.common.types.TypeProtos.MinorType

    }

    assert keyExprsBuild.length == keyExprsProbe.length;

    for (int i = 0; i < keyExprsBuild.length; i++) {
      MinorType buildType = keyExprsBuild[i].getMajorType().getMinorType();
      MinorType probeType = keyExprsProbe[i].getMajorType().getMinorType();

      if (buildType != probeType) {
        // We need to add a cast to one of the expressions
        List<MinorType> types = new LinkedList<>();
        types.add(buildType);
        types.add(probeType);
        MinorType result = TypeCastRules.getLeastRestrictiveType(types);

        // Add the cast
        List<LogicalExpression> args = new LinkedList<>();
        if (result == null) {
          throw new DrillRuntimeException(String.format("Join conditions cannot be compared failing build expression: %s failing probe expression: %s",
              keyExprsBuild[i].getMajorType().toString(), keyExprsProbe[i].getMajorType().toString()));
        }
        else if (result != buildType) {
          // Add a cast expression on top of the build expression
          args.add(keyExprsBuild[i]);
          FunctionCall castCall = new FunctionCall("cast" + result.toString().toUpperCase(), args, ExpressionPosition.UNKNOWN);
          keyExprsBuild[i] = ExpressionTreeMaterializer.materialize(castCall, incomingBuild, new ErrorCollectorImpl(), context.getFunctionRegistry());
        } else if (result != probeType) {
          args.add(keyExprsProbe[i]);
          FunctionCall castCall = new FunctionCall("cast" + result.toString().toUpperCase(), args, ExpressionPosition.UNKNOWN);
          keyExprsProbe[i] = ExpressionTreeMaterializer.materialize(castCall, incomingProbe, new ErrorCollectorImpl(), context.getFunctionRegistry());
        }
      }
    }
  }
View Full Code Here

Examples of org.apache.drill.common.types.TypeProtos.MinorType

    consumer = columnIO.getRecordWriter(store);
    setUp(schema, consumer);
  }

  private PrimitiveType getPrimitiveType(MaterializedField field) {
    MinorType minorType = field.getType().getMinorType();
    String name = field.getLastName();
    PrimitiveTypeName primitiveTypeName = ParquetTypeHelper.getPrimitiveTypeNameForMinorType(minorType);
    Repetition repetition = ParquetTypeHelper.getRepetitionForDataMode(field.getDataMode());
    OriginalType originalType = ParquetTypeHelper.getOriginalTypeForMinorType(minorType);
    DecimalMetadata decimalMetadata = ParquetTypeHelper.getDecimalMetadataForField(field);
View Full Code Here

Examples of org.apache.drill.common.types.TypeProtos.MinorType

    int length = ParquetTypeHelper.getLengthForMinorType(minorType);
    return new PrimitiveType(repetition, primitiveTypeName, length, name, originalType, decimalMetadata);
  }

  private parquet.schema.Type getType(MaterializedField field) {
    MinorType minorType = field.getType().getMinorType();
    DataMode dataMode = field.getType().getMode();
    switch(minorType) {
      case MAP:
        List<parquet.schema.Type> types = Lists.newArrayList();
        for (MaterializedField childField : field.getChildren()) {
View Full Code Here

Examples of org.apache.drill.common.types.TypeProtos.MinorType

   * Function checks if casting is allowed from the 'from' -> 'to' minor type. If its allowed
   * we also check if the precedence map allows such a cast and return true if both cases are satisfied
   */
  public static MinorType getLeastRestrictiveType(List<MinorType> types) {
    assert types.size() >= 2;
    MinorType result = types.get(0);
    int resultPrec = ResolverTypePrecedence.precedenceMap.get(result);

    for (int i = 1; i < types.size(); i++) {
      MinorType next = types.get(i);
      if (next == result) {
        // both args are of the same type; continue
        continue;
      }

View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.