code: def read_parquet(
      source: str | Path | list[str] | list[Path] | IO[bytes] | bytes,
      *,
      columns: list[int] | list[str] | None = None,
      n_rows: int | None = None,
      row_count_name: str | None = None,
      row_count_offset: int = 0,
      parallel: ParallelStrategy = "auto",
      use_statistics: bool = True,
      hive_partitioning: bool = True,
      rechunk: bool = True,
      low_memory: bool = False,
      storage_options: dict[str, Any] | None = None,
      retries: int = 0,
      use_pyarrow: bool = False,
      pyarrow_options: dict[str, Any] | None = None,
      memory_map: bool = True,
  ) -> DataFrame:
      """
      Read into a DataFrame from a parquet file.
  
      Parameters
      ----------
      source
          Path to a file, or a file-like object. If the path is a directory, files in that
          directory will all be read.
      columns
          Columns to select. Accepts a list of column indices (starting at zero) or a list
          of column names.
      n_rows
          Stop reading from parquet file after reading `n_rows`.
          Only valid when `use_pyarrow=False`.
      row_count_name
          If not None, this will insert a row count column with give name into the
          DataFrame.
      row_count_offset
          Offset to start the row_count column (only use if the name is set).
      parallel : {'auto', 'columns', 'row_groups', 'none'}
          This determines the direction of parallelism. 'auto' will try to determine the
          optimal direction.
      use_statistics
          Use statistics in the parquet to determine if pages
          can be skipped from reading.
      hive_partitioning
          Infer statistics and schema from hive partitioned URL and use them
          to prune reads.
      rechunk
          Make sure that all columns are contiguous in memory by
          aggregating the chunks into a single array.
      low_memory
          Reduce memory pressure at the expense of performance.
      storage_options
          Options that indicate how to connect to a cloud provider.
          If the cloud provider is not supported by Polars, the storage options
          are passed to `fsspec.open()`.
  
          The cloud providers currently supported are AWS, GCP, and Azure.
          See supported keys here:
  
          * `aws <https://docs.rs/object_store/latest/object_store/aws/enum.AmazonS3ConfigKey.html>`_
          * `gcp <https://docs.rs/object_store/latest/object_store/gcp/enum.GoogleConfigKey.html>`_
          * `azure <https://docs.rs/object_store/latest/object_store/azure/enum.AzureConfigKey.html>`_
  
          If `storage_options` is not provided, Polars will try to infer the information
          from environment variables.
      retries
          Number of retries if accessing a cloud instance fails.
      use_pyarrow
          Use pyarrow instead of the Rust native parquet reader. The pyarrow reader is
          more stable.
      pyarrow_options
          Keyword arguments for `pyarrow.parquet.read_table
          <https://arrow.apache.org/docs/python/generated/pyarrow.parquet.read_table.html>`_.
      memory_map
          Memory map underlying file. This will likely increase performance.
          Only used when `use_pyarrow=True`.
  
      Returns
      -------
      DataFrame
  
      See Also
      --------
      scan_parquet
      scan_pyarrow_dataset
  
      Notes
      -----
      * Partitioned files:
          If you have a directory-nested (hive-style) partitioned dataset, you should
          use the :func:`scan_pyarrow_dataset` method instead.
      * When benchmarking:
          This operation defaults to a `rechunk` operation at the end, meaning that all
          data will be stored continuously in memory. Set `rechunk=False` if you are
          benchmarking the parquet-reader as `rechunk` can be an expensive operation
          that should not contribute to the timings.
      """
      # Dispatch to pyarrow if requested
      if use_pyarrow:
          if not _PYARROW_AVAILABLE:
              raise ModuleNotFoundError(
                  "'pyarrow' is required when using `read_parquet(..., use_pyarrow=True)`"
              )
          if n_rows is not None:
              raise ValueError(
                  "`n_rows` cannot be used with `use_pyarrow=True`"
              )
  
          import pyarrow as pa
          import pyarrow.parquet
  
          pyarrow_options = pyarrow_options or {}
  
          with _prepare_file_arg(
              source,  # type: ignore[arg-type]
              use_pyarrow=True,
              storage_options=storage_options,
          ) as source_prep:
              return from_arrow(  # type: ignore[return-value]
                  pa.parquet.read_table(
                      source_prep,
                      memory_map=memory_map,
                      columns=columns,
                      **pyarrow_options,
                  )
              )
  
      # Read binary types using `read_parquet`
      elif isinstance(source, (io.BufferedIOBase, io.RawIOBase, bytes)):
          with _prepare_file_arg(
              source, use_pyarrow=False
          ) as source_prep:
              return pl.DataFrame._read_parquet(
                  source_prep,
                  columns=columns,
                  n_rows=n_rows,
                  parallel=parallel,
                  row_count_name=row_count_name,
                  row_count_offset=row_count_offset,
                  low_memory=low_memory,
                  use_statistics=use_statistics,
                  rechunk=rechunk,
              )
  
      # For other inputs, defer to `scan_parquet`
      lf = scan_parquet(
          source,  # type: ignore[arg-type]
          n_rows=n_rows,
          row_count_name=row_count_name,
          row_count_offset=row_count_offset,
          parallel=parallel,
          use_statistics=use_statistics,
          hive_partitioning=hive_partitioning,
          rechunk=rechunk,
          low_memory=low_memory,
          cache=False,
          storage_options=storage_options,
          retries=retries,
      )
  
      if columns is not None:
          if is_int_sequence(columns):
              columns = [lf.columns[i] for i in columns]
          lf = lf.select(columns)
  
      return lf.collect(no_optimization=True)
  
file_path: polars/py-polars/polars/io/parquet/functions.py
imports: from __future__ import annotations
  import contextlib
  import io
  from pathlib import Path
  from typing import IO, TYPE_CHECKING, Any
  import polars._reexport
  from polars.convert import from_arrow
  from polars.dependencies import _PYARROW_AVAILABLE
  from polars.io._utils import _prepare_file_arg
  from polars.utils.various import is_int_sequence, normalize_filepath
label_desc: Use image node_id 1 for calling a global function with example usage: read_parquet(source) and returns: lf, from_arrow, pl