code: def _dataset_to_decl(dataset, use_threads=True):
      decl = Declaration(
          "scan", ScanNodeOptions(dataset, use_threads=use_threads)
      )
  
      # Get rid of special dataset columns
      # "__fragment_index", "__batch_index", "__last_in_fragment", "__filename"
      projections = [field(f) for f in dataset.schema.names]
      decl = Declaration.from_sequence(
          [
              decl,
              Declaration("project", ProjectNodeOptions(projections)),
          ]
      )
  
      filter_expr = dataset._scan_options.get("filter")
      if filter_expr is not None:
          # Filters applied in CScanNodeOptions are "best effort" for the scan node itself
          # so we always need to inject an additional Filter node to apply them for real.
          decl = Declaration.from_sequence(
              [
                  decl,
                  Declaration("filter", FilterNodeOptions(filter_expr)),
              ]
          )
  
      return decl
  
imports: from pyarrow.lib import Table
  from pyarrow.compute import Expression, field
label_desc: Use image node_id 1 for calling a global function with example usage: _dataset_to_decl(dataset, use_threads) and returns: decl