use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.rel.type.RelDataType in project storm by apache.
the class RelNodeCompiler method visitProject.
@Override
public Void visitProject(Project project, List<Void> inputStreams) throws Exception {
beginStage(project);
List<RexNode> childExps = project.getChildExps();
RelDataType inputRowType = project.getInput(0).getRowType();
int outputCount = project.getRowType().getFieldCount();
pw.print("Context context = new StormContext(Processor.dataContext);\n");
pw.print("context.values = _data.toArray();\n");
pw.print(String.format("Object[] outputValues = new Object[%d];\n", outputCount));
pw.write(rexCompiler.compileToBlock(childExps, inputRowType).toString());
pw.print(" ctx.emit(new Values(outputValues));\n");
endStage();
return null;
}
use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.rel.type.RelDataType in project flink by apache.
the class FlinkRelDecorrelator method getNewForOldInputRef.
private RexInputRef getNewForOldInputRef(RexInputRef oldInputRef) {
assert currentRel != null;
int oldOrdinal = oldInputRef.getIndex();
int newOrdinal = 0;
// determine which input rel oldOrdinal references, and adjust
// oldOrdinal to be relative to that input rel
RelNode oldInput = null;
for (RelNode oldInput0 : currentRel.getInputs()) {
RelDataType oldInputType = oldInput0.getRowType();
int n = oldInputType.getFieldCount();
if (oldOrdinal < n) {
oldInput = oldInput0;
break;
}
RelNode newInput = map.get(oldInput0).r;
newOrdinal += newInput.getRowType().getFieldCount();
oldOrdinal -= n;
}
assert oldInput != null;
final Frame frame = map.get(oldInput);
assert frame != null;
// now oldOrdinal is relative to oldInput
int oldLocalOrdinal = oldOrdinal;
// figure out the newLocalOrdinal, relative to the newInput.
int newLocalOrdinal = oldLocalOrdinal;
if (!frame.oldToNewOutputPos.isEmpty()) {
newLocalOrdinal = frame.oldToNewOutputPos.get(oldLocalOrdinal);
}
newOrdinal += newLocalOrdinal;
return new RexInputRef(newOrdinal, frame.r.getRowType().getFieldList().get(newLocalOrdinal).getType());
}
use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.rel.type.RelDataType in project druid by druid-io.
the class RowSignature method getRelDataType.
/**
* Returns a Calcite RelDataType corresponding to this row signature.
*
* @param typeFactory factory for type construction
*
* @return Calcite row type
*/
public RelDataType getRelDataType(final RelDataTypeFactory typeFactory) {
final RelDataTypeFactory.FieldInfoBuilder builder = typeFactory.builder();
for (final String columnName : columnNames) {
final ValueType columnType = getColumnType(columnName);
final RelDataType type;
if (Column.TIME_COLUMN_NAME.equals(columnName)) {
type = typeFactory.createSqlType(SqlTypeName.TIMESTAMP);
} else {
switch(columnType) {
case STRING:
// Note that there is no attempt here to handle multi-value in any special way. Maybe one day...
type = typeFactory.createTypeWithCharsetAndCollation(typeFactory.createSqlType(SqlTypeName.VARCHAR), Calcites.defaultCharset(), SqlCollation.IMPLICIT);
break;
case LONG:
type = typeFactory.createSqlType(SqlTypeName.BIGINT);
break;
case FLOAT:
type = typeFactory.createSqlType(SqlTypeName.FLOAT);
break;
case COMPLEX:
// Loses information about exactly what kind of complex column this is.
type = typeFactory.createSqlType(SqlTypeName.OTHER);
break;
default:
throw new ISE("WTF?! valueType[%s] not translatable?", columnType);
}
}
builder.add(columnName, type);
}
return builder.build();
}
use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.rel.type.RelDataType in project druid by druid-io.
the class DruidQueryBuilder method fullScan.
public static DruidQueryBuilder fullScan(final RowSignature rowSignature, final RelDataTypeFactory relDataTypeFactory) {
final RelDataType rowType = rowSignature.getRelDataType(relDataTypeFactory);
final List<String> rowOrder = rowSignature.getRowOrder();
return new DruidQueryBuilder(null, null, null, null, null, rowType, rowOrder);
}
use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.rel.type.RelDataType in project drill by apache.
the class AvroDrillTable method getRowType.
@Override
public RelDataType getRowType(RelDataTypeFactory typeFactory) {
List<RelDataType> typeList = Lists.newArrayList();
List<String> fieldNameList = Lists.newArrayList();
Schema schema = reader.getSchema();
for (Field field : schema.getFields()) {
fieldNameList.add(field.name());
typeList.add(getNullableRelDataTypeFromAvroType(typeFactory, field.schema()));
}
return typeFactory.createStructType(typeList, fieldNameList);
}
Aggregations