@Override public MajorType getType() { return Types.optional(MinorType.UNION); }
public static MajorType getMajorTypeFromName(final String typeName, final DataMode mode) { return withMode(getMinorTypeFromName(typeName), mode); }
private static int toSQLType(MinorType minorType) { String sqlTypeName = Types.getSqlTypeName(Types.optional(minorType)); return Types.getJdbcTypeCode(sqlTypeName); } }
public static MajorType overrideMinorType(final MajorType originalMajorType, final MinorType overrideMinorType) { switch (originalMajorType.getMode()) { case REPEATED: return repeated(overrideMinorType); case OPTIONAL: return optional(overrideMinorType); case REQUIRED: return required(overrideMinorType); default: throw new UnsupportedOperationException(); } }
@Test public void simpleSelectLimit0() throws Exception { @SuppressWarnings("unchecked") final List<Pair<SchemaPath, MajorType>> expectedSchema = Lists.newArrayList( Pair.of(SchemaPath.getSimplePath("employee_id"), Types.optional(MinorType.INT)), Pair.of(SchemaPath.getSimplePath("full_name"), Types.optional(MinorType.VARCHAR)), Pair.of(SchemaPath.getSimplePath("position_id"), Types.optional(MinorType.INT)), Pair.of(SchemaPath.getSimplePath("department_id"), Types.optional(MinorType.BIGINT)), Pair.of(SchemaPath.getSimplePath("birth_date"), Types.optional(MinorType.DATE)), Pair.of(SchemaPath.getSimplePath("hire_date"), Types.optional(MinorType.TIMESTAMP)), Pair.of(SchemaPath.getSimplePath("salary"), Types.optional(MinorType.FLOAT8)), Pair.of(SchemaPath.getSimplePath("fsalary"), Types.optional(MinorType.FLOAT4)), Pair.of(SchemaPath.getSimplePath("single"), Types.required(MinorType.BIT)), Pair.of(SchemaPath.getSimplePath("education_level"), Types.optional(MinorType.VARCHAR)), Pair.of(SchemaPath.getSimplePath("gender"), Types.optional(MinorType.VARCHAR))); testBuilder() .sqlQuery(wrapLimit0(String.format("SELECT * FROM %s", viewName))) .schemaBaseLine(expectedSchema) .go(); checkThatQueryPlanIsOptimized("SELECT * FROM " + viewName); }
final MajorType type; if (completeType.getPrecision() != null && completeType.getScale() != null) { type = Types.withScaleAndPrecision(completeType.toMinorType(), DataMode.OPTIONAL, completeType.getScale(), completeType.getPrecision()); } else { type = Types.optional(completeType.toMinorType());
+ rpcDataType.getMode() + "'" ); final boolean isSigned = Types.isJdbcSignedType( rpcDataType ); final int precision = Types.getPrecision(rpcDataType); final int scale = Types.getScale(rpcDataType); final int displaySize = Types.getJdbcDisplaySize(rpcDataType);
for(VectorWrapper<?> vv : batch) { String copyMethod; if (!Types.isFixedWidthType(getMajorTypeForField(vv.getField())) || Types.isRepeated(getMajorTypeForField(vv.getField())) || Types.isComplex(getMajorTypeForField(vv.getField()))) { copyMethod = "copyFromSafe"; } else {
public static boolean isFixedWidthType(final MajorType type) { return isFixedWidthType(type.getMinorType()); }
/** * @param encodingType * @param convertFunction * @param input * @param pos */ public ConvertExpression(String convertFunction, String encodingType, LogicalExpression input) { this.input = input; this.convertFunction = CONVERT_FROM.equals(convertFunction.toLowerCase()) ? CONVERT_FROM : CONVERT_TO; this.encodingType = encodingType.toUpperCase(); this.type = CompleteType.fromMinorType(Types.getMinorTypeFromName(encodingType.split("_", 2)[0].toLowerCase())); }
public static MajorType overrideMode(final MajorType originalMajorType, final DataMode overrideMode) { return withScaleAndPrecision(originalMajorType.getMinorType(), overrideMode, originalMajorType.getScale(), originalMajorType.getPrecision()); }
final int precision = getPrecision(type);
@Test public void testAvgCountStar() throws Exception { final String query = "select avg(distinct cast(r_regionkey as bigint)) + avg(cast(r_regionkey as integer)) as col1, \n" + "sum(distinct cast(r_regionkey as bigint)) + 100 as col2, count(*) as col3 \n" + "from cp.\"tpch/region.parquet\" alltypes_v \n" + "where cast(r_regionkey as bigint) = 100000000000000000 \n" + "limit 0"; final List<Pair<SchemaPath, MajorType>> expectedSchema = Lists.newArrayList(); final MajorType majorType1 = Types.optional(MinorType.FLOAT8); final MajorType majorType2 = Types.optional(MinorType.BIGINT); final MajorType majorType3 = Types.required(MinorType.BIGINT); expectedSchema.add(Pair.of(SchemaPath.getSimplePath("col1"), majorType1)); expectedSchema.add(Pair.of(SchemaPath.getSimplePath("col2"), majorType2)); expectedSchema.add(Pair.of(SchemaPath.getSimplePath("col3"), majorType3)); testBuilder() .sqlQuery(query) .schemaBaseLine(expectedSchema) .build() .run(); }
if (!Types.isFixedWidthType(type)) {
types.add(Types.getMinorTypeFromName(type1.getSqlTypeName().getName())); types.add(Types.getMinorTypeFromName(type2.getSqlTypeName().getName())); if(TypeCastRules.getLeastRestrictiveType(types) != null) { return true;
public MajorType getTypeForColumn(SchemaPath column) { if (IncrementalUpdateUtils.UPDATE_COLUMN.equals(column.getAsUnescapedPath())) { return Types.optional(MinorType.BIGINT); } return null; }
@Test public void testAvgAndSUM() throws Exception { final String query = "SELECT AVG(cast(r_regionkey as float)) AS \"col1\", \n" + "SUM(cast(r_regionkey as float)) AS \"col2\", \n" + "SUM(1) AS \"col3\" \n" + "FROM cp.\"tpch/region.parquet\" \n" + "GROUP BY CAST(r_regionkey AS INTEGER) \n" + "LIMIT 0"; final List<Pair<SchemaPath, MajorType>> expectedSchema = Lists.newArrayList(); final MajorType majorType1 = Types.optional(MinorType.FLOAT8); final MajorType majorType2 = Types.optional(MinorType.FLOAT8); final MajorType majorType3 = Types.required(MinorType.BIGINT); expectedSchema.add(Pair.of(SchemaPath.getSimplePath("col1"), majorType1)); expectedSchema.add(Pair.of(SchemaPath.getSimplePath("col2"), majorType2)); expectedSchema.add(Pair.of(SchemaPath.getSimplePath("col3"), majorType3)); testBuilder() .sqlQuery(query) .schemaBaseLine(expectedSchema) .build() .run(); }
public CSVTestBuilder baselineTypes(MinorType... baselineTypes) { MajorType[] majorTypes = new MajorType[baselineTypes.length]; int i = 0; for(MinorType minorType : baselineTypes) { majorTypes[i] = Types.required(minorType); i++; } this.baselineTypes = majorTypes; this.baselineTypeMap = null; return this; }
if (!Types.isFixedWidthType(type)) {