Java Code Examples for org.apache.calcite.sql.SqlGroupedWindowFunction

The following examples show how to use org.apache.calcite.sql.SqlGroupedWindowFunction. These examples are extracted from open source projects. 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 Project: Bats   Source File: SqlStdOperatorTable.java    License: 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 2
Source Project: Bats   Source File: SqlStdOperatorTable.java    License: 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 3
Source Project: calcite   Source File: SqlStdOperatorTable.java    License: 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 4
Source Project: calcite   Source File: SqlStdOperatorTable.java    License: 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 5
Source Project: Bats   Source File: SqlStdOperatorTable.java    License: 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 Project: calcite   Source File: SqlStdOperatorTable.java    License: 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 Project: Bats   Source File: SqlStdOperatorTable.java    License: Apache License 2.0 4 votes vote down vote up
@Override public List<SqlGroupedWindowFunction> getAuxiliaryFunctions() {
  return ImmutableList.of(TUMBLE_START, TUMBLE_END);
}
 
Example 8
Source Project: Bats   Source File: SqlStdOperatorTable.java    License: Apache License 2.0 4 votes vote down vote up
@Override public List<SqlGroupedWindowFunction> getAuxiliaryFunctions() {
  return ImmutableList.of(HOP_START, HOP_END);
}
 
Example 9
Source Project: Bats   Source File: SqlStdOperatorTable.java    License: Apache License 2.0 4 votes vote down vote up
@Override public List<SqlGroupedWindowFunction> getAuxiliaryFunctions() {
  return ImmutableList.of(SESSION_START, SESSION_END);
}
 
Example 10
Source Project: flink   Source File: FlinkSqlOperatorTable.java    License: 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 11
Source Project: flink   Source File: FlinkSqlOperatorTable.java    License: 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 12
Source Project: flink   Source File: FlinkSqlOperatorTable.java    License: 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 13
Source Project: flink   Source File: FlinkSqlOperatorTable.java    License: 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 14
Source Project: flink   Source File: FlinkSqlOperatorTable.java    License: 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 15
Source Project: flink   Source File: FlinkSqlOperatorTable.java    License: 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 16
Source Project: calcite   Source File: SqlStdOperatorTable.java    License: Apache License 2.0 4 votes vote down vote up
@Override public List<SqlGroupedWindowFunction> getAuxiliaryFunctions() {
  return ImmutableList.of(TUMBLE_START, TUMBLE_END);
}
 
Example 17
Source Project: calcite   Source File: SqlStdOperatorTable.java    License: Apache License 2.0 4 votes vote down vote up
@Override public List<SqlGroupedWindowFunction> getAuxiliaryFunctions() {
  return ImmutableList.of(HOP_START, HOP_END);
}
 
Example 18
Source Project: calcite   Source File: SqlStdOperatorTable.java    License: Apache License 2.0 4 votes vote down vote up
@Override public List<SqlGroupedWindowFunction> getAuxiliaryFunctions() {
  return ImmutableList.of(SESSION_START, SESSION_END);
}