Search in sources :

Example 46 with RowSignature

use of org.apache.druid.segment.column.RowSignature in project druid by druid-io.

the class RowSignatures method fromRelDataType.

public static RowSignature fromRelDataType(final List<String> rowOrder, final RelDataType rowType) {
    if (rowOrder.size() != rowType.getFieldCount()) {
        throw new IAE("Field count %d != %d", rowOrder.size(), rowType.getFieldCount());
    }
    final RowSignature.Builder rowSignatureBuilder = RowSignature.builder();
    for (int i = 0; i < rowOrder.size(); i++) {
        final RelDataType dataType = rowType.getFieldList().get(i).getType();
        final ColumnType valueType = Calcites.getColumnTypeForRelDataType(dataType);
        rowSignatureBuilder.add(rowOrder.get(i), valueType);
    }
    return rowSignatureBuilder.build();
}
Also used : ColumnType(org.apache.druid.segment.column.ColumnType) RelDataType(org.apache.calcite.rel.type.RelDataType) IAE(org.apache.druid.java.util.common.IAE) RowSignature(org.apache.druid.segment.column.RowSignature)

Aggregations

RowSignature (org.apache.druid.segment.column.RowSignature)46 ColumnType (org.apache.druid.segment.column.ColumnType)17 List (java.util.List)14 Test (org.junit.Test)13 Collectors (java.util.stream.Collectors)12 Nullable (javax.annotation.Nullable)11 PlannerContext (org.apache.druid.sql.calcite.planner.PlannerContext)11 DruidExpression (org.apache.druid.sql.calcite.expression.DruidExpression)10 Expressions (org.apache.druid.sql.calcite.expression.Expressions)10 Project (org.apache.calcite.rel.core.Project)9 RexLiteral (org.apache.calcite.rex.RexLiteral)9 RexNode (org.apache.calcite.rex.RexNode)9 SqlKind (org.apache.calcite.sql.SqlKind)9 ISE (org.apache.druid.java.util.common.ISE)9 Aggregation (org.apache.druid.sql.calcite.aggregation.Aggregation)9 ArrayList (java.util.ArrayList)8 StringUtils (org.apache.druid.java.util.common.StringUtils)8 AggregatorFactory (org.apache.druid.query.aggregation.AggregatorFactory)8 ImmutableList (com.google.common.collect.ImmutableList)6 ImmutableSet (com.google.common.collect.ImmutableSet)6