Package org.apache.drill.common.expression

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


    throw new UnsupportedOperationException();
  }
 
  public static ValueVector getNewVector(SchemaPath parentPath, String name, BufferAllocator allocator, MajorType type){
    SchemaPath child = parentPath.getChild(name);
    MaterializedField field = MaterializedField.create(child, type);
    return getNewVector(field, allocator);
  }
View Full Code Here


  @Test
  public void checkNullsFirst() throws Exception{
    List<UnbackedRecord> records = TestUtils.getResultAsUnbackedRecords("/order/nulls-first.json");

    DataValue[] depts = {DataValue.NULL_VALUE, new LongScalar(31), new LongScalar(33), new LongScalar(34)};
    SchemaPath dept = new SchemaPath("deptId", ExpressionPosition.UNKNOWN);
    for(int i =0; i < depts.length; i++){
      UnbackedRecord r = records.get(i);
      assertEquals(String.format("Invalid dept value for record %d.", i), depts[i], r.getField(dept));
    }
   
View Full Code Here

  @Test
  public void checkNullsLast() throws Exception{
    List<UnbackedRecord> records = TestUtils.getResultAsUnbackedRecords("/order/nulls-last.json");

    DataValue[] depts = {new LongScalar(31), new LongScalar(33), new LongScalar(34), DataValue.NULL_VALUE};
    SchemaPath dept = new SchemaPath("deptId", ExpressionPosition.UNKNOWN);
    for(int i =0; i < depts.length; i++){
      UnbackedRecord r = records.get(i);
      assertEquals(String.format("Invalid dept value for record %d.", i), depts[i], r.getField(dept));
    }
   
View Full Code Here

  public void checkNullsHandling() throws Exception{
    List<UnbackedRecord> records = TestUtils.getResultAsUnbackedRecords("/collapse/test1.json");

    DataValue[] depts = {DataValue.NULL_VALUE, new LongScalar(31), new LongScalar(33), new LongScalar(34)};
    DataValue[] cnts = {new LongScalar(1), new LongScalar(1), new LongScalar(2), new LongScalar(2)};
    SchemaPath typeCount = new SchemaPath("typeCount", ExpressionPosition.UNKNOWN);
    SchemaPath dept = new SchemaPath("deptId", ExpressionPosition.UNKNOWN);
    for(int i =0; i < depts.length; i++){
      UnbackedRecord r = records.get(i);
      assertEquals(String.format("Invalid dept value for record %d.", i), depts[i], r.getField(dept));
      assertEquals(String.format("Invalid type count value for record %d with deptId %s.", i, depts[i]), cnts[i], r.getField(typeCount));
    }
View Full Code Here

            int i = 1;
            while (iter.next() != RecordIterator.NextOutcome.NONE_LEFT){
                System.out.println(ptr);
                org.junit.Assert.assertEquals("Integer value in record " + i + " is incorrect.",
                        ptr.getField(new SchemaPath("c1", ExpressionPosition.UNKNOWN)), new ScalarValues.IntegerScalar(i));
                org.junit.Assert.assertEquals("String value in record " + i + " is incorrect.",
                        ptr.getField(new SchemaPath("c2", ExpressionPosition.UNKNOWN)), new ScalarValues.StringScalar("string " + i));
                i++;
            }
            org.junit.Assert.assertEquals("Incorrect number of records returned by 'constant' record iterator.", 3, i - 1);
        } catch (Exception ex){ ex.printStackTrace(); }
        System.out.println("end test");
View Full Code Here

        verifyWindowOrder(windows, out);
    }

    private void verifyWindowOrder(List<WindowObj> expectedIds, RecordIterator out) {
        verifyWindowOrder(expectedIds, out, new SchemaPath("ref.segment", ExpressionPosition.UNKNOWN), new SchemaPath("ref.position", ExpressionPosition.UNKNOWN));
    }
View Full Code Here

    private void verifyWindowOrder(List<WindowObj> expectedIds, RecordIterator out, SchemaPath segment, SchemaPath position) {
        RecordIterator.NextOutcome outcome = out.next();
        RecordPointer pointer = out.getRecordPointer();
        int count = 0;
        SchemaPath id = new SchemaPath("test.id", ExpressionPosition.UNKNOWN);
        int expectedSize = expectedIds.size();
        while (outcome != RecordIterator.NextOutcome.NONE_LEFT) {
            count += 1;
            WindowObj windowObj = expectedIds.get(count - 1);
            //System.out.println(windowObj);
View Full Code Here

    }
  }

  private SchemaPath toFieldName(String[] paths) {
    if(this.ref == null){
      return new SchemaPath(Joiner.on('/').join(paths), ExpressionPosition.UNKNOWN);
    }else{
      return ref.getChild(paths);
    }
  }
View Full Code Here

import com.google.common.io.Files;

public class TestUtils {
  public static RecordIterator jsonToRecordIterator(String schemaPath, String j) throws IOException {
    InputStream is = new ByteArrayInputStream(j.getBytes());
    JSONRecordReader reader = new JSONRecordReader(new SchemaPath(schemaPath, ExpressionPosition.UNKNOWN), DrillConfig.create(), is, null);
    return reader.getIterator();
  }
View Full Code Here

    ExprLexer lexer = new ExprLexer(new ANTLRStringStream(expr));
    CommonTokenStream tokens = new CommonTokenStream(lexer);
    ExprParser parser = new ExprParser(tokens);
    LogicalExpression e = parser.parse().e;
    RecordPointer r = new UnbackedRecord();
    r.addField(new SchemaPath("a", ExpressionPosition.UNKNOWN), new IntegerScalar(3));
    SimpleEvaluationVisitor builder = new SimpleEvaluationVisitor(r);
    BasicEvaluator eval = e.accept(builder, null);
    DataValue v = eval.eval();
    System.out.println(v);
  }
View Full Code Here

TOP

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

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.