Search in sources :

Example 21 with TupleSchema

use of org.apache.drill.exec.record.metadata.TupleSchema in project drill by apache.

the class AvroMessageReader method init.

@Override
public void init(SchemaNegotiator negotiator, ReadOptions readOptions, KafkaStoragePlugin plugin) {
    Properties kafkaConsumerProps = plugin.getConfig().getKafkaConsumerProps();
    Map<String, Object> propertiesMap = kafkaConsumerProps.entrySet().stream().collect(Collectors.toMap(e -> e.getKey().toString(), Map.Entry::getValue));
    deserializer = new KafkaAvroDeserializer(null, propertiesMap);
    TupleMetadata providedSchema = negotiator.providedSchema();
    loader = negotiator.build();
    AvroColumnConverterFactory factory = new AvroColumnConverterFactory(providedSchema);
    converter = factory.getRootConverter(providedSchema, new TupleSchema(), loader.writer());
    String keyDeserializer = kafkaConsumerProps.getProperty(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG);
    deserializeKey = keyDeserializer != null && keyDeserializer.equals(KafkaAvroDeserializer.class.getName());
}
Also used : ColumnConverter(org.apache.drill.exec.record.ColumnConverter) SchemaNegotiator(org.apache.drill.exec.physical.impl.scan.framework.SchemaNegotiator) MetadataUtils(org.apache.drill.exec.record.metadata.MetadataUtils) UserException(org.apache.drill.common.exceptions.UserException) LoggerFactory(org.slf4j.LoggerFactory) RowSetLoader(org.apache.drill.exec.physical.resultSet.RowSetLoader) ReadOptions(org.apache.drill.exec.store.kafka.ReadOptions) Map(java.util.Map) ColumnMetadata(org.apache.drill.exec.record.metadata.ColumnMetadata) TupleSchema(org.apache.drill.exec.record.metadata.TupleSchema) ByteArrayDeserializer(org.apache.kafka.common.serialization.ByteArrayDeserializer) GenericRecord(org.apache.avro.generic.GenericRecord) AvroColumnConverterFactory(org.apache.drill.exec.store.avro.AvroColumnConverterFactory) Schema(org.apache.avro.Schema) Logger(org.slf4j.Logger) Properties(java.util.Properties) ResultSetLoader(org.apache.drill.exec.physical.resultSet.ResultSetLoader) ConsumerConfig(org.apache.kafka.clients.consumer.ConsumerConfig) IOException(java.io.IOException) TupleMetadata(org.apache.drill.exec.record.metadata.TupleMetadata) Collectors(java.util.stream.Collectors) KafkaAvroDeserializer(io.confluent.kafka.serializers.KafkaAvroDeserializer) KafkaStoragePlugin(org.apache.drill.exec.store.kafka.KafkaStoragePlugin) TypeProtos(org.apache.drill.common.types.TypeProtos) MetaDataField(org.apache.drill.exec.store.kafka.MetaDataField) ConsumerRecord(org.apache.kafka.clients.consumer.ConsumerRecord) KafkaConsumer(org.apache.kafka.clients.consumer.KafkaConsumer) AvroColumnConverterFactory(org.apache.drill.exec.store.avro.AvroColumnConverterFactory) TupleMetadata(org.apache.drill.exec.record.metadata.TupleMetadata) KafkaAvroDeserializer(io.confluent.kafka.serializers.KafkaAvroDeserializer) Properties(java.util.Properties) Map(java.util.Map) TupleSchema(org.apache.drill.exec.record.metadata.TupleSchema)

Example 22 with TupleSchema

use of org.apache.drill.exec.record.metadata.TupleSchema in project drill by apache.

the class AbstractSchemaTracker method implicitColumns.

private TupleMetadata implicitColumns() {
    TupleMetadata implicitCols = new TupleSchema();
    for (ColumnHandle handle : schema.columns()) {
        if (handle.isImplicit()) {
            handle.setIndex(implicitCols.size());
            implicitCols.addColumn(handle.column());
        }
    }
    return implicitCols;
}
Also used : ColumnHandle(org.apache.drill.exec.physical.impl.scan.v3.schema.MutableTupleSchema.ColumnHandle) TupleMetadata(org.apache.drill.exec.record.metadata.TupleMetadata) TupleSchema(org.apache.drill.exec.record.metadata.TupleSchema)

Example 23 with TupleSchema

use of org.apache.drill.exec.record.metadata.TupleSchema in project drill by apache.

the class SchemaUtils method projectAll.

public static ScanProjectionParser.ProjectionParseResult projectAll() {
    TupleMetadata projSet = new TupleSchema();
    projSet.setProperty(ScanProjectionParser.PROJECTION_TYPE_PROP, ScanProjectionParser.PROJECT_ALL);
    return new ScanProjectionParser.ProjectionParseResult(0, projSet);
}
Also used : TupleMetadata(org.apache.drill.exec.record.metadata.TupleMetadata) TupleSchema(org.apache.drill.exec.record.metadata.TupleSchema)

Example 24 with TupleSchema

use of org.apache.drill.exec.record.metadata.TupleSchema in project drill by apache.

the class SchemaUtils method projectNone.

public static ScanProjectionParser.ProjectionParseResult projectNone() {
    TupleMetadata projSet = new TupleSchema();
    projSet.setProperty(ScanProjectionParser.PROJECTION_TYPE_PROP, ScanProjectionParser.PROJECT_NONE);
    return new ScanProjectionParser.ProjectionParseResult(-1, projSet);
}
Also used : TupleMetadata(org.apache.drill.exec.record.metadata.TupleMetadata) TupleSchema(org.apache.drill.exec.record.metadata.TupleSchema)

Example 25 with TupleSchema

use of org.apache.drill.exec.record.metadata.TupleSchema in project drill by apache.

the class EnumerableRecordReader method open.

@Override
public boolean open(SchemaNegotiator negotiator) {
    TupleMetadata providedSchema = negotiator.providedSchema();
    loader = negotiator.build();
    setup(negotiator.context());
    ColumnConverterFactory factory = new ColumnConverterFactory(providedSchema);
    converter = factory.getRootConverter(providedSchema, new TupleSchema(), loader.writer());
    return true;
}
Also used : ColumnConverterFactory(org.apache.drill.exec.record.ColumnConverterFactory) TupleMetadata(org.apache.drill.exec.record.metadata.TupleMetadata) TupleSchema(org.apache.drill.exec.record.metadata.TupleSchema)

Aggregations

TupleSchema (org.apache.drill.exec.record.metadata.TupleSchema)30 TupleMetadata (org.apache.drill.exec.record.metadata.TupleMetadata)25 ColumnMetadata (org.apache.drill.exec.record.metadata.ColumnMetadata)12 Test (org.junit.Test)10 MapColumnMetadata (org.apache.drill.exec.record.metadata.MapColumnMetadata)6 PrimitiveColumnMetadata (org.apache.drill.exec.record.metadata.PrimitiveColumnMetadata)6 VariantColumnMetadata (org.apache.drill.exec.record.metadata.VariantColumnMetadata)6 SubOperatorTest (org.apache.drill.test.SubOperatorTest)5 SchemaPath (org.apache.drill.common.expression.SchemaPath)4 IOException (java.io.IOException)3 ArrayList (java.util.ArrayList)3 Map (java.util.Map)3 UserException (org.apache.drill.common.exceptions.UserException)3 MajorType (org.apache.drill.common.types.TypeProtos.MajorType)3 MaterializedField (org.apache.drill.exec.record.MaterializedField)3 BaseTest (org.apache.drill.test.BaseTest)3 Collectors (java.util.stream.Collectors)2 MinorType (org.apache.drill.common.types.TypeProtos.MinorType)2 CompoundProjectionFilter (org.apache.drill.exec.physical.resultSet.impl.ProjectionFilter.CompoundProjectionFilter)2 DirectProjectionFilter (org.apache.drill.exec.physical.resultSet.impl.ProjectionFilter.DirectProjectionFilter)2