use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.rex.RexBuilder in project calcite by apache.
the class RelOptUtil method createNullFilter.
// to be removed before 2.0
@Deprecated
public static RelNode createNullFilter(RelNode rel, Integer[] fieldOrdinals) {
RexNode condition = null;
final RexBuilder rexBuilder = rel.getCluster().getRexBuilder();
RelDataType rowType = rel.getRowType();
int n;
if (fieldOrdinals != null) {
n = fieldOrdinals.length;
} else {
n = rowType.getFieldCount();
}
List<RelDataTypeField> fields = rowType.getFieldList();
for (int i = 0; i < n; ++i) {
int iField;
if (fieldOrdinals != null) {
iField = fieldOrdinals[i];
} else {
iField = i;
}
RelDataType type = fields.get(iField).getType();
if (!type.isNullable()) {
continue;
}
RexNode newCondition = rexBuilder.makeCall(SqlStdOperatorTable.IS_NOT_NULL, rexBuilder.makeInputRef(type, iField));
if (condition == null) {
condition = newCondition;
} else {
condition = rexBuilder.makeCall(SqlStdOperatorTable.AND, condition, newCondition);
}
}
if (condition == null) {
// no filtering required
return rel;
}
final RelFactories.FilterFactory factory = RelFactories.DEFAULT_FILTER_FACTORY;
return factory.createFilter(rel, condition);
}
use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.rex.RexBuilder in project calcite by apache.
the class CalcitePrepareImpl method perform.
/**
* Executes a prepare action.
*/
public <R> R perform(CalciteServerStatement statement, Frameworks.PrepareAction<R> action) {
final CalcitePrepare.Context prepareContext = statement.createPrepareContext();
final JavaTypeFactory typeFactory = prepareContext.getTypeFactory();
final CalciteSchema schema = action.getConfig().getDefaultSchema() != null ? CalciteSchema.from(action.getConfig().getDefaultSchema()) : prepareContext.getRootSchema();
CalciteCatalogReader catalogReader = new CalciteCatalogReader(schema.root(), schema.path(null), typeFactory, prepareContext.config());
final RexBuilder rexBuilder = new RexBuilder(typeFactory);
final RelOptPlanner planner = createPlanner(prepareContext, action.getConfig().getContext(), action.getConfig().getCostFactory());
final RelOptCluster cluster = createCluster(planner, rexBuilder);
return action.apply(cluster, catalogReader, prepareContext.getRootSchema().plus(), statement);
}
use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.rex.RexBuilder in project calcite by apache.
the class LixToRelTranslator method toRex.
RexNode toRex(FunctionExpression expression, RelNode... inputs) {
List<RexNode> list = new ArrayList<RexNode>();
RexBuilder rexBuilder = cluster.getRexBuilder();
for (RelNode input : inputs) {
list.add(rexBuilder.makeRangeReference(input));
}
return CalcitePrepareImpl.EmptyScalarTranslator.empty(rexBuilder).bind(expression.parameterList, list).toRex(expression.body);
}
use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.rex.RexBuilder in project calcite by apache.
the class LixToRelTranslator method toRexList.
List<RexNode> toRexList(FunctionExpression expression, RelNode... inputs) {
List<RexNode> list = new ArrayList<RexNode>();
RexBuilder rexBuilder = cluster.getRexBuilder();
for (RelNode input : inputs) {
list.add(rexBuilder.makeRangeReference(input));
}
return CalcitePrepareImpl.EmptyScalarTranslator.empty(rexBuilder).bind(expression.parameterList, list).toRexList(expression.body);
}
use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.rex.RexBuilder in project calcite by apache.
the class PlannerImpl method rel.
public RelRoot rel(SqlNode sql) throws RelConversionException {
ensure(State.STATE_4_VALIDATED);
assert validatedSqlNode != null;
final RexBuilder rexBuilder = createRexBuilder();
final RelOptCluster cluster = RelOptCluster.create(planner, rexBuilder);
final SqlToRelConverter.Config config = SqlToRelConverter.configBuilder().withConfig(sqlToRelConverterConfig).withTrimUnusedFields(false).withConvertTableAccess(false).build();
final SqlToRelConverter sqlToRelConverter = new SqlToRelConverter(new ViewExpanderImpl(), validator, createCatalogReader(), cluster, convertletTable, config);
root = sqlToRelConverter.convertQuery(validatedSqlNode, false, true);
root = root.withRel(sqlToRelConverter.flattenTypes(root.rel, true));
final RelBuilder relBuilder = config.getRelBuilderFactory().create(cluster, null);
root = root.withRel(RelDecorrelator.decorrelateQuery(root.rel, relBuilder));
state = State.STATE_5_CONVERTED;
return root;
}
Aggregations