Search in sources :

Example 1 with ColumnDTO

use of org.apache.drill.exec.store.openTSDB.dto.ColumnDTO 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 2 with ColumnDTO

use of org.apache.drill.exec.store.openTSDB.dto.ColumnDTO in project drill by axbaretto.

the class ServiceImpl method getUnfixedColumns.

@Override
public List<ColumnDTO> getUnfixedColumns(Map<String, String> queryParam) {
    Set<MetricDTO> metrics = getAllMetricsByTags(queryParam);
    List<ColumnDTO> unfixedColumns = new ArrayList<>();
    for (MetricDTO metric : metrics) {
        for (String tag : metric.getTags().keySet()) {
            ColumnDTO tmp = new ColumnDTO(tag, OpenTSDBTypes.STRING);
            if (!unfixedColumns.contains(tmp)) {
                unfixedColumns.add(tmp);
            }
        }
    }
    return unfixedColumns;
}
Also used : MetricDTO(org.apache.drill.exec.store.openTSDB.dto.MetricDTO) ArrayList(java.util.ArrayList) ColumnDTO(org.apache.drill.exec.store.openTSDB.dto.ColumnDTO)

Example 3 with ColumnDTO

use of org.apache.drill.exec.store.openTSDB.dto.ColumnDTO in project drill by apache.

the class Schema method setupStructure.

private void setupStructure() {
    columns.add(new ColumnDTO(METRIC.toString(), OpenTSDBTypes.STRING));
    columns.add(new ColumnDTO(AGGREGATE_TAGS.toString(), OpenTSDBTypes.STRING));
    columns.add(new ColumnDTO(TIMESTAMP.toString(), OpenTSDBTypes.TIMESTAMP));
    columns.add(new ColumnDTO(AGGREGATED_VALUE.toString(), OpenTSDBTypes.DOUBLE));
    columns.addAll(db.getUnfixedColumns(getParamsForQuery()));
}
Also used : ColumnDTO(org.apache.drill.exec.store.openTSDB.dto.ColumnDTO)

Example 4 with ColumnDTO

use of org.apache.drill.exec.store.openTSDB.dto.ColumnDTO in project drill by axbaretto.

the class DrillOpenTSDBTable method convertToRelDataType.

private void convertToRelDataType(RelDataTypeFactory typeFactory, List<String> names, List<RelDataType> types) {
    for (ColumnDTO column : schema.getColumns()) {
        names.add(column.getColumnName());
        RelDataType type = getSqlTypeFromOpenTSDBType(typeFactory, column.getColumnType());
        type = typeFactory.createTypeWithNullability(type, column.isNullable());
        types.add(type);
    }
}
Also used : RelDataType(org.apache.calcite.rel.type.RelDataType) ColumnDTO(org.apache.drill.exec.store.openTSDB.dto.ColumnDTO)

Example 5 with ColumnDTO

use of org.apache.drill.exec.store.openTSDB.dto.ColumnDTO in project drill by axbaretto.

the class Schema method setupStructure.

private void setupStructure() {
    columns.add(new ColumnDTO(METRIC.toString(), OpenTSDBTypes.STRING));
    columns.add(new ColumnDTO(AGGREGATE_TAGS.toString(), OpenTSDBTypes.STRING));
    columns.add(new ColumnDTO(TIMESTAMP.toString(), OpenTSDBTypes.TIMESTAMP));
    columns.add(new ColumnDTO(AGGREGATED_VALUE.toString(), OpenTSDBTypes.DOUBLE));
    columns.addAll(db.getUnfixedColumns(getParamsForQuery()));
}
Also used : ColumnDTO(org.apache.drill.exec.store.openTSDB.dto.ColumnDTO)

Aggregations

ColumnDTO (org.apache.drill.exec.store.openTSDB.dto.ColumnDTO)8 ArrayList (java.util.ArrayList)2 RelDataType (org.apache.calcite.rel.type.RelDataType)2 TypeProtos (org.apache.drill.common.types.TypeProtos)2 MinorType (org.apache.drill.common.types.TypeProtos.MinorType)2 OpenTSDBTypes (org.apache.drill.exec.store.openTSDB.client.OpenTSDBTypes)2 MetricDTO (org.apache.drill.exec.store.openTSDB.dto.MetricDTO)2 ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableList (org.apache.drill.shaded.guava.com.google.common.collect.ImmutableList)1