Java Code Examples for org.apache.calcite.sql.type.SqlTypeUtil#projectTypes()

The following examples show how to use org.apache.calcite.sql.type.SqlTypeUtil#projectTypes() . 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: AggregateCall.java    From Bats with Apache License 2.0 6 votes vote down vote up
/** Creates an AggregateCall, inferring its type if {@code type} is null. */
public static AggregateCall create(SqlAggFunction aggFunction,
    boolean distinct, boolean approximate, List<Integer> argList,
    int filterArg, RelCollation collation, int groupCount,
    RelNode input, RelDataType type, String name) {
  if (type == null) {
    final RelDataTypeFactory typeFactory =
        input.getCluster().getTypeFactory();
    final List<RelDataType> types =
        SqlTypeUtil.projectTypes(input.getRowType(), argList);
    final Aggregate.AggCallBinding callBinding =
        new Aggregate.AggCallBinding(typeFactory, aggFunction, types,
            groupCount, filterArg >= 0);
    type = aggFunction.inferReturnType(callBinding);
  }
  return create(aggFunction, distinct, approximate, argList, filterArg,
      collation, type, name);
}
 
Example 2
Source File: AggregateCall.java    From calcite with Apache License 2.0 6 votes vote down vote up
/** Creates an AggregateCall, inferring its type if {@code type} is null. */
public static AggregateCall create(SqlAggFunction aggFunction,
    boolean distinct, boolean approximate, boolean ignoreNulls,
    List<Integer> argList, int filterArg, RelCollation collation,
    int groupCount,
    RelNode input, RelDataType type, String name) {
  if (type == null) {
    final RelDataTypeFactory typeFactory =
        input.getCluster().getTypeFactory();
    final List<RelDataType> types =
        SqlTypeUtil.projectTypes(input.getRowType(), argList);
    final Aggregate.AggCallBinding callBinding =
        new Aggregate.AggCallBinding(typeFactory, aggFunction, types,
            groupCount, filterArg >= 0);
    type = aggFunction.inferReturnType(callBinding);
  }
  return create(aggFunction, distinct, approximate, ignoreNulls, argList,
      filterArg, collation, type, name);
}
 
Example 3
Source File: AggregateCall.java    From Bats with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a binding of this call in the context of an
 * {@link org.apache.calcite.rel.logical.LogicalAggregate},
 * which can then be used to infer the return type.
 */
public Aggregate.AggCallBinding createBinding(
    Aggregate aggregateRelBase) {
  final RelDataType rowType = aggregateRelBase.getInput().getRowType();

  return new Aggregate.AggCallBinding(
      aggregateRelBase.getCluster().getTypeFactory(), aggFunction,
      SqlTypeUtil.projectTypes(rowType, argList),
      aggregateRelBase.getGroupCount(), hasFilter());
}
 
Example 4
Source File: AggregateCall.java    From calcite with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a binding of this call in the context of an
 * {@link org.apache.calcite.rel.logical.LogicalAggregate},
 * which can then be used to infer the return type.
 */
public Aggregate.AggCallBinding createBinding(
    Aggregate aggregateRelBase) {
  final RelDataType rowType = aggregateRelBase.getInput().getRowType();

  return new Aggregate.AggCallBinding(
      aggregateRelBase.getCluster().getTypeFactory(), aggFunction,
      SqlTypeUtil.projectTypes(rowType, argList),
      aggregateRelBase.getGroupCount(), hasFilter());
}