code: def dataset(
      source,
      schema=None,
      format=None,
      filesystem=None,
      partitioning=None,
      partition_base_dir=None,
      exclude_invalid_files=None,
      ignore_prefixes=None,
  ):
      """
      Open a dataset.
  
      Datasets provides functionality to efficiently work with tabular,
      potentially larger than memory and multi-file dataset.
  
      - A unified interface for different sources, like Parquet and Feather
      - Discovery of sources (crawling directories, handle directory-based
        partitioned datasets, basic schema normalization)
      - Optimized reading with predicate pushdown (filtering rows), projection
        (selecting columns), parallel reading or fine-grained managing of tasks.
  
      Note that this is the high-level API, to have more control over the dataset
      construction use the low-level API classes (FileSystemDataset,
      FilesystemDatasetFactory, etc.)
  
      Parameters
      ----------
      source : path, list of paths, dataset, list of datasets, (list of) \
  RecordBatch or Table, iterable of RecordBatch, RecordBatchReader, or URI
          Path pointing to a single file:
              Open a FileSystemDataset from a single file.
          Path pointing to a directory:
              The directory gets discovered recursively according to a
              partitioning scheme if given.
          List of file paths:
              Create a FileSystemDataset from explicitly given files. The files
              must be located on the same filesystem given by the filesystem
              parameter.
              Note that in contrary of construction from a single file, passing
              URIs as paths is not allowed.
          List of datasets:
              A nested UnionDataset gets constructed, it allows arbitrary
              composition of other datasets.
              Note that additional keyword arguments are not allowed.
          (List of) batches or tables, iterable of batches, or RecordBatchReader:
              Create an InMemoryDataset. If an iterable or empty list is given,
              a schema must also be given. If an iterable or RecordBatchReader
              is given, the resulting dataset can only be scanned once; further
              attempts will raise an error.
      schema : Schema, optional
          Optionally provide the Schema for the Dataset, in which case it will
          not be inferred from the source.
      format : FileFormat or str
          Currently "parquet", "ipc"/"arrow"/"feather", "csv", "json", and "orc" are
          supported. For Feather, only version 2 files are supported.
      filesystem : FileSystem or URI string, default None
          If a single path is given as source and filesystem is None, then the
          filesystem will be inferred from the path.
          If an URI string is passed, then a filesystem object is constructed
          using the URI's optional path component as a directory prefix. See the
          examples below.
          Note that the URIs on Windows must follow 'file:///C:...' or
          'file:/C:...' patterns.
      partitioning : Partitioning, PartitioningFactory, str, list of str
          The partitioning scheme specified with the ``partitioning()``
          function. A flavor string can be used as shortcut, and with a list of
          field names a DirectoryPartitioning will be inferred.
      partition_base_dir : str, optional
          For the purposes of applying the partitioning, paths will be
          stripped of the partition_base_dir. Files not matching the
          partition_base_dir prefix will be skipped for partitioning discovery.
          The ignored files will still be part of the Dataset, but will not
          have partition information.
      exclude_invalid_files : bool, optional (default True)
          If True, invalid files will be excluded (file format specific check).
          This will incur IO for each files in a serial and single threaded
          fashion. Disabling this feature will skip the IO, but unsupported
          files may be present in the Dataset (resulting in an error at scan
          time).
      ignore_prefixes : list, optional
          Files matching any of these prefixes will be ignored by the
          discovery process. This is matched to the basename of a path.
          By default this is ['.', '_'].
          Note that discovery happens only if a directory is passed as source.
  
      Returns
      -------
      dataset : Dataset
          Either a FileSystemDataset or a UnionDataset depending on the source
          parameter.
  
      Examples
      --------
      Creating an example Table:
  
      >>> import pyarrow as pa
      >>> import pyarrow.parquet as pq
      >>> table = pa.table({'year': [2020, 2022, 2021, 2022, 2019, 2021],
      ...                   'n_legs': [2, 2, 4, 4, 5, 100],
      ...                   'animal': ["Flamingo", "Parrot", "Dog", "Horse",
      ...                              "Brittle stars", "Centipede"]})
      >>> pq.write_table(table, "file.parquet")
  
      Opening a single file:
  
      >>> import pyarrow.dataset as ds
      >>> dataset = ds.dataset("file.parquet", format="parquet")
      >>> dataset.to_table()
      pyarrow.Table
      year: int64
      n_legs: int64
      animal: string
      ----
      year: [[2020,2022,2021,2022,2019,2021]]
      n_legs: [[2,2,4,4,5,100]]
      animal: [["Flamingo","Parrot","Dog","Horse","Brittle stars","Centipede"]]
  
      Opening a single file with an explicit schema:
  
      >>> myschema = pa.schema([
      ...     ('n_legs', pa.int64()),
      ...     ('animal', pa.string())])
      >>> dataset = ds.dataset("file.parquet", schema=myschema, format="parquet")
      >>> dataset.to_table()
      pyarrow.Table
      n_legs: int64
      animal: string
      ----
      n_legs: [[2,2,4,4,5,100]]
      animal: [["Flamingo","Parrot","Dog","Horse","Brittle stars","Centipede"]]
  
      Opening a dataset for a single directory:
  
      >>> ds.write_dataset(table, "partitioned_dataset", format="parquet",
      ...                  partitioning=['year'])
      >>> dataset = ds.dataset("partitioned_dataset", format="parquet")
      >>> dataset.to_table()
      pyarrow.Table
      n_legs: int64
      animal: string
      ----
      n_legs: [[5],[2],[4,100],[2,4]]
      animal: [["Brittle stars"],["Flamingo"],...["Parrot","Horse"]]
  
      For a single directory from a S3 bucket:
  
      >>> ds.dataset("s3://mybucket/nyc-taxi/",
      ...            format="parquet") # doctest: +SKIP
  
      Opening a dataset from a list of relatives local paths:
  
      >>> dataset = ds.dataset([
      ...     "partitioned_dataset/2019/part-0.parquet",
      ...     "partitioned_dataset/2020/part-0.parquet",
      ...     "partitioned_dataset/2021/part-0.parquet",
      ... ], format='parquet')
      >>> dataset.to_table()
      pyarrow.Table
      n_legs: int64
      animal: string
      ----
      n_legs: [[5],[2],[4,100]]
      animal: [["Brittle stars"],["Flamingo"],["Dog","Centipede"]]
  
      With filesystem provided:
  
      >>> paths = [
      ...     'part0/data.parquet',
      ...     'part1/data.parquet',
      ...     'part3/data.parquet',
      ... ]
      >>> ds.dataset(paths, filesystem='file:///directory/prefix,
      ...            format='parquet') # doctest: +SKIP
  
      Which is equivalent with:
  
      >>> fs = SubTreeFileSystem("/directory/prefix",
      ...                        LocalFileSystem()) # doctest: +SKIP
      >>> ds.dataset(paths, filesystem=fs, format='parquet') # doctest: +SKIP
  
      With a remote filesystem URI:
  
      >>> paths = [
      ...     'nested/directory/part0/data.parquet',
      ...     'nested/directory/part1/data.parquet',
      ...     'nested/directory/part3/data.parquet',
      ... ]
      >>> ds.dataset(paths, filesystem='s3://bucket/',
      ...            format='parquet') # doctest: +SKIP
  
      Similarly to the local example, the directory prefix may be included in the
      filesystem URI:
  
      >>> ds.dataset(paths, filesystem='s3://bucket/nested/directory',
      ...         format='parquet') # doctest: +SKIP
  
      Construction of a nested dataset:
  
      >>> ds.dataset([
      ...     dataset("s3://old-taxi-data", format="parquet"),
      ...     dataset("local/path/to/data", format="ipc")
      ... ]) # doctest: +SKIP
      """
      # collect the keyword arguments for later reuse
      kwargs = dict(
          schema=schema,
          filesystem=filesystem,
          partitioning=partitioning,
          format=format,
          partition_base_dir=partition_base_dir,
          exclude_invalid_files=exclude_invalid_files,
          selector_ignore_prefixes=ignore_prefixes,
      )
  
      if _is_path_like(source):
          return _filesystem_dataset(source, **kwargs)
      elif isinstance(source, (tuple, list)):
          if all(_is_path_like(elem) for elem in source):
              return _filesystem_dataset(source, **kwargs)
          elif all(isinstance(elem, Dataset) for elem in source):
              return _union_dataset(source, **kwargs)
          elif all(
              isinstance(elem, (pa.RecordBatch, pa.Table))
              for elem in source
          ):
              return _in_memory_dataset(source, **kwargs)
          else:
              unique_types = set(type(elem).__name__ for elem in source)
              type_names = ", ".join(
                  "{}".format(t) for t in unique_types
              )
              raise TypeError(
                  "Expected a list of path-like or dataset objects, or a list "
                  "of batches or tables. The given list contains the following "
                  "types: {}".format(type_names)
              )
      elif isinstance(source, (pa.RecordBatch, pa.Table)):
          return _in_memory_dataset(source, **kwargs)
      else:
          raise TypeError(
              "Expected a path-like, list of path-likes or a list of Datasets "
              "instead of the given type: {}".format(
                  type(source).__name__
              )
          )
  
file_path: arrow/python/pyarrow/dataset.py
imports: import pyarrow
  from pyarrow.util import _is_iterable, _stringify_path, _is_path_like
  from pyarrow.compute import Expression, scalar, field
label_desc: Use image node_id 11 for calling a global function with example usage: dataset(source, schema, format, filesystem, partitioning, partition_base_dir, exclude_invalid_files, ignore_prefixes) and returns: _filesystem_dataset, _filesystem_dataset, _in_memory_dataset, _union_dataset, _in_memory_dataset