Search in sources :

Example 1 with MinorType

use of org.apache.drill.common.types.TypeProtos.MinorType in project drill by apache.

the class ColumnDef method makeDefaultGenerator.

private void makeDefaultGenerator() {
    MinorType minorType = mockCol.getMinorType();
    switch(minorType) {
        case BIGINT:
            break;
        case BIT:
            generator = new BooleanGen();
            break;
        case DATE:
            break;
        case DECIMAL18:
            break;
        case DECIMAL28DENSE:
            break;
        case DECIMAL28SPARSE:
            break;
        case DECIMAL38DENSE:
            break;
        case DECIMAL38SPARSE:
            break;
        case DECIMAL9:
            break;
        case FIXED16CHAR:
            break;
        case FIXEDBINARY:
            break;
        case FIXEDCHAR:
            break;
        case FLOAT4:
            break;
        case FLOAT8:
            generator = new DoubleGen();
            break;
        case GENERIC_OBJECT:
            break;
        case INT:
            generator = new IntGen();
            break;
        case INTERVAL:
            break;
        case INTERVALDAY:
            break;
        case INTERVALYEAR:
            break;
        case LATE:
            break;
        case LIST:
            break;
        case MAP:
            break;
        case MONEY:
            break;
        case NULL:
            break;
        case SMALLINT:
            break;
        case TIME:
            break;
        case TIMESTAMP:
            break;
        case TIMESTAMPTZ:
            break;
        case TIMETZ:
            break;
        case TINYINT:
            break;
        case UINT1:
            break;
        case UINT2:
            break;
        case UINT4:
            break;
        case UINT8:
            break;
        case UNION:
            break;
        case VAR16CHAR:
            break;
        case VARBINARY:
            break;
        case VARCHAR:
            generator = new StringGen();
            break;
        default:
            break;
    }
    if (generator == null) {
        throw new IllegalArgumentException("No default column generator for column " + name + " of type " + minorType);
    }
    generator.setup(this);
}
Also used : MinorType(org.apache.drill.common.types.TypeProtos.MinorType)

Example 2 with MinorType

use of org.apache.drill.common.types.TypeProtos.MinorType in project drill by apache.

the class AbstractSingleRowSet method buildReader.

/**
   * Internal method to build the set of column readers needed for
   * this row set. Used when building a row set reader.
   * @param rowIndex object that points to the current row
   * @return an array of column readers: in the same order as the
   * (non-map) vectors.
   */
protected RowSetReader buildReader(RowSetIndex rowIndex) {
    FlattenedSchema accessSchema = schema().flatAccess();
    ValueVector[] valueVectors = vectors();
    AbstractColumnReader[] readers = new AbstractColumnReader[valueVectors.length];
    for (int i = 0; i < readers.length; i++) {
        MinorType type = accessSchema.column(i).getType().getMinorType();
        if (type == MinorType.MAP) {
            // buildMapAccessor(i);
            readers[i] = null;
        } else if (type == MinorType.LIST) {
            // buildListAccessor(i);
            readers[i] = null;
        } else {
            readers[i] = ColumnAccessorFactory.newReader(valueVectors[i].getField().getType());
            readers[i].bind(rowIndex, valueVectors[i]);
        }
    }
    return new RowSetReaderImpl(accessSchema, rowIndex, readers);
}
Also used : ValueVector(org.apache.drill.exec.vector.ValueVector) FlattenedSchema(org.apache.drill.test.rowSet.RowSetSchema.FlattenedSchema) MinorType(org.apache.drill.common.types.TypeProtos.MinorType) AbstractColumnReader(org.apache.drill.exec.vector.accessor.impl.AbstractColumnReader)

Example 3 with MinorType

use of org.apache.drill.common.types.TypeProtos.MinorType in project drill by apache.

the class ParquetToDrillTypeConverter method toMajorType.

public static TypeProtos.MajorType toMajorType(PrimitiveType.PrimitiveTypeName primitiveTypeName, int length, TypeProtos.DataMode mode, ConvertedType convertedType, int precision, int scale, OptionManager options) {
    MinorType minorType = getMinorType(primitiveTypeName, length, convertedType, precision, scale, options);
    TypeProtos.MajorType.Builder typeBuilder = TypeProtos.MajorType.newBuilder().setMinorType(minorType).setMode(mode);
    if (CoreDecimalUtility.isDecimalType(minorType)) {
        typeBuilder.setPrecision(precision).setScale(scale);
    }
    return typeBuilder.build();
}
Also used : MinorType(org.apache.drill.common.types.TypeProtos.MinorType)

Example 4 with MinorType

use of org.apache.drill.common.types.TypeProtos.MinorType in project drill by axbaretto.

the class OpenTSDBRecordReader method initCols.

private void initCols(Schema schema) throws SchemaChangeException {
    ImmutableList.Builder<ProjectedColumnInfo> pciBuilder = ImmutableList.builder();
    for (int i = 0; i < schema.getColumnCount(); i++) {
        ColumnDTO column = schema.getColumnByIndex(i);
        final String name = column.getColumnName();
        final OpenTSDBTypes type = column.getColumnType();
        TypeProtos.MinorType minorType = TYPES.get(type);
        if (isMinorTypeNull(minorType)) {
            String message = String.format("A column you queried has a data type that is not currently supported by the OpenTSDB storage plugin. " + "The column's name was %s and its OpenTSDB data type was %s. ", name, type.toString());
            throw UserException.unsupportedError().message(message).build(log);
        }
        ProjectedColumnInfo pci = getProjectedColumnInfo(column, name, minorType);
        pciBuilder.add(pci);
    }
    projectedCols = pciBuilder.build();
}
Also used : OpenTSDBTypes(org.apache.drill.exec.store.openTSDB.client.OpenTSDBTypes) ImmutableList(com.google.common.collect.ImmutableList) MinorType(org.apache.drill.common.types.TypeProtos.MinorType) TypeProtos(org.apache.drill.common.types.TypeProtos) ColumnDTO(org.apache.drill.exec.store.openTSDB.dto.ColumnDTO)

Example 5 with MinorType

use of org.apache.drill.common.types.TypeProtos.MinorType in project drill by axbaretto.

the class KuduRecordReader method initCols.

private void initCols(Schema schema) throws SchemaChangeException {
    ImmutableList.Builder<ProjectedColumnInfo> pciBuilder = ImmutableList.builder();
    for (int i = 0; i < schema.getColumnCount(); i++) {
        ColumnSchema col = schema.getColumnByIndex(i);
        final String name = col.getName();
        final Type kuduType = col.getType();
        MinorType minorType = TYPES.get(kuduType);
        if (minorType == null) {
            logger.warn("Ignoring column that is unsupported.", UserException.unsupportedError().message("A column you queried has a data type that is not currently supported by the Kudu storage plugin. " + "The column's name was %s and its Kudu data type was %s. ", name, kuduType.toString()).addContext("column Name", name).addContext("plugin", "kudu").build(logger));
            continue;
        }
        MajorType majorType;
        if (col.isNullable()) {
            majorType = Types.optional(minorType);
        } else {
            majorType = Types.required(minorType);
        }
        MaterializedField field = MaterializedField.create(name, majorType);
        final Class<? extends ValueVector> clazz = TypeHelper.getValueVectorClass(minorType, majorType.getMode());
        ValueVector vector = output.addField(field, clazz);
        vector.allocateNew();
        ProjectedColumnInfo pci = new ProjectedColumnInfo();
        pci.vv = vector;
        pci.kuduColumn = col;
        pci.index = i;
        pciBuilder.add(pci);
    }
    projectedCols = pciBuilder.build();
}
Also used : ValueVector(org.apache.drill.exec.vector.ValueVector) Type(org.apache.kudu.Type) MajorType(org.apache.drill.common.types.TypeProtos.MajorType) MinorType(org.apache.drill.common.types.TypeProtos.MinorType) ImmutableList(com.google.common.collect.ImmutableList) MajorType(org.apache.drill.common.types.TypeProtos.MajorType) MinorType(org.apache.drill.common.types.TypeProtos.MinorType) ColumnSchema(org.apache.kudu.ColumnSchema) MaterializedField(org.apache.drill.exec.record.MaterializedField)

Aggregations

MinorType (org.apache.drill.common.types.TypeProtos.MinorType)86 MajorType (org.apache.drill.common.types.TypeProtos.MajorType)32 MaterializedField (org.apache.drill.exec.record.MaterializedField)17 ValueVector (org.apache.drill.exec.vector.ValueVector)11 DataMode (org.apache.drill.common.types.TypeProtos.DataMode)10 SchemaBuilder (org.apache.drill.exec.record.metadata.SchemaBuilder)8 TupleMetadata (org.apache.drill.exec.record.metadata.TupleMetadata)7 SubOperatorTest (org.apache.drill.test.SubOperatorTest)6 Test (org.junit.Test)6 ImmutableList (com.google.common.collect.ImmutableList)5 SchemaPath (org.apache.drill.common.expression.SchemaPath)5 ValueHolder (org.apache.drill.exec.expr.holders.ValueHolder)5 IOException (java.io.IOException)4 UserException (org.apache.drill.common.exceptions.UserException)4 OriginalType (org.apache.parquet.schema.OriginalType)4 PrimitiveType (org.apache.parquet.schema.PrimitiveType)4 SQLException (java.sql.SQLException)3 DrillRuntimeException (org.apache.drill.common.exceptions.DrillRuntimeException)3 SchemaChangeException (org.apache.drill.exec.exception.SchemaChangeException)3 ExtendableRowSet (org.apache.drill.exec.physical.rowSet.RowSet.ExtendableRowSet)3