class_docstr: A DoFn that extracts slice keys in batch based on input SQL.
class_docstr_tok: ["A","DoFn","that","extracts","slice","keys","in","batch","based","on","input","SQL","."]
code: def setup(self):
      def _generate_queries(
          schema: pa.Schema,
      ) -> List[sql_util.RecordBatchSQLSliceQuery]:
          queries = []
          for sql in self._sqls:
              try:
                  queries.append(
                      sql_util.RecordBatchSQLSliceQuery(sql, schema)
                  )
              except RuntimeError as error:
                  # We can't crash on errors caused by missing features/values.
                  # Instead failed slicing sqls will create a Invalid Slice.
                  logging.warning(
                      "Failed to parse SQL query %r: %r", sql, error
                  )
                  queries.append(None)
          return queries
  
      # A cache for compiled sql queries, keyed by record batch schemas.
      # This way we can work with record batches of different schemas.
      self._get_queries_for_schema = functools.lru_cache(maxsize=3)(
          _generate_queries
      )
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import collections
  from collections import abc
  import functools
  import logging
  from typing import Any, Dict, Iterable, List, Optional, Text, Union, Tuple
  import apache_beam
  import numpy
  import pandas
  import pandas.core.computation.expressions
  import pyarrow
  import six
  from tensorflow_data_validation import constants
  from tensorflow_data_validation import types
  from tensorflow_data_validation.arrow import arrow_util
  from tensorflow_data_validation.utils import stats_util
  from tfx_bsl.arrow import array_util
  from tfx_bsl.arrow import sql_util
  from tfx_bsl.arrow import table_util
  from tfx_bsl.public.proto import slicing_spec_pb2
  from tensorflow_metadata.proto.v0 import statistics_pb2
label_desc: Use image node_id 2 for calling the GenerateSlicesSqlDoFn obj's underlying member method code with example usage: obj.setup() and returns: queries