public static TypeDescriptor javaTypeForFieldType(FieldType fieldType) {
    switch (fieldType.getTypeName()) {
      case LOGICAL_TYPE:
        // TODO: shouldn't we handle this differently?
        return javaTypeForFieldType(fieldType.getLogicalType().getBaseType());
      case ARRAY:
        return TypeDescriptors.lists(javaTypeForFieldType(fieldType.getCollectionElementType()));
      case ITERABLE:
        return TypeDescriptors.iterables(
            javaTypeForFieldType(fieldType.getCollectionElementType()));
      case MAP:
        return TypeDescriptors.maps(
            javaTypeForFieldType(fieldType.getMapKeyType()),
            javaTypeForFieldType(fieldType.getMapValueType()));
      case ROW:
        return TypeDescriptors.rows();
      default:
        return PRIMITIVE_MAPPING.get(fieldType.getTypeName());
    }
  }
@Test
  public void testPrimitiveTypeToJavaType() {
    assertEquals(
        TypeDescriptors.bytes(), FieldTypeDescriptors.javaTypeForFieldType(FieldType.BYTE));
    assertEquals(
        TypeDescriptors.shorts(), FieldTypeDescriptors.javaTypeForFieldType(FieldType.INT16));
    assertEquals(
        TypeDescriptors.integers(), FieldTypeDescriptors.javaTypeForFieldType(FieldType.INT32));
    assertEquals(
        TypeDescriptors.longs(), FieldTypeDescriptors.javaTypeForFieldType(FieldType.INT64));
    assertEquals(
        TypeDescriptors.bigdecimals(),
        FieldTypeDescriptors.javaTypeForFieldType(FieldType.DECIMAL));
    assertEquals(
        TypeDescriptors.floats(), FieldTypeDescriptors.javaTypeForFieldType(FieldType.FLOAT));
    assertEquals(
        TypeDescriptors.doubles(), FieldTypeDescriptors.javaTypeForFieldType(FieldType.DOUBLE));
    assertEquals(
        TypeDescriptors.strings(), FieldTypeDescriptors.javaTypeForFieldType(FieldType.STRING));
    assertEquals(
        TypeDescriptor.of(Instant.class),
        FieldTypeDescriptors.javaTypeForFieldType(FieldType.DATETIME));
    assertEquals(
        TypeDescriptors.booleans(), FieldTypeDescriptors.javaTypeForFieldType(FieldType.BOOLEAN));
    assertEquals(
        TypeDescriptor.of(byte[].class),
        FieldTypeDescriptors.javaTypeForFieldType(FieldType.BYTES));
  }