@param $alias
@param $columns

@return string
164798
protected function buildColumnsGroup(string $alias, array $columns): string
    {
        $parts = [];
        foreach ($columns as $column) {
            $parts[] = $column instanceof Query\Aggregation
                ? $column->setTableAlias($alias)
                : $alias . '.' . $column;
        }

        return implode(', ', $parts);
    }
564782
private function remapColumns(array &$columns, $alias = true): void {
    foreach($columns as &$column) {
      if($this->to_db[$column] !== $column) {
        if($alias) {
          $column = $this->to_db[$column] . ' as ' . $column;
        } else {
          $column = $this->to_db[$column];
        }
      }
    }
  }
1176837
function addColumn($column_name, $alias = null) {
		if ($alias === null || $alias === '') {
			$alias = $column_name;
		}
		$this->columns[$alias] = $column_name;
		return $this;
	}
1288301
public function selectMax(string $column, string $alias = null)
    {
        $instance = $this->selectQueryInstance();

        $instance->selectQuery()->max($column, $alias);

        return $instance;
    }
1065228
protected function extractColumnAlias($column)
    {
        $alias = $column;

        if (strpos($column, ' as ') !== false) {
            list($column, $alias) = explode(' as ', $column);
        }

        return [$column, $alias];
    }
93533
public function min(string $column, string $alias = null): string
    {
        if ($alias) {
            $alias = $this->quoteName($alias);
        }

        return 'MIN(' . $this->quoteName($column) . ')' . ($alias ? ' AS ' . $alias : '');
    }
125971
public function selectAvg(string $column, string $alias = null)
    {
        $instance = $this->selectQueryInstance();

        $instance->selectQuery()->avg($column, $alias);

        return $instance;
    }
152492
protected function withoutSelectAliases(array $columns)
    {
        return array_map(function ($column) {
            return is_string($column) && ($aliasPosition = stripos($column, ' as ')) !== false
                    ? substr($column, 0, $aliasPosition) : $column;
        }, $columns);
    }
1201700
protected function getIdentifier( $alias )
    {
        $aliasParts = explode( '.', $alias );
        $identifiers = array();
        // If the alias consists of one part, then we just look it up in the
        // array. If we find it, we use it, otherwise we return the name as-is
        // and assume it's just a column name. The alias target can be a fully
        // qualified name (table.column).
        if ( count( $aliasParts ) == 1 )
        {
            if ( $this->aliases !== null &&
                array_key_exists( $alias, $this->aliases ) )
            {
                $alias = $this->aliases[$alias];
            }
            return $alias;
        }
        // If the passed name consist of two parts, we need to check all parts
        // of the passed-in name for aliases, because an alias can be made for
        // both a table name and a column name. For each element we try to find
        // whether we have an alias mapping. Unlike the above case, the alias
        // target can in this case *not* consist of a fully qualified name as
        // this would introduce another part of the name (with two dots).
        for ( $i = 0; $i < count( $aliasParts ); $i++ )
        {
            if ( $this->aliases !== null &&
                array_key_exists( $aliasParts[$i], $this->aliases ) )
            {
                // We only use the found alias if the alias target is not a fully
                // qualified name (table.column).
                $tmpAlias = $this->aliases[$aliasParts[$i]];
                if ( count( explode( '.', $tmpAlias ) ) === 1 )
                {
                    $aliasParts[$i] = $this->aliases[$aliasParts[$i]];
                }
            }
        }
        $alias = join( '.', $aliasParts );
        return $alias;
    }
39542
public function alias($alias)
    {
        $this->alias = $alias;

        if (!in_array('`' . $alias . '`.*', $this->select)) {
            $this->select[] = '`' . $alias . '`.*';
        }

        if (in_array('`' . $this->table . '`.*', $this->select)) {
            unset($this->select[array_search('`' . $this->table . '`.*', $this->select)]);
        }

        return $this;
    }
1055581
public function select(string $column, string ...$columns)
    {
        $instance = $this->selectQueryInstance();

        $instance->selectQuery()->columns($column, ...$columns);

        return $instance;
    }
251498
public function select($columns = "*") : QueryBuilder
    {
        $this->_query[] = "SELECT";

        //Parse column(s)
        if(is_array($columns)) {
            $select_columns = "";

            $size = sizeof($columns);
            for($i = 0; $i < $size; $i++) {
                if($i > 0) {
                    $select_columns .= ', ';
                }

                $select_columns .= '`'. $this->sanitize((string)$columns[$i]) .'`';
            }

            $this->_query[] = $select_columns;

            return $this;
        }

        $select_columns = "*";
        if(
            !empty($columns) &&
            $columns !== "*"
        ) {
            $select_columns = '`'. $this->sanitize((string)$columns) .'`';
        }

        $this->_query[] = $select_columns;

        return $this;
    }
379075
public function addAliasedRawColumn(string $alias, string $column)
    {
        $table = $this->getTable();

        if (!$table->hasColumn($column)) {
            throw InvalidArgumentException::format(
                    'Invalid column for select: must be one of (%s), \'%s\' given',
                    Debug::formatValues($table->getColumnNames()), $column
            );
        }

        $this->aliasColumnMap[$alias] = Expr::column($this->getTableAlias(), $table->findColumn($column));

        return $this;
    }
859676
public function get($columns = ['*']) {
        if (count($columns) === 1 && isset($columns[0]) && $columns[0] === '*' && !empty($this->query->selects)) {
            return $this->query->all();
        }
        return $this->query->select($columns)->all();
    }
105152
public function guessCountQuery($column, $alias)
    {
        return str_replace($this->selected, $this->createFunction('COUNT', array($column), $alias), $this->getQueryString());
    }
1302294
public function columns($columns) {
        if (is_array($columns)) {
            $this->sql .= '(`' . implode('`, `', $columns) . '`) ';
        } else if (is_string($columns)) {
            $this->sql .= "($columns) ";
        }
        return $this;
    }
1248500
public function avg(string $column, string $alias = null)
    {
        $this->columnRaw($this->dialect()->avg($column, $alias));

        return $this;
    }