docs: static Type getType(int setType, Type type) {
  
          if (setType == OpTypes.COUNT) {
              return Type.SQL_BIGINT;
          }
  
          // A VoltDB extension to handle aggfnc(*) syntax errors.
          // If the argument node does not have
          // a data type, it may be '*'.  If the
          // operation is COUNT (optype == 71) this is
          // just fine.  But if it's anything else this
          // is a syntax error.
          if (type == null) {
              throw Error.error(ErrorCode.U_S0500);
          }
          // End of VoltDB extension
          int dataType = type.isIntervalType() ? Types.SQL_INTERVAL
                                               : type.typeCode;
  
          switch (setType) {
  
              case OpTypes.AVG : {
                  switch (dataType) {
  
                      case Types.TINYINT :
                      case Types.SQL_SMALLINT :
                      case Types.SQL_INTEGER :
                      case Types.SQL_BIGINT :
                      case Types.SQL_REAL :
                      case Types.SQL_FLOAT :
                      case Types.SQL_DOUBLE :
                      case Types.SQL_NUMERIC :
                      case Types.SQL_DECIMAL :
                      case Types.SQL_INTERVAL :
                          return type;
  
                      default :
                          throw Error.error(ErrorCode.X_42565);
                  }
              }
              case OpTypes.SUM : {
                  switch (dataType) {
  
                      case Types.TINYINT :
                      case Types.SQL_SMALLINT :
                      case Types.SQL_INTEGER :
                          return Type.SQL_BIGINT;
  
                      case Types.SQL_BIGINT :
                          return Type.SQL_DECIMAL_BIGINT_SQR;
  
                      case Types.SQL_REAL :
                      case Types.SQL_FLOAT :
                      case Types.SQL_DOUBLE :
                          return Type.SQL_DOUBLE;
  
                      case Types.SQL_NUMERIC :
                      case Types.SQL_DECIMAL :
                          return Type.getType(type.typeCode, 0,
                                              type.precision * 2, type.scale);
  
                      case Types.SQL_INTERVAL :
                          return IntervalType.newIntervalType(
                              type.typeCode, DTIType.maxIntervalPrecision,
                              type.scale);
  
                      default :
                          throw Error.error(ErrorCode.X_42565);
                  }
              }
              case OpTypes.MIN :
              case OpTypes.MAX :
                  return type;
  
              case OpTypes.EVERY :
              case OpTypes.SOME :
                  if (type.isBooleanType()) {
                      return Type.SQL_BOOLEAN;
                  }
                  break;
  
              case OpTypes.STDDEV_POP :
              case OpTypes.STDDEV_SAMP :
              case OpTypes.VAR_POP :
              case OpTypes.VAR_SAMP :
                  if (type.isNumberType()) {
                      return Type.SQL_DOUBLE;
                  }
                  break;
  
              // A VoltDB extension for APPROX_COUNT_DISTINCT
              case OpTypes.APPROX_COUNT_DISTINCT :
                  switch (dataType) {
                  case Types.TINYINT :
                  case Types.SQL_SMALLINT :
                  case Types.SQL_INTEGER :
                  case Types.SQL_BIGINT :
                  case Types.SQL_DECIMAL :
                  case Types.SQL_TIMESTAMP :
                      return Type.SQL_BIGINT;
                  default:
                      // We only support fixed-width types for this
                      // aggregate function.
                      //
                      // FLOAT is not supported since this function
                      // relies on different values having different bit
                      // patterns, and the same values being the
                      // same.  Floating point numbers don't hold to
                      // this---e.g., positive and negative zero.
                      //
                      // Incompatible data types in operation
                      throw Error.error(ErrorCode.X_42565);
                  }
              // End of VoltDB extension for APPROX_COUNT_DISTINCT
              default :
                  throw Error.runtimeError(ErrorCode.U_S0500, "SetFunction");
          }
  
          throw Error.error(ErrorCode.X_42565);
      }