Search in sources :

Example 6 with RelDataTypeFieldImpl

use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.rel.type.RelDataTypeFieldImpl in project samza by apache.

the class RelSchemaConverter method getRelFields.

private List<RelDataTypeField> getRelFields(List<SqlSchema.SqlField> fields) {
    List<RelDataTypeField> relFields = new ArrayList<>();
    for (SqlSchema.SqlField field : fields) {
        String fieldName = field.getFieldName();
        int fieldPos = field.getPosition();
        RelDataType dataType = getRelDataType(field.getFieldSchema());
        relFields.add(new RelDataTypeFieldImpl(fieldName, fieldPos, dataType));
    }
    return relFields;
}
Also used : RelDataTypeField(org.apache.calcite.rel.type.RelDataTypeField) SqlSchema(org.apache.samza.sql.schema.SqlSchema) ArrayList(java.util.ArrayList) RelDataType(org.apache.calcite.rel.type.RelDataType) RelDataTypeFieldImpl(org.apache.calcite.rel.type.RelDataTypeFieldImpl)

Example 7 with RelDataTypeFieldImpl

use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.rel.type.RelDataTypeFieldImpl in project flink by apache.

the class StructuredRelDataType method create.

public static StructuredRelDataType create(FlinkTypeFactory factory, StructuredType structuredType) {
    final List<RelDataTypeField> fields = new ArrayList<>();
    for (int i = 0; i < structuredType.getAttributes().size(); i++) {
        final StructuredAttribute attribute = structuredType.getAttributes().get(i);
        final RelDataTypeField field = new RelDataTypeFieldImpl(attribute.getName(), i, factory.createFieldTypeFromLogicalType(attribute.getType()));
        fields.add(field);
    }
    return new StructuredRelDataType(structuredType, fields);
}
Also used : RelDataTypeField(org.apache.calcite.rel.type.RelDataTypeField) ArrayList(java.util.ArrayList) StructuredAttribute(org.apache.flink.table.types.logical.StructuredType.StructuredAttribute) RelDataTypeFieldImpl(org.apache.calcite.rel.type.RelDataTypeFieldImpl)

Example 8 with RelDataTypeFieldImpl

use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.rel.type.RelDataTypeFieldImpl in project drill by apache.

the class ConvertCountToDirectScan method getCountDirectScanRowType.

private RelDataType getCountDirectScanRowType(RelDataTypeFactory typeFactory) {
    List<RelDataTypeField> fields = Lists.newArrayList();
    fields.add(new RelDataTypeFieldImpl("count", 0, typeFactory.createSqlType(SqlTypeName.BIGINT)));
    return new RelRecordType(fields);
}
Also used : RelDataTypeField(org.apache.calcite.rel.type.RelDataTypeField) RelDataTypeFieldImpl(org.apache.calcite.rel.type.RelDataTypeFieldImpl) RelRecordType(org.apache.calcite.rel.type.RelRecordType)

Example 9 with RelDataTypeFieldImpl

use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.rel.type.RelDataTypeFieldImpl in project drill by apache.

the class DrillFixedRelDataTypeImpl method addField.

private void addField(String columnName) {
    RelDataTypeField newField = new RelDataTypeFieldImpl(columnName, fields.size(), typeFactory.createTypeWithNullability(typeFactory.createSqlType(SqlTypeName.ANY), true));
    fields.add(newField);
}
Also used : RelDataTypeField(org.apache.calcite.rel.type.RelDataTypeField) RelDataTypeFieldImpl(org.apache.calcite.rel.type.RelDataTypeFieldImpl)

Example 10 with RelDataTypeFieldImpl

use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.rel.type.RelDataTypeFieldImpl in project drill by axbaretto.

the class ConvertCountToDirectScan method constructDataType.

/**
 * For each aggregate call creates field based on its name with bigint type.
 * Constructs record type for created fields.
 *
 * @param aggregateRel aggregate relation expression
 * @param fieldNames field names
 * @return record type
 */
private RelDataType constructDataType(DrillAggregateRel aggregateRel, Collection<String> fieldNames) {
    List<RelDataTypeField> fields = new ArrayList<>();
    Iterator<String> filedNamesIterator = fieldNames.iterator();
    int fieldIndex = 0;
    while (filedNamesIterator.hasNext()) {
        RelDataTypeField field = new RelDataTypeFieldImpl(filedNamesIterator.next(), fieldIndex++, aggregateRel.getCluster().getTypeFactory().createSqlType(SqlTypeName.BIGINT));
        fields.add(field);
    }
    return new RelRecordType(fields);
}
Also used : RelDataTypeField(org.apache.calcite.rel.type.RelDataTypeField) ArrayList(java.util.ArrayList) RelDataTypeFieldImpl(org.apache.calcite.rel.type.RelDataTypeFieldImpl) RelRecordType(org.apache.calcite.rel.type.RelRecordType)

Aggregations

RelDataTypeFieldImpl (org.apache.calcite.rel.type.RelDataTypeFieldImpl)27 RelDataTypeField (org.apache.calcite.rel.type.RelDataTypeField)26 ArrayList (java.util.ArrayList)15 RelRecordType (org.apache.calcite.rel.type.RelRecordType)15 RelDataType (org.apache.calcite.rel.type.RelDataType)9 RexNode (org.apache.calcite.rex.RexNode)8 RelNode (org.apache.calcite.rel.RelNode)6 Type (java.lang.reflect.Type)4 RexInputRef (org.apache.calcite.rex.RexInputRef)4 ImmutableList (com.google.common.collect.ImmutableList)3 JavaRecordType (org.apache.calcite.jdbc.JavaRecordType)3 Field (java.lang.reflect.Field)2 RelDataTypeFactory (org.apache.calcite.rel.type.RelDataTypeFactory)2 SqlTypeName (org.apache.calcite.sql.type.SqlTypeName)2 NlsString (org.apache.calcite.util.NlsString)2 LogicalExpression (org.apache.drill.common.expression.LogicalExpression)2 SchemaPath (org.apache.drill.common.expression.SchemaPath)2 NamedExpression (org.apache.drill.common.logical.data.NamedExpression)2 DbGroupScan (org.apache.drill.exec.physical.base.DbGroupScan)2 Prel (org.apache.drill.exec.planner.physical.Prel)2