static void checkColumnsResolved(HsqlList set) {

    if (set != null && !set.isEmpty()) {
      StringBuffer sb = new StringBuffer();
      Expression e = (Expression) set.get(0);

      if (e instanceof ExpressionColumn) {
        ExpressionColumn c = (ExpressionColumn) e;

        if (c.schema != null) {
          sb.append(c.schema + '.');
        }

        if (c.tableName != null) {
          sb.append(c.tableName + '.');
        }

        throw Error.error(ErrorCode.X_42501, sb.toString() + c.getColumnName());
      } else {
        OrderedHashSet newSet = new OrderedHashSet();

        e.collectAllExpressions(
            newSet, Expression.columnExpressionSet, Expression.emptyExpressionSet);

        // throw with column name
        checkColumnsResolved(newSet);

        // throw anyway if not found
        throw Error.error(ErrorCode.X_42501);
      }
    }
  }
  public void resolveRangeTable(Session session, RangeGroup rangeGroup, RangeGroup[] rangeGroups) {

    QueryExpression queryExpression = rangeTable.getQueryExpression();
    Expression dataExpression = rangeTable.getDataExpression();

    if (queryExpression == null && dataExpression == null) {
      return;
    }

    rangeGroups =
        (RangeGroup[]) ArrayUtil.toAdjustedArray(rangeGroups, rangeGroup, rangeGroups.length, 1);

    if (dataExpression != null) {
      HsqlList unresolved =
          dataExpression.resolveColumnReferences(session, RangeGroup.emptyGroup, rangeGroups, null);

      unresolved =
          Expression.resolveColumnSet(
              session, RangeVariable.emptyArray, RangeGroup.emptyArray, unresolved);

      ExpressionColumn.checkColumnsResolved(unresolved);
      dataExpression.resolveTypes(session, null);
      setRangeTableVariables();
    }

    if (queryExpression != null) {
      queryExpression.resolveReferences(session, rangeGroups);

      HsqlList unresolved = queryExpression.getUnresolvedExpressions();

      unresolved =
          Expression.resolveColumnSet(
              session, RangeVariable.emptyArray, RangeGroup.emptyArray, unresolved);

      ExpressionColumn.checkColumnsResolved(unresolved);
      queryExpression.resolveTypesPartOne(session);
      queryExpression.resolveTypesPartTwo(session);
      rangeTable.prepareTable();
      setRangeTableVariables();
    }
  }