org.apache.calcite.sql.SqlGroupedWindowFunction Java Examples

The following examples show how to use org.apache.calcite.sql.SqlGroupedWindowFunction. 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: SqlStdOperatorTable.java    From calcite with Apache License 2.0 6 votes vote down vote up
/** Converts a call to a grouped window function to a call to its auxiliary
 * window function(s). For other calls returns null.
 *
 * <p>For example, converts {@code TUMBLE_START(rowtime, INTERVAL '1' HOUR))}
 * to {@code TUMBLE(rowtime, INTERVAL '1' HOUR))}. */
public static List<Pair<SqlNode, AuxiliaryConverter>> convertGroupToAuxiliaryCalls(
    SqlCall call) {
  final SqlOperator op = call.getOperator();
  if (op instanceof SqlGroupedWindowFunction
      && op.isGroup()) {
    ImmutableList.Builder<Pair<SqlNode, AuxiliaryConverter>> builder =
        ImmutableList.builder();
    for (final SqlGroupedWindowFunction f
        : ((SqlGroupedWindowFunction) op).getAuxiliaryFunctions()) {
      builder.add(
          Pair.of(copy(call, f),
              new AuxiliaryConverter.Impl(f)));
    }
    return builder.build();
  }
  return ImmutableList.of();
}
 
Example #2
Source File: SqlStdOperatorTable.java    From Bats with Apache License 2.0 6 votes vote down vote up
/** Returns the group function for which a given kind is an auxiliary
 * function, or null if it is not an auxiliary function. */
public static SqlGroupedWindowFunction auxiliaryToGroup(SqlKind kind) {
  switch (kind) {
  case TUMBLE_START:
  case TUMBLE_END:
    return TUMBLE;
  case HOP_START:
  case HOP_END:
    return HOP;
  case SESSION_START:
  case SESSION_END:
    return SESSION;
  default:
    return null;
  }
}
 
Example #3
Source File: SqlStdOperatorTable.java    From Bats with Apache License 2.0 6 votes vote down vote up
/** Converts a call to a grouped window function to a call to its auxiliary
 * window function(s). For other calls returns null.
 *
 * <p>For example, converts {@code TUMBLE_START(rowtime, INTERVAL '1' HOUR))}
 * to {@code TUMBLE(rowtime, INTERVAL '1' HOUR))}. */
public static List<Pair<SqlNode, AuxiliaryConverter>> convertGroupToAuxiliaryCalls(
    SqlCall call) {
  final SqlOperator op = call.getOperator();
  if (op instanceof SqlGroupedWindowFunction
      && op.isGroup()) {
    ImmutableList.Builder<Pair<SqlNode, AuxiliaryConverter>> builder =
        ImmutableList.builder();
    for (final SqlGroupedWindowFunction f
        : ((SqlGroupedWindowFunction) op).getAuxiliaryFunctions()) {
      builder.add(
          Pair.of(copy(call, f),
              new AuxiliaryConverter.Impl(f)));
    }
    return builder.build();
  }
  return ImmutableList.of();
}
 
Example #4
Source File: SqlStdOperatorTable.java    From calcite with Apache License 2.0 6 votes vote down vote up
/** Returns the group function for which a given kind is an auxiliary
 * function, or null if it is not an auxiliary function. */
public static SqlGroupedWindowFunction auxiliaryToGroup(SqlKind kind) {
  switch (kind) {
  case TUMBLE_START:
  case TUMBLE_END:
    return TUMBLE_OLD;
  case HOP_START:
  case HOP_END:
    return HOP_OLD;
  case SESSION_START:
  case SESSION_END:
    return SESSION_OLD;
  default:
    return null;
  }
}
 
Example #5
Source File: SqlStdOperatorTable.java    From calcite with Apache License 2.0 5 votes vote down vote up
/** Converts a call to a grouped auxiliary function
 * to a call to the grouped window function. For other calls returns null.
 *
 * <p>For example, converts {@code TUMBLE_START(rowtime, INTERVAL '1' HOUR))}
 * to {@code TUMBLE(rowtime, INTERVAL '1' HOUR))}. */
public static SqlCall convertAuxiliaryToGroupCall(SqlCall call) {
  final SqlOperator op = call.getOperator();
  if (op instanceof SqlGroupedWindowFunction
      && op.isGroupAuxiliary()) {
    return copy(call, ((SqlGroupedWindowFunction) op).groupFunction);
  }
  return null;
}
 
Example #6
Source File: SqlStdOperatorTable.java    From Bats with Apache License 2.0 5 votes vote down vote up
/** Converts a call to a grouped auxiliary function
 * to a call to the grouped window function. For other calls returns null.
 *
 * <p>For example, converts {@code TUMBLE_START(rowtime, INTERVAL '1' HOUR))}
 * to {@code TUMBLE(rowtime, INTERVAL '1' HOUR))}. */
public static SqlCall convertAuxiliaryToGroupCall(SqlCall call) {
  final SqlOperator op = call.getOperator();
  if (op instanceof SqlGroupedWindowFunction
      && op.isGroupAuxiliary()) {
    return copy(call, ((SqlGroupedWindowFunction) op).groupFunction);
  }
  return null;
}
 
Example #7
Source File: FlinkSqlOperatorTable.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
public List<SqlGroupedWindowFunction> getAuxiliaryFunctions() {
	return Arrays.asList(TUMBLE_START, TUMBLE_END, TUMBLE_ROWTIME, TUMBLE_PROCTIME);
}
 
Example #8
Source File: SqlStdOperatorTable.java    From calcite with Apache License 2.0 4 votes vote down vote up
@Override public List<SqlGroupedWindowFunction> getAuxiliaryFunctions() {
  return ImmutableList.of(SESSION_START, SESSION_END);
}
 
Example #9
Source File: SqlStdOperatorTable.java    From calcite with Apache License 2.0 4 votes vote down vote up
@Override public List<SqlGroupedWindowFunction> getAuxiliaryFunctions() {
  return ImmutableList.of(HOP_START, HOP_END);
}
 
Example #10
Source File: SqlStdOperatorTable.java    From calcite with Apache License 2.0 4 votes vote down vote up
@Override public List<SqlGroupedWindowFunction> getAuxiliaryFunctions() {
  return ImmutableList.of(TUMBLE_START, TUMBLE_END);
}
 
Example #11
Source File: FlinkSqlOperatorTable.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
public List<SqlGroupedWindowFunction> getAuxiliaryFunctions() {
	return Arrays.asList(SESSION_START, SESSION_END, SESSION_ROWTIME, SESSION_PROCTIME);
}
 
Example #12
Source File: FlinkSqlOperatorTable.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
public List<SqlGroupedWindowFunction> getAuxiliaryFunctions() {
	return Arrays.asList(HOP_START, HOP_END, HOP_ROWTIME, HOP_PROCTIME);
}
 
Example #13
Source File: SqlStdOperatorTable.java    From Bats with Apache License 2.0 4 votes vote down vote up
@Override public List<SqlGroupedWindowFunction> getAuxiliaryFunctions() {
  return ImmutableList.of(TUMBLE_START, TUMBLE_END);
}
 
Example #14
Source File: FlinkSqlOperatorTable.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
public List<SqlGroupedWindowFunction> getAuxiliaryFunctions() {
	return Arrays.asList(SESSION_START, SESSION_END, SESSION_ROWTIME, SESSION_PROCTIME);
}
 
Example #15
Source File: FlinkSqlOperatorTable.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
public List<SqlGroupedWindowFunction> getAuxiliaryFunctions() {
	return Arrays.asList(HOP_START, HOP_END, HOP_ROWTIME, HOP_PROCTIME);
}
 
Example #16
Source File: FlinkSqlOperatorTable.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
public List<SqlGroupedWindowFunction> getAuxiliaryFunctions() {
	return Arrays.asList(TUMBLE_START, TUMBLE_END, TUMBLE_ROWTIME, TUMBLE_PROCTIME);
}
 
Example #17
Source File: SqlStdOperatorTable.java    From Bats with Apache License 2.0 4 votes vote down vote up
@Override public List<SqlGroupedWindowFunction> getAuxiliaryFunctions() {
  return ImmutableList.of(SESSION_START, SESSION_END);
}
 
Example #18
Source File: SqlStdOperatorTable.java    From Bats with Apache License 2.0 4 votes vote down vote up
@Override public List<SqlGroupedWindowFunction> getAuxiliaryFunctions() {
  return ImmutableList.of(HOP_START, HOP_END);
}