Package org.apache.trevni

Examples of org.apache.trevni.ColumnMetaData


  private static final String RECORD_ARRAY =
    "{\"type\":\"array\",\"items\":"+SIMPLE_RECORD+"}";

  @Test public void testArray() throws Exception {
    ColumnMetaData p = new ColumnMetaData("[]", ValueType.NULL).isArray(true);
    check(Schema.parse(RECORD_ARRAY),
          p,
          new ColumnMetaData("[]#x", ValueType.INT).setParent(p),
          new ColumnMetaData("[]#y", ValueType.STRING).setParent(p));
  }
View Full Code Here


  }

  @Test public void testSimpleUnion() throws Exception {
    String s = "[\"int\",\"string\"]";
    check(Schema.parse(s),
          new ColumnMetaData("int", ValueType.INT).isArray(true),
          new ColumnMetaData("string", ValueType.STRING).isArray(true));
  }
View Full Code Here

  }

  @Test public void testSimpleOptional() throws Exception {
    String s = "[\"null\",\"string\"]";
    check(Schema.parse(s),
          new ColumnMetaData("string", ValueType.STRING).isArray(true));
  }
View Full Code Here

  }

  private static final String UNION = "[\"null\",\"int\","+SIMPLE_RECORD+"]";

  @Test public void testUnion() throws Exception {
    ColumnMetaData p = new ColumnMetaData("R", ValueType.NULL).isArray(true);
    check(Schema.parse(UNION),
          new ColumnMetaData("int", ValueType.INT).isArray(true),
          p,
          new ColumnMetaData("R#x", ValueType.INT).setParent(p),
          new ColumnMetaData("R#y", ValueType.STRING).setParent(p));
  }
View Full Code Here

      "{\"type\":\"record\",\"name\":\"S\",\"fields\":["
      +"{\"name\":\"x\",\"type\":\"int\"},"
      +"{\"name\":\"A\",\"type\":"+RECORD_ARRAY+"},"
      +"{\"name\":\"y\",\"type\":\"string\"}"
      +"]}";
    ColumnMetaData p = new ColumnMetaData("A[]", ValueType.NULL).isArray(true);
    check(Schema.parse(s),
          new ColumnMetaData("x", ValueType.INT),
          p,
          new ColumnMetaData("A[]#x", ValueType.INT).setParent(p),
          new ColumnMetaData("A[]#y", ValueType.STRING).setParent(p),
          new ColumnMetaData("y", ValueType.STRING));
  }
View Full Code Here

      "{\"type\":\"record\",\"name\":\"S\",\"fields\":["
      +"{\"name\":\"x\",\"type\":\"int\"},"
      +"{\"name\":\"u\",\"type\":"+UNION+"},"
      +"{\"name\":\"y\",\"type\":\"string\"}"
      +"]}";
    ColumnMetaData p = new ColumnMetaData("u/R", ValueType.NULL).isArray(true);
    check(Schema.parse(s),
          new ColumnMetaData("x", ValueType.INT),
          new ColumnMetaData("u/int", ValueType.INT).isArray(true),
          p,
          new ColumnMetaData("u/R#x", ValueType.INT).setParent(p),
          new ColumnMetaData("u/R#y", ValueType.STRING).setParent(p),
          new ColumnMetaData("y", ValueType.STRING));
  }
View Full Code Here

  @Test public void testUnionInArray() throws Exception {
    String s =
      "{\"type\":\"record\",\"name\":\"S\",\"fields\":["
      +"{\"name\":\"a\",\"type\":{\"type\":\"array\",\"items\":"+UNION+"}}"
      +"]}";
    ColumnMetaData p = new ColumnMetaData("a[]",ValueType.NULL).isArray(true);
    ColumnMetaData r = new ColumnMetaData("a[]/R", ValueType.NULL)
      .setParent(p)
      .isArray(true);
      check(Schema.parse(s),
          p,
          new ColumnMetaData("a[]/int", ValueType.INT)
            .setParent(p)
            .isArray(true),
          r,
          new ColumnMetaData("a[]/R#x", ValueType.INT).setParent(r),
          new ColumnMetaData("a[]/R#y", ValueType.STRING).setParent(r));
  }
View Full Code Here

  @Test public void testArrayInUnion() throws Exception {
    String s =
      "{\"type\":\"record\",\"name\":\"S\",\"fields\":["
      +"{\"name\":\"a\",\"type\":[\"int\","+RECORD_ARRAY+"]}]}";
    ColumnMetaData q = new ColumnMetaData("a/array",ValueType.NULL)
      .isArray(true);
    ColumnMetaData r = new ColumnMetaData("a/array[]", ValueType.NULL)
      .setParent(q)
      .isArray(true);
    check(Schema.parse(s),
          new ColumnMetaData("a/int", ValueType.INT).isArray(true),
          q,
          r,
          new ColumnMetaData("a/array[]#x", ValueType.INT).setParent(r),
          new ColumnMetaData("a/array[]#y", ValueType.STRING).setParent(r));
  }
View Full Code Here

          new ColumnMetaData("a/array[]#y", ValueType.STRING).setParent(r));
  }

  @Test public void testSimpleMap() throws Exception {
    String s = "{\"type\":\"map\",\"values\":\"long\"}";
    ColumnMetaData p = new ColumnMetaData(">", ValueType.NULL).isArray(true);
    check(Schema.parse(s),
          p,
          new ColumnMetaData(">key", ValueType.STRING).setParent(p),
          new ColumnMetaData(">value", ValueType.LONG).setParent(p));
  }
View Full Code Here

          new ColumnMetaData(">value", ValueType.LONG).setParent(p));
  }

  @Test public void testMap() throws Exception {
    String s = "{\"type\":\"map\",\"values\":"+SIMPLE_RECORD+"}";
    ColumnMetaData p = new ColumnMetaData(">", ValueType.NULL).isArray(true);
    check(Schema.parse(s),
          p,
          new ColumnMetaData(">key", ValueType.STRING).setParent(p),
          new ColumnMetaData(">value#x", ValueType.INT).setParent(p),
          new ColumnMetaData(">value#y", ValueType.STRING).setParent(p));
  }
View Full Code Here

TOP

Related Classes of org.apache.trevni.ColumnMetaData

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.