Java Code Examples for org.apache.calcite.rel.core.RelFactories#ProjectFactory

The following examples show how to use org.apache.calcite.rel.core.RelFactories#ProjectFactory . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MoreRelOptUtil.java    From dremio-oss with Apache License 2.0 6 votes vote down vote up
/**
 * Creates a projection which casts a rel's output to a desired row type.
 * Differs from RelOptUtil implementation by casting even when type is ANY.
 *
 * @param rel         producer of rows to be converted
 * @param castRowType row type after cast
 * @param projectFactory Project Factory
 *
 * @return conversion rel
 */
public static RelNode createCastRel(
  final RelNode rel,
  RelDataType castRowType,
  RelFactories.ProjectFactory projectFactory) {
  assert projectFactory != null;
  RelDataType rowType = rel.getRowType();
  if (areRowTypesEqual(rowType, castRowType, false, true)) {
    // nothing to do
    return rel;
  }
  final RexBuilder rexBuilder = rel.getCluster().getRexBuilder();
  final List<RexNode> castExps =
    RexUtil.generateCastExpressions(rexBuilder, castRowType, rowType);

  return projectFactory.createProject(rel, castExps, rowType.getFieldNames());
}
 
Example 2
Source File: RelOptUtil.java    From Bats with Apache License 2.0 6 votes vote down vote up
/**
 * Creates a projection which casts a rel's output to a desired row type.
 *
 * @param rel         producer of rows to be converted
 * @param castRowType row type after cast
 * @param rename      if true, use field names from castRowType; if false,
 *                    preserve field names from rel
 * @param projectFactory Project Factory
 * @return conversion rel
 */
public static RelNode createCastRel(final RelNode rel, RelDataType castRowType, boolean rename,
        RelFactories.ProjectFactory projectFactory) {
    assert projectFactory != null;
    RelDataType rowType = rel.getRowType();
    if (areRowTypesEqual(rowType, castRowType, rename)) {
        // nothing to do
        return rel;
    }
    final RexBuilder rexBuilder = rel.getCluster().getRexBuilder();
    final List<RexNode> castExps = RexUtil.generateCastExpressions(rexBuilder, castRowType, rowType);
    if (rename) {
        // Use names and types from castRowType.
        return projectFactory.createProject(rel, castExps, castRowType.getFieldNames());
    } else {
        // Use names from rowType, types from castRowType.
        return projectFactory.createProject(rel, castExps, rowType.getFieldNames());
    }
}
 
Example 3
Source File: FilterProjectTransposeRule.java    From Bats with Apache License 2.0 5 votes vote down vote up
@Deprecated // to be removed before 2.0
public FilterProjectTransposeRule(
    Class<? extends Filter> filterClass,
    RelFactories.FilterFactory filterFactory,
    Class<? extends Project> projectClass,
    RelFactories.ProjectFactory projectFactory) {
  this(filterClass, filter -> !RexUtil.containsCorrelation(filter.getCondition()),
      projectClass, project -> true,
      filterFactory == null,
      projectFactory == null,
      RelBuilder.proto(filterFactory, projectFactory));
}
 
Example 4
Source File: FilterProjectTransposeRule.java    From calcite with Apache License 2.0 5 votes vote down vote up
@Deprecated // to be removed before 2.0
public FilterProjectTransposeRule(
    Class<? extends Filter> filterClass,
    RelFactories.FilterFactory filterFactory,
    Class<? extends Project> projectClass,
    RelFactories.ProjectFactory projectFactory) {
  this(filterClass, filter -> !RexUtil.containsCorrelation(filter.getCondition()),
      projectClass, project -> true,
      filterFactory == null,
      projectFactory == null,
      RelBuilder.proto(filterFactory, projectFactory));
}
 
Example 5
Source File: FlinkFilterJoinRule.java    From flink with Apache License 2.0 5 votes vote down vote up
@Deprecated // to be removed before 2.0
public FlinkFilterIntoJoinRule(boolean smart,
		RelFactories.FilterFactory filterFactory,
		RelFactories.ProjectFactory projectFactory,
		Predicate predicate) {
	this(smart, RelBuilder.proto(filterFactory, projectFactory), predicate);
}
 
Example 6
Source File: FlinkFilterJoinRule.java    From flink with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a FilterProjectTransposeRule with an explicit root operand and
 * factories.
 */
@Deprecated // to be removed before 2.0
protected FlinkFilterJoinRule(RelOptRuleOperand operand, String id,
		boolean smart, RelFactories.FilterFactory filterFactory,
		RelFactories.ProjectFactory projectFactory,
		Predicate predicate) {
	this(operand, id, smart, RelBuilder.proto(filterFactory, projectFactory),
			predicate);
}
 
Example 7
Source File: FlinkFilterJoinRule.java    From flink with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a FlinkFilterJoinRule with an explicit root operand and
 * factories.
 */
@Deprecated // to be removed before 2.0
protected FlinkFilterJoinRule(RelOptRuleOperand operand, String id,
		boolean smart, RelFactories.FilterFactory filterFactory,
		RelFactories.ProjectFactory projectFactory) {
	this(operand, id, smart, RelBuilder.proto(filterFactory, projectFactory),
			TRUE_PREDICATE);
}
 
Example 8
Source File: FilterJoinRule.java    From Bats with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a FilterJoinRule with an explicit root operand and
 * factories.
 */
@Deprecated // to be removed before 2.0
protected FilterJoinRule(RelOptRuleOperand operand, String id,
    boolean smart, RelFactories.FilterFactory filterFactory,
    RelFactories.ProjectFactory projectFactory) {
  this(operand, id, smart, RelBuilder.proto(filterFactory, projectFactory),
      TRUE_PREDICATE);
}
 
Example 9
Source File: FilterJoinRule.java    From Bats with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a FilterProjectTransposeRule with an explicit root operand and
 * factories.
 */
@Deprecated // to be removed before 2.0
protected FilterJoinRule(RelOptRuleOperand operand, String id,
    boolean smart, RelFactories.FilterFactory filterFactory,
    RelFactories.ProjectFactory projectFactory,
    Predicate predicate) {
  this(operand, id, smart, RelBuilder.proto(filterFactory, projectFactory),
      predicate);
}
 
Example 10
Source File: FlinkFilterJoinRule.java    From flink with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a FlinkFilterJoinRule with an explicit root operand and
 * factories.
 */
@Deprecated // to be removed before 2.0
protected FlinkFilterJoinRule(RelOptRuleOperand operand, String id,
		boolean smart, RelFactories.FilterFactory filterFactory,
		RelFactories.ProjectFactory projectFactory) {
	this(operand, id, smart, RelBuilder.proto(filterFactory, projectFactory),
			TRUE_PREDICATE);
}
 
Example 11
Source File: FilterJoinRule.java    From Bats with Apache License 2.0 5 votes vote down vote up
@Deprecated // to be removed before 2.0
public FilterIntoJoinRule(boolean smart,
    RelFactories.FilterFactory filterFactory,
    RelFactories.ProjectFactory projectFactory,
    Predicate predicate) {
  this(smart, RelBuilder.proto(filterFactory, projectFactory), predicate);
}
 
Example 12
Source File: FlinkFilterJoinRule.java    From flink with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a FilterProjectTransposeRule with an explicit root operand and
 * factories.
 */
@Deprecated // to be removed before 2.0
protected FlinkFilterJoinRule(RelOptRuleOperand operand, String id,
		boolean smart, RelFactories.FilterFactory filterFactory,
		RelFactories.ProjectFactory projectFactory,
		Predicate predicate) {
	this(operand, id, smart, RelBuilder.proto(filterFactory, projectFactory),
			predicate);
}
 
Example 13
Source File: FlinkFilterJoinRule.java    From flink with Apache License 2.0 4 votes vote down vote up
@Deprecated // to be removed before 2.0
public FlinkJoinConditionPushRule(RelFactories.FilterFactory filterFactory,
		RelFactories.ProjectFactory projectFactory, Predicate predicate) {
	this(RelBuilder.proto(filterFactory, projectFactory), predicate);
}
 
Example 14
Source File: FlinkJoinPushExpressionsRule.java    From flink with Apache License 2.0 4 votes vote down vote up
@Deprecated // to be removed before 2.0
public FlinkJoinPushExpressionsRule(Class<? extends Join> clazz,
		RelFactories.ProjectFactory projectFactory) {
	this(clazz, RelBuilder.proto(projectFactory));
}
 
Example 15
Source File: RelOptUtil.java    From Bats with Apache License 2.0 4 votes vote down vote up
public static RelNode createProject(RelNode child, Mappings.TargetMapping mapping,
        RelFactories.ProjectFactory projectFactory) {
    return createProject(projectFactory, child, Mappings.asList(mapping.inverse()));
}
 
Example 16
Source File: MultiJoinOptimizeBushyRule.java    From calcite with Apache License 2.0 4 votes vote down vote up
@Deprecated // to be removed before 2.0
public MultiJoinOptimizeBushyRule(RelFactories.JoinFactory joinFactory,
    RelFactories.ProjectFactory projectFactory) {
  this(RelBuilder.proto(joinFactory, projectFactory));
}
 
Example 17
Source File: JoinPushExpressionsRule.java    From calcite with Apache License 2.0 4 votes vote down vote up
@Deprecated // to be removed before 2.0
public JoinPushExpressionsRule(Class<? extends Join> clazz,
    RelFactories.ProjectFactory projectFactory) {
  this(clazz, RelBuilder.proto(projectFactory));
}
 
Example 18
Source File: RelOptUtil.java    From calcite with Apache License 2.0 4 votes vote down vote up
public static RelNode createProject(RelNode child, Mappings.TargetMapping mapping,
        RelFactories.ProjectFactory projectFactory) {
  return createProject(projectFactory, child, Mappings.asList(mapping.inverse()));
}
 
Example 19
Source File: FilterCorrelateRule.java    From Bats with Apache License 2.0 4 votes vote down vote up
/**
 * Creates a FilterCorrelateRule with an explicit root operand and
 * factories.
 */
@Deprecated // to be removed before 2.0
public FilterCorrelateRule(RelFactories.FilterFactory filterFactory,
    RelFactories.ProjectFactory projectFactory) {
  this(RelBuilder.proto(filterFactory, projectFactory));
}
 
Example 20
Source File: MultiJoinOptimizeBushyRule.java    From Bats with Apache License 2.0 4 votes vote down vote up
@Deprecated // to be removed before 2.0
public MultiJoinOptimizeBushyRule(RelFactories.JoinFactory joinFactory,
    RelFactories.ProjectFactory projectFactory) {
  this(RelBuilder.proto(joinFactory, projectFactory));
}