Search in sources :

Example 16 with DataType

use of com.linkedin.pinot.common.data.FieldSpec.DataType in project pinot by linkedin.

the class SegmentTestUtils method getColumnType.

public static DataType getColumnType(Field field) {
    org.apache.avro.Schema fieldSchema = field.schema();
    fieldSchema = extractSchemaFromUnionIfNeeded(fieldSchema);
    final Type type = fieldSchema.getType();
    if (type == Type.ARRAY) {
        org.apache.avro.Schema elementSchema = extractSchemaFromUnionIfNeeded(fieldSchema.getElementType());
        if (elementSchema.getType() == Type.RECORD) {
            if (elementSchema.getFields().size() == 1) {
                elementSchema = elementSchema.getFields().get(0).schema();
            } else {
                throw new RuntimeException("More than one schema in Multi-value column!");
            }
            elementSchema = extractSchemaFromUnionIfNeeded(elementSchema);
        }
        return DataType.valueOf(elementSchema.getType());
    } else {
        return DataType.valueOf(type);
    }
}
Also used : Type(org.apache.avro.Schema.Type) DataType(com.linkedin.pinot.common.data.FieldSpec.DataType) FieldType(com.linkedin.pinot.common.data.FieldSpec.FieldType)

Aggregations

DataType (com.linkedin.pinot.common.data.FieldSpec.DataType)16 FieldType (com.linkedin.pinot.common.data.FieldSpec.FieldType)6 FieldSpec (com.linkedin.pinot.common.data.FieldSpec)4 TimeUnit (java.util.concurrent.TimeUnit)4 DataSchema (com.linkedin.pinot.common.utils.DataSchema)3 File (java.io.File)3 Nonnull (javax.annotation.Nonnull)3 Type (org.apache.avro.Schema.Type)3 IntRange (org.apache.commons.lang.math.IntRange)3 DimensionFieldSpec (com.linkedin.pinot.common.data.DimensionFieldSpec)2 MetricFieldSpec (com.linkedin.pinot.common.data.MetricFieldSpec)2 Schema (com.linkedin.pinot.common.data.Schema)2 TimeFieldSpec (com.linkedin.pinot.common.data.TimeFieldSpec)2 DataGenerator (com.linkedin.pinot.tools.data.generator.DataGenerator)2 DataGeneratorSpec (com.linkedin.pinot.tools.data.generator.DataGeneratorSpec)2 Serializable (java.io.Serializable)2 HashMap (java.util.HashMap)2 Schema (org.apache.avro.Schema)2 Test (org.testng.annotations.Test)2 DerivedMetricType (com.linkedin.pinot.common.data.MetricFieldSpec.DerivedMetricType)1