class_docstr: BigQueryClient is the entrypoint for interacting with Cloud BigQuery in TF.
  
  BigQueryClient encapsulates a connection to Cloud BigQuery, and exposes the
  `readSession` method to initiate a BigQuery read session.
docstr: Opens a session and returns a `BigQueryReadSession` object.
  
  Args:
      parent: String of the form projects/{project_id} indicating the project
          this ReadSession is associated with. This is the project that will be
          billed for usage.
      project_id: The assigned project ID of the project.
      table_id: The ID of the table in the dataset.
      dataset_id: The ID of the dataset in the project.
      selected_fields: This can be a list or a dict. If a list, it has
          names of the fields in the table that should be read. If a dict,
          it should be in a form like, i.e:
          { "field_a_name": {"mode": "repeated", "output_type": dtypes.int64},
          "field_b_name": {"mode": "nullable", "output_type": dtypes.int32, "default_value": 0},
          ...
          "field_x_name": {"mode": "repeated", "output_type": dtypes.string, "default_value": ""}
          }
          "mode" is BigQuery column attribute, it can be 'repeated', 'nullable' or 'required'.
          The output field order is unrelated to the order of fields in
          selected_fields. If "mode" not specified, defaults to "nullable".
          If "output_type" not specified, DT_STRING is implied for all Tensors.
      output_types: Types for the output tensor in the same sequence as
          selected_fields. This is only needed when selected_fields is a list,
          if selected_fields is a dictionary, this output_types information is
          included in selected_fields as described above.
          If not specified, DT_STRING is implied for all Tensors.
      default_values: Default values to use when underlying tensor is "null"
          in the same sequence as selected_fields. If not sepecified,
          meaningful defaults are going to be used
          (0 for numerices, empty string for strings, and False for booleans).
      row_restriction: Optional. SQL text filtering statement, similar to a
          WHERE clause in a query.
      requested_streams: Desirable number of streams that can be read in parallel.
          Must be a positive number. The actual number of streams that
          BigQuery Streaming API returns may be lower than this number,
          depending on the amount parallelism that is reasonable
          for the table and the maximum amount of parallelism allowed by the
          system.
  
  Returns:
      A `BigQueryReadSession` Python object representing the
      operations available on the table.
docstr_tok: ["Opens","a","session","and","returns","a","`","BigQueryReadSession","`","object",".","Args",":","parent",":","String","of","the","form","projects\/","{","project_id","}","indicating","the","project","this","ReadSession","is","associated","with",".","This","is","the","project","that","will","be","billed","for","usage",".","project_id",":","The","assigned","project","ID","of","the","project",".","table_id",":","The","ID","of","the","table","in","the","dataset",".","dataset_id",":","The","ID","of","the","dataset","in","the","project",".","selected_fields",":","This","can","be","a","list","or","a","dict",".","If","a","list",",","it","has","names","of","the","fields","in","the","table","that","should","be","read",".","If","a","dict",",","it","should","be","in","a","form","like",",","i.e",":","{","``","field_a_name","''",":","{","``","mode","''",":","``","repeated","''",",","``","output_type","''",":","dtypes.int64","}",",","``","field_b_name","''",":","{","``","mode","''",":","``","nullable","''",",","``","output_type","''",":","dtypes.int32",",","``","default_value","''",":","0","}",",","...","``","field_x_name","''",":","{","``","mode","''",":","``","repeated","''",",","``","output_type","''",":","dtypes.string",",","``","default_value","''",":","``","''","}","}","``","mode","''","is","BigQuery","column","attribute",",","it","can","be","'repeated","'",",","'nullable","'","or","'required","'",".","The","output","field","order","is","unrelated","to","the","order","of","fields","in","selected_fields",".","If","``","mode","''","not","specified",",","defaults","to","``","nullable","''",".","If","``","output_type","''","not","specified",",","DT_STRING","is","implied","for","all","Tensors",".","output_types",":","Types","for","the","output","tensor","in","the","same","sequence","as","selected_fields",".","This","is","only","needed","when","selected_fields","is","a","list",",","if","selected_fields","is","a","dictionary",",","this","output_types","information","is","included","in","selected_fields","as","described","above",".","If","not","specified",",","DT_STRING","is","implied","for","all","Tensors",".","default_values",":","Default","values","to","use","when","underlying","tensor","is","``","null","''","in","the","same","sequence","as","selected_fields",".","If","not","sepecified",",","meaningful","defaults","are","going","to","be","used","(","0","for","numerices",",","empty","string","for","strings",",","and","False","for","booleans",")",".","row_restriction",":","Optional",".","SQL","text","filtering","statement",",","similar","to","a","WHERE","clause","in","a","query",".","requested_streams",":","Desirable","number","of","streams","that","can","be","read","in","parallel",".","Must","be","a","positive","number",".","The","actual","number","of","streams","that","BigQuery","Streaming","API","returns","may","be","lower","than","this","number",",","depending","on","the","amount","parallelism","that","is","reasonable","for","the","table","and","the","maximum","amount","of","parallelism","allowed","by","the","system",".","Returns",":","A","`","BigQueryReadSession","`","Python","object","representing","the","operations","available","on","the","table","."]
code: def read_session(
      self,
      parent,
      project_id,
      table_id,
      dataset_id,
      selected_fields,
      output_types=None,
      default_values=None,
      row_restriction="",
      requested_streams=1,
      data_format: DataFormat = DataFormat.AVRO,
  ):
      """Opens a session and returns a `BigQueryReadSession` object.
  
      Args:
          parent: String of the form projects/{project_id} indicating the project
              this ReadSession is associated with. This is the project that will be
              billed for usage.
          project_id: The assigned project ID of the project.
          table_id: The ID of the table in the dataset.
          dataset_id: The ID of the dataset in the project.
          selected_fields: This can be a list or a dict. If a list, it has
              names of the fields in the table that should be read. If a dict,
              it should be in a form like, i.e:
              { "field_a_name": {"mode": "repeated", "output_type": dtypes.int64},
              "field_b_name": {"mode": "nullable", "output_type": dtypes.int32, "default_value": 0},
              ...
              "field_x_name": {"mode": "repeated", "output_type": dtypes.string, "default_value": ""}
              }
              "mode" is BigQuery column attribute, it can be 'repeated', 'nullable' or 'required'.
              The output field order is unrelated to the order of fields in
              selected_fields. If "mode" not specified, defaults to "nullable".
              If "output_type" not specified, DT_STRING is implied for all Tensors.
          output_types: Types for the output tensor in the same sequence as
              selected_fields. This is only needed when selected_fields is a list,
              if selected_fields is a dictionary, this output_types information is
              included in selected_fields as described above.
              If not specified, DT_STRING is implied for all Tensors.
          default_values: Default values to use when underlying tensor is "null"
              in the same sequence as selected_fields. If not sepecified,
              meaningful defaults are going to be used
              (0 for numerices, empty string for strings, and False for booleans).
          row_restriction: Optional. SQL text filtering statement, similar to a
              WHERE clause in a query.
          requested_streams: Desirable number of streams that can be read in parallel.
              Must be a positive number. The actual number of streams that
              BigQuery Streaming API returns may be lower than this number,
              depending on the amount parallelism that is reasonable
              for the table and the maximum amount of parallelism allowed by the
              system.
  
      Returns:
          A `BigQueryReadSession` Python object representing the
          operations available on the table.
      """
      if not isinstance(parent, str):
          raise ValueError("`parent` must be a string")
      if not parent:
          raise ValueError("`parent` must be a set")
  
      if not isinstance(project_id, str):
          raise ValueError("`project_id` must be a string")
      if not project_id:
          raise ValueError("`project_id` must be a set")
  
      if not isinstance(table_id, str):
          raise ValueError("`table_id` must be a string")
      if not table_id:
          raise ValueError("`table_id` must be a set")
  
      if not isinstance(dataset_id, str):
          raise ValueError("`dataset_id` must be a string")
      if not dataset_id:
          raise ValueError("`dataset_id` must be a set")
  
      if requested_streams is None or requested_streams <= 0:
          raise ValueError(
              "`requested_streams` must be a positive number"
          )
  
      if isinstance(selected_fields, list):
          if output_types is None:
              if not isinstance(output_types, list):
                  raise ValueError(
                      "`output_types` must be a list if selected_fields is list"
                  )
              if len(output_types) != len(selected_fields):
                  raise ValueError(
                      "length of `output_types` must be a same as the "
                      "length of `selected_fields`"
                  )
              output_types = [dtypes.string] * len(selected_fields)
          # Repeated fields are not supported if selected_fields is list
          selected_fields_repeated = [False] * len(selected_fields)
  
          if default_values is None:
              default_values = []
              for output_type in output_types:
                  default_values.append(
                      self._get_default_value_for_type(output_type)
                  )
          else:
              if not isinstance(default_values, list):
                  raise ValueError(
                      "`default_values` must be a list if selected_fields is list"
                  )
              if len(default_values) != len(selected_fields):
                  raise ValueError(
                      "length of `default_values` must be a same as the "
                      "length of `selected_fields`"
                  )
              default_values = [
                  str(default_value) for default_value in default_values
              ]
      elif isinstance(selected_fields, dict):
          _selected_fields = []
          selected_fields_repeated = []
          output_types = []
          default_values = []
          for field, field_attr_dict in selected_fields.items():
              _selected_fields.append(field)
              mode = field_attr_dict.get(
                  "mode", self.FieldMode.NULLABLE
              )
              if mode == self.FieldMode.REPEATED:
                  selected_fields_repeated.append(True)
              elif (
                  mode == self.FieldMode.NULLABLE
                  or mode == self.FieldMode.REQUIRED
              ):
                  selected_fields_repeated.append(False)
              else:
                  raise ValueError(
                      "mode needs be BigQueryClient.FieldMode.NULLABLE, FieldMode.REQUIRED or FieldMode.REPEATED"
                  )
              output_type = field_attr_dict.get(
                  "output_type", dtypes.string
              )
              output_types.append(output_type)
              if "default_value" in field_attr_dict:
                  default_value = str(field_attr_dict["default_value"])
              else:
                  default_value = self._get_default_value_for_type(
                      output_type
                  )
              default_values.append(default_value)
          selected_fields = _selected_fields
      else:
          raise ValueError("`selected_fields` must be a list or dict.")
  
      (streams, schema) = core_ops.io_big_query_read_session(
          client=self._client_resource,
          parent=parent,
          project_id=project_id,
          table_id=table_id,
          dataset_id=dataset_id,
          requested_streams=requested_streams,
          data_format=data_format.value,
          selected_fields=selected_fields,
          output_types=output_types,
          default_values=default_values,
          row_restriction=row_restriction,
      )
      return BigQueryReadSession(
          parent,
          project_id,
          table_id,
          dataset_id,
          selected_fields,
          selected_fields_repeated,
          output_types,
          default_values,
          row_restriction,
          requested_streams,
          data_format,
          streams,
          schema,
          self._client_resource,
      )
  
imports: import collections
  import enum
  import tensorflow
  from operator import itemgetter
  from tensorflow.python.data.ops import dataset_ops
  from tensorflow.python.framework import dtypes
  from tensorflow.python.framework import tensor_spec
  from tensorflow.python.util import deprecation
  from tensorflow_io.python.ops import core_ops
label_desc: Use image node_id 2 for calling the BigQueryClient obj's underlying member method code with example usage: obj.read_session(parent, project_id, table_id, dataset_id, selected_fields, output_types, default_values, row_restriction, requested_streams, data_format) and returns: BigQueryReadSession