org.apache.arrow.vector.types.pojo.ArrowType.Utf8 Java Examples

The following examples show how to use org.apache.arrow.vector.types.pojo.ArrowType.Utf8. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CompleteType.java    From dremio-oss with Apache License 2.0 5 votes vote down vote up
public boolean isFixedWidthScalar() {
  switch(type.getTypeID()){
  case List:
  case Struct:
  case Union:
  case Binary:
  case Utf8:
    return false;
  default:
    return true;
  }
}
 
Example #2
Source File: CompleteType.java    From dremio-oss with Apache License 2.0 5 votes vote down vote up
public boolean isVariableWidthScalar() {
  switch(type.getTypeID()){
  case Utf8:
  case Binary:
    return true;
  default:
    return false;
  }
}
 
Example #3
Source File: AbstractTestNamespaceService.java    From dremio-oss with Apache License 2.0 5 votes vote down vote up
@Test
public void testDataSetSchema() throws Exception {
  Field field1 = new Field("a", true, new Int(32, true), null);
  Field child1 = new Field("c", true, Utf8.INSTANCE, null);
  Field field2 = new Field("b", true, Struct.INSTANCE, ImmutableList.of(child1));
  Schema schema = new Schema(ImmutableList.of(field1, field2));
  FlatBufferBuilder builder = new FlatBufferBuilder();
  schema.getSchema(builder);
  builder.finish(schema.getSchema(builder));
  NamespaceTestUtils.addSource(namespaceService, "s");
  NamespaceTestUtils.addPhysicalDS(namespaceService, "s.foo", builder.sizedByteArray());
  ByteBuffer bb = ByteBuffer.wrap(DatasetHelper.getSchemaBytes(namespaceService.getDataset(new NamespaceKey(PathUtils.parseFullPath("s.foo")))).toByteArray());
  Schema returnedSchema = Schema.convertSchema(org.apache.arrow.flatbuf.Schema.getRootAsSchema(bb));
  assertEquals(schema, returnedSchema);
}
 
Example #4
Source File: SqlTypeNameToArrowType.java    From dremio-flight-connector with Apache License 2.0 4 votes vote down vote up
public static ArrowType toArrowType(UserProtos.ResultColumnMetadata type) {
  String typeName = type.getDataType();
  switch (typeName) {
    case "NULL":
      return new Null();
    case "MAP":
      return new ArrowType.Map(false); //todo inner type?
    case "ARRAY":
      return new ArrowType.List(); //todo inner type?
    case "UNION":
      throw new UnsupportedOperationException("have not implemented unions");
      //return new Union(); //todo inner type?
    case "TINYINT":
      return new Int(8, true);
    case "SMALLINT":
      return new Int(16, true);
    case "INTEGER":
      return new Int(32, true);
    case "BIGINT":
      return new Int(64, true);
    case "FLOAT":
      return new FloatingPoint(FloatingPointPrecision.SINGLE);
    case "DOUBLE":
      return new FloatingPoint(FloatingPointPrecision.DOUBLE);
    case "CHARACTER VARYING":
      return new Utf8();
    case "BINARY VARYING":
      return new Binary();
    case "BOOLEAN":
      return new Bool();
    case "DECIMAL":
      return new Decimal(type.getPrecision(), type.getScale());
    case "DATE":
      return new Date(DateUnit.MILLISECOND);
    case "TIME":
      return new Time(TimeUnit.MICROSECOND, 64);
    case "TIMESTAMP":
      return new Timestamp(TimeUnit.MICROSECOND, "UTC");
    case "INTERVAL DAY TO SECOND":
      return new Interval(IntervalUnit.DAY_TIME);
    case "INTERVAL YEAR TO MONTH":
      return new Interval(IntervalUnit.YEAR_MONTH);
    case "BINARY":
      return new ArrowType.FixedSizeBinary(50);
    default:
      throw new IllegalStateException("unable to find arrow type for " + typeName);
  }
}
 
Example #5
Source File: AbstractArrowTypeVisitor.java    From dremio-oss with Apache License 2.0 4 votes vote down vote up
@Override
public T visit(Utf8 type) {
  return visitGeneric(type);
}
 
Example #6
Source File: Describer.java    From dremio-oss with Apache License 2.0 4 votes vote down vote up
@Override
public String visit(Utf8 type) {
  return "varchar";
}
 
Example #7
Source File: CompleteType.java    From dremio-oss with Apache License 2.0 4 votes vote down vote up
public boolean isText() {
  return type.getTypeID() == ArrowTypeID.Utf8;
}
 
Example #8
Source File: SqlDisplaySizeVisitor.java    From dremio-oss with Apache License 2.0 4 votes vote down vote up
@Override
public Integer visit(Utf8 paramUtf8) {
  return 65536;
}
 
Example #9
Source File: SqlTypeNameVisitor.java    From dremio-oss with Apache License 2.0 4 votes vote down vote up
@Override
public String visit(Utf8 paramUtf8) {
  return "CHARACTER VARYING";
}
 
Example #10
Source File: ComplexToJsonPrel.java    From dremio-oss with Apache License 2.0 4 votes vote down vote up
Field asVarchar(){
  return new Field(field.getName(), true, Utf8.INSTANCE, Collections.<Field>emptyList());
}
 
Example #11
Source File: HiveSchemaConverter.java    From dremio-oss with Apache License 2.0 4 votes vote down vote up
public static Field getArrowFieldFromHivePrimitiveType(String name, TypeInfo typeInfo) {
  switch (typeInfo.getCategory()) {
  case PRIMITIVE:
    PrimitiveTypeInfo pTypeInfo = (PrimitiveTypeInfo) typeInfo;
    switch (pTypeInfo.getPrimitiveCategory()) {
    case BOOLEAN:

      return new Field(name, true, new Bool(), null);
    case BYTE:
      return new Field(name, true, new Int(32, true), null);
    case SHORT:
      return new Field(name, true, new Int(32, true), null);

    case INT:
      return new Field(name, true, new Int(32, true), null);

    case LONG:
      return new Field(name, true, new Int(64, true), null);

    case FLOAT:
      return new Field(name, true, new FloatingPoint(FloatingPointPrecision.SINGLE), null);

    case DOUBLE:
      return new Field(name, true, new FloatingPoint(FloatingPointPrecision.DOUBLE), null);

    case DATE:
      return new Field(name, true, new Date(DateUnit.MILLISECOND), null);

    case TIMESTAMP:
      return new Field(name, true, new Timestamp(TimeUnit.MILLISECOND, null), null);

    case BINARY:
      return new Field(name, true, new Binary(), null);
    case DECIMAL: {
      DecimalTypeInfo decimalTypeInfo = (DecimalTypeInfo) pTypeInfo;
      return new Field(name, true, new Decimal(decimalTypeInfo.getPrecision(), decimalTypeInfo.getScale()), null);
    }

    case STRING:
    case VARCHAR:
    case CHAR: {
      return new Field(name, true, new Utf8(), null);
    }
    case UNKNOWN:
    case VOID:
    default:
      // fall through.
    }
  default:
  }

  return null;
}