code: public function build($query, $params = [])
      {
          $query = $query->prepare($this);
  
          $params = empty($params) ? $query->params : array_merge($params, $query->params);
  
          $clauses = [
              $this->buildSelect($query->select, $params, $query->distinct, $query->selectOption),
              $this->buildFrom($query->from, $params),
              $this->buildJoin($query->join, $params),
              $this->buildWhere($query->where, $params),
              $this->buildGroupBy($query->groupBy),
              $this->buildHaving($query->having, $params),
          ];
  
          $sql = implode($this->separator, array_filter($clauses));
          $sql = $this->buildOrderByAndLimit($sql, $query->orderBy, $query->limit, $query->offset);
  
          if (!empty($query->orderBy)) {
              foreach ($query->orderBy as $expression) {
                  if ($expression instanceof ExpressionInterface) {
                      $this->buildExpression($expression, $params);
                  }
              }
          }
          if (!empty($query->groupBy)) {
              foreach ($query->groupBy as $expression) {
                  if ($expression instanceof ExpressionInterface) {
                      $this->buildExpression($expression, $params);
                  }
              }
          }
  
          $union = $this->buildUnion($query->union, $params);
          if ($union !== '') {
              $sql = "$sql{$this->separator}$union";
          }
  
          return [$sql, $params];
      }
docs: {@inheritdoc}