Package org.apache.drill.common.expression

Examples of org.apache.drill.common.expression.FieldReference


            positionRef = frameRef.getPosition();
            segmentRef = frameRef.getSegment();
        }

        if (positionRef == null) {
            positionRef = new FieldReference("ref.position", ExpressionPosition.UNKNOWN);
        }

        if (segmentRef == null) {
            segmentRef = new FieldReference("ref.segment", ExpressionPosition.UNKNOWN);
        }

        withinRef = config.getWithin();
        withinConstrained = withinRef != null;
    }
View Full Code Here


                "{id: 0, v: 0}" +
                "{id: 1, v: 1}" +
                "{id: 2, v: 2}" +
                "{id: 3, v: 3}" +
                "{id: 4, v: 4}";
        WindowFrameROP rop = new WindowFrameROP(new WindowFrame(new FieldReference("test.v", ExpressionPosition.UNKNOWN), null, -2L, 2L));
        RecordIterator incoming = TestUtils.jsonToRecordIterator("test", withinInput);
        rop.setInput(incoming);
        RecordIterator out = rop.getOutput();

        List<WindowObj> windows = Lists.newArrayList(
View Full Code Here

                "{id: 0, v: 0}" +
                "{id: 1, v: 0}" +
                "{id: 2, v: 1}" +
                "{id: 3, v: 1}" +
                "{id: 4, v: 2}";
        WindowFrameROP rop = new WindowFrameROP(new WindowFrame(new FieldReference("test.v", ExpressionPosition.UNKNOWN), null, -1L, 2L));
        RecordIterator incoming = TestUtils.jsonToRecordIterator("test", withinInput);
        rop.setInput(incoming);
        RecordIterator out = rop.getOutput();

        List<WindowObj> windows = Lists.newArrayList(
View Full Code Here

                "{id: 2, v: 0}" +
                "{id: 3, v: 0}" +
                "{id: 4, v: 1}" +
                "{id: 5, v: 1}" +
                "{id: 6, v: 2}";
        WindowFrameROP rop = new WindowFrameROP(new WindowFrame(new FieldReference("test.v", ExpressionPosition.UNKNOWN), null, -1L, 3L));
        RecordIterator incoming = TestUtils.jsonToRecordIterator("test", withinInput);
        rop.setInput(incoming);
        RecordIterator out = rop.getOutput();

        List<WindowObj> windows = Lists.newArrayList(
View Full Code Here

      List<OrderDef> orderDefs = Lists.newArrayList();
     
      List<NamedExpression> keys = Lists.newArrayList();
      for(LogicalExpression e : segment.getExprs()){
        if( !(e instanceof SchemaPath)) throw new OptimizerException("The basic optimizer doesn't currently support collapsing aggregate where the segment value is something other than a SchemaPath.");
        keys.add(new NamedExpression(e, new FieldReference((SchemaPath) e)));
        orderDefs.add(new OrderDef(Direction.ASC, e));
      }
      Sort sort = new Sort(segment.getInput().accept(this, value), orderDefs, false);
     
      StreamingAggregate sa = new StreamingAggregate(sort, keys.toArray(new NamedExpression[keys.size()]), agg.getAggregations(), 1.0f);
View Full Code Here

    builder.addField(getField(2, "test", bigIntType));
    final BatchSchema schema = builder.build();

    new NonStrictExpectations() {
      {
        batch.getValueVectorId(new FieldReference("test", ExpressionPosition.UNKNOWN));
        result = new TypedFieldId(Types.required(MinorType.BIGINT), -5);
      }
    };

    ErrorCollector ec = new ErrorCollectorImpl();
    LogicalExpression expr = ExpressionTreeMaterializer.materialize(new FieldReference("test",
        ExpressionPosition.UNKNOWN), batch, ec);
    assertEquals(bigIntType, expr.getMajorType());
    assertFalse(ec.hasErrors());
  }
View Full Code Here

  @Test
  public void testMaterializingLateboundTree(final @Injectable RecordBatch batch) throws SchemaChangeException {
    new NonStrictExpectations() {
      {
        batch.getValueVectorId(new FieldReference("test", ExpressionPosition.UNKNOWN));
        result = new TypedFieldId(Types.required(MinorType.BIT), -4);
        batch.getValueVectorId(new FieldReference("test1", ExpressionPosition.UNKNOWN));
        result = new TypedFieldId(Types.required(MinorType.BIGINT), -5);
      }
    };

    ErrorCollector ec = new ErrorCollectorImpl();

    LogicalExpression expr = new IfExpression.Builder()
        .addCondition(
            new IfExpression.IfCondition( //
                new FieldReference("test", ExpressionPosition.UNKNOWN), //
                new IfExpression.Builder()
                    //
                    .addCondition( //
                        new IfExpression.IfCondition(
                            //
                            new ValueExpressions.BooleanExpression("true", ExpressionPosition.UNKNOWN),
                            new FieldReference("test1", ExpressionPosition.UNKNOWN)))
                    .setElse(new ValueExpressions.LongExpression(1L, ExpressionPosition.UNKNOWN)).build()) //
        ) //
        .setElse(new ValueExpressions.LongExpression(1L, ExpressionPosition.UNKNOWN)).build();
    LogicalExpression newExpr = ExpressionTreeMaterializer.materialize(expr, batch, ec);
    assertTrue(newExpr instanceof IfExpression);
View Full Code Here

      }
    };

    new NonStrictExpectations() {
      {
        batch.getValueVectorId(new FieldReference("test", ExpressionPosition.UNKNOWN));
        result = new TypedFieldId(Types.required(MinorType.BIGINT), -5);
      }
    };

   
    LogicalExpression functionCallExpr = new FunctionCall(FunctionDefinition.simple("testFunc",
        new ArgumentValidator() {
          @Override
          public void validateArguments(ExpressionPosition expr, List<LogicalExpression> expressions,
              ErrorCollector errors) {
            errors.addGeneralError(expr, "Error!");
          }

          @Override
          public String[] getArgumentNamesByPosition() {
            return new String[0];
          }
        }, OutputTypeDeterminer.FIXED_BIT), ImmutableList.of((LogicalExpression) //
            new FieldReference("test", ExpressionPosition.UNKNOWN) ), ExpressionPosition.UNKNOWN);
    LogicalExpression newExpr = ExpressionTreeMaterializer.materialize(functionCallExpr, batch, ec);
    assertTrue(newExpr instanceof FunctionCall);
    FunctionCall funcExpr = (FunctionCall) newExpr;
    assertEquals(1, funcExpr.args.size());
    assertEquals(bigIntType, funcExpr.args.get(0).getMajorType());
View Full Code Here

    }
  }

  /** hack to make ref and full work together... need to figure out if this is still necessary. **/
  private FieldReference getRef(NamedExpression e){
    FieldReference ref = e.getRef();
    PathSegment seg = ref.getRootSegment();
    if(seg.isNamed() && "output".contentEquals(seg.getNameSegment().getPath())){
      return new FieldReference(ref.getPath().toString().subSequence(7, ref.getPath().length()), ref.getPosition());
    }
    return ref;
  }
View Full Code Here

        result = new TypedFieldId(Types.required(MinorType.BIGINT), -5);
      }
    };

    ErrorCollector ec = new ErrorCollectorImpl();
    LogicalExpression expr = ExpressionTreeMaterializer.materialize(new FieldReference("test",
        ExpressionPosition.UNKNOWN), batch, ec, registry);
    assertEquals(bigIntType, expr.getMajorType());
    assertFalse(ec.hasErrors());
  }
View Full Code Here

TOP

Related Classes of org.apache.drill.common.expression.FieldReference

Copyright © 2018 www.massapicom. 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.