@Override public MajorType getMajorType() { return MajorType.newBuilder().setMinorType(MinorType.DECIMAL28SPARSE).setScale(bigDecimal.scale()).setPrecision(bigDecimal.precision()).setMode(DataMode.REQUIRED).build(); }
@Override public MajorType getMajorType() { return MajorType.newBuilder().setMinorType(MinorType.DECIMAL38SPARSE).setScale(bigDecimal.scale()).setPrecision(bigDecimal.precision()).setMode(DataMode.REQUIRED).build(); }
MajorType exampleIntType = MajorType.newBuilder().setMinorType(MinorType.INT).build(); when(exampleIntField.getName()).thenReturn("/path/to/testInt"); when(exampleIntField.getType()).thenReturn(exampleIntType); MajorType exampleStringType = MajorType.newBuilder().setMinorType(MinorType.VARCHAR).build(); when(exampleStringField.getName()).thenReturn("/path/to/testString"); when(exampleStringField.getType()).thenReturn(exampleStringType);
.setMinorType(minorType) .setScale(scale) .setPrecision(width)
setState(198); ((CharTypeContext)_localctx).typeLen = typeLen(); ((CharTypeContext)_localctx).type = TypeProtos.MajorType.newBuilder().setMinorType(TypeProtos.MinorType.VARCHAR).setMode(DataMode.REQUIRED).setPrecision(((CharTypeContext)_localctx).typeLen.length.intValue()).build(); setState(202); ((CharTypeContext)_localctx).typeLen = typeLen(); ((CharTypeContext)_localctx).type = TypeProtos.MajorType.newBuilder().setMinorType(TypeProtos.MinorType.VARBINARY).setMode(DataMode.REQUIRED).setPrecision(((CharTypeContext)_localctx).typeLen.length.intValue()).build();
return; case 1: builder.setMinorType(org.apache.drill.common.types.TypeProtos.MinorType.valueOf(input.readEnum())); break; case 2:
PrimitiveTypeInfo primitiveTypeInfo = (PrimitiveTypeInfo) typeInfo; MinorType minorType = HiveUtilities.getMinorTypeFromHivePrimitiveTypeInfo(primitiveTypeInfo, options); MajorType.Builder typeBuilder = MajorType.newBuilder().setMinorType(minorType)
public Builder mergeFrom(org.apache.drill.common.types.TypeProtos.MajorType other) { if (other == org.apache.drill.common.types.TypeProtos.MajorType.getDefaultInstance()) return this; if (other.hasMinorType()) { setMinorType(other.getMinorType());
@Override public MajorType getMajorType() { if (outputType != null) { return outputType; } MajorType elseType = elseExpression.getMajorType(); MajorType ifType = ifCondition.expression.getMajorType(); if (elseType.getMinorType() == MinorType.UNION) { Set<MinorType> subtypes = Sets.newHashSet(); for (MinorType subtype : elseType.getSubTypeList()) { subtypes.add(subtype); } for (MinorType subtype : ifType.getSubTypeList()) { subtypes.add(subtype); } MajorType.Builder builder = MajorType.newBuilder().setMinorType(MinorType.UNION).setMode(DataMode.OPTIONAL); for (MinorType subtype : subtypes) { builder.addSubType(subtype); } return builder.build(); } MajorType.Builder builder = MajorType.newBuilder().setMinorType(ifType.getMinorType()); builder.setMode(elseType.getMode() == DataMode.OPTIONAL || ifType.getMode() == DataMode.OPTIONAL ? DataMode.OPTIONAL : elseType.getMode()); builder = Types.calculateTypePrecisionAndScale(ifType, elseType, builder); return builder.build(); }
@Test public void testXpath_Double() throws Exception { final String query = "select xpath_double ('<a><b>20</b><c>40</c></a>', 'a/b * a/c') as col \n" + "from hive.kv \n" + "limit 0"; final TypeProtos.MajorType majorType = TypeProtos.MajorType.newBuilder() .setMinorType(TypeProtos.MinorType.FLOAT8) .setMode(TypeProtos.DataMode.OPTIONAL) .build(); final List<Pair<SchemaPath, TypeProtos.MajorType>> expectedSchema = Lists.newArrayList(); expectedSchema.add(Pair.of(SchemaPath.getSimplePath("col"), majorType)); testBuilder() .sqlQuery(query) .schemaBaseLine(expectedSchema) .build() .run(); }
public static MajorType withScaleAndPrecision(final MinorType type, final DataMode mode, final int scale, final int precision) { return MajorType.newBuilder().setMinorType(type).setMode(mode).setScale(scale).setPrecision(precision).build(); }
public static MajorType withMode(final MinorType type, final DataMode mode) { return MajorType.newBuilder().setMode(mode).setMinorType(type).build(); }
public static MajorType optional(final MinorType type) { return MajorType.newBuilder().setMode(DataMode.OPTIONAL).setMinorType(type).build(); }
public static MajorType repeated(final MinorType type) { return MajorType.newBuilder().setMode(REPEATED).setMinorType(type).build(); }
@Override public MajorType getMajorType() { return MajorType.newBuilder().setMinorType(MinorType.DECIMAL9).setScale(scale).setPrecision(precision).setMode(DataMode.REQUIRED).build(); }
public static MajorType required(final MinorType type) { return MajorType.newBuilder().setMode(DataMode.REQUIRED).setMinorType(type).build(); }
@Override public TypeProtos.MajorType getVectorType(SchemaPath column, PlannerSettings plannerSettings) { HiveScan hiveScan = (HiveScan) scanRel.getGroupScan(); String partitionName = column.getAsNamePart().getName(); Map<String, String> partitionNameTypeMap = hiveScan.getHiveReadEntry().table.getPartitionNameTypeMap(); String hiveType = partitionNameTypeMap.get(partitionName); PrimitiveTypeInfo primitiveTypeInfo = (PrimitiveTypeInfo) TypeInfoUtils.getTypeInfoFromTypeString(hiveType); TypeProtos.MinorType partitionType = HiveUtilities.getMinorTypeFromHivePrimitiveTypeInfo(primitiveTypeInfo, plannerSettings.getOptions()); return TypeProtos.MajorType.newBuilder().setMode(TypeProtos.DataMode.OPTIONAL).setMinorType(partitionType).build(); }
/** * Builds major type using given minor type, data mode and precision. * * @param type minor type * @param mode data mode * @param precision precision value * @return major type */ public static MajorType withPrecision(final MinorType type, final DataMode mode, final int precision) { return MajorType.newBuilder().setMinorType(type).setMode(mode).setPrecision(precision).build(); }
@Override public MajorType getMajorType() { return MajorType.newBuilder().setMinorType(MinorType.DECIMAL18).setScale(scale).setPrecision(precision).setMode(DataMode.REQUIRED).build(); }
@Override public MajorType getMajorType() { return MajorType .newBuilder() .setMinorType(MinorType.VARDECIMAL) .setScale(scale) .setPrecision(precision) .setMode(DataMode.REQUIRED) .build(); }