class_docstr: The GitHub Issue Table implementation
class_docstr_tok: ["The","GitHub","Issue","Table","implementation"]
docstr: Pulls data from the GitHub "List repository pull requests" API
  
  Parameters
  ----------
  query : ast.Select
     Given SQL SELECT query
  
  Returns
  -------
  pd.DataFrame
      GitHub pull requests matching the query
  
  Raises
  ------
  ValueError
      If the query contains an unsupported condition
docstr_tok: ["Pulls","data","from","the","GitHub","``","List","repository","pull","requests","''","API","Parameters","--","--","--","--","--","query",":","ast.Select","Given","SQL","SELECT","query","Returns","--","--","--","-","pd.DataFrame","GitHub","pull","requests","matching","the","query","Raises","--","--","--","ValueError","If","the","query","contains","an","unsupported","condition"]
code: def select(self, query: ast.Select) -> pd.DataFrame:
      """Pulls data from the GitHub "List repository pull requests" API
  
      Parameters
      ----------
      query : ast.Select
         Given SQL SELECT query
  
      Returns
      -------
      pd.DataFrame
          GitHub pull requests matching the query
  
      Raises
      ------
      ValueError
          If the query contains an unsupported condition
      """
  
      conditions = extract_comparison_conditions(query.where)
  
      if query.limit:
          total_results = query.limit.value
      else:
          total_results = 20
  
      issues_kwargs = {}
      order_by_conditions = {}
  
      if query.order_by and len(query.order_by) > 0:
          order_by_conditions["columns"] = []
          order_by_conditions["ascending"] = []
  
          for an_order in query.order_by:
              if an_order.field.parts[0] != "pull_requests":
                  next
  
              if an_order.field.parts[1] in [
                  "created",
                  "updated",
                  "popularity",
              ]:
                  if issues_kwargs != {}:
                      raise ValueError(
                          "Duplicate order conditions found for created/updated/popularity"
                      )
  
                  issues_kwargs["sort"] = an_order.field.parts[1]
                  issues_kwargs["direction"] = an_order.direction
              elif an_order.field.parts[1] == "long_running":
                  if issues_kwargs != {}:
                      raise ValueError(
                          "Duplicate order conditions found for long_running"
                      )
  
                  issues_kwargs["sort"] = "long-running"
                  issues_kwargs["direction"] = an_order.direction
              elif an_order.field.parts[1] in self.get_columns():
                  order_by_conditions["columns"].append(
                      an_order.field.parts[1]
                  )
  
                  if an_order.direction == "ASC":
                      order_by_conditions["ascending"].append(True)
                  else:
                      order_by_conditions["ascending"].append(False)
              else:
                  raise ValueError(
                      f"Order by unknown column {an_order.field.parts[1]}"
                  )
  
      for a_where in conditions:
          if a_where[1] == "state":
              if a_where[0] != "=":
                  raise ValueError(
                      "Unsupported where operation for state"
                  )
              if a_where[2] not in ["open", "closed", "all"]:
                  raise ValueError(
                      f"Unsupported where argument for state {a_where[2]}"
                  )
  
              issues_kwargs["state"] = a_where[2]
  
              continue
          if a_where[1] in ["head", "base"]:
              if a_where[0] != "=":
                  raise ValueError(
                      f"Unsupported where operation for {a_where[1]}"
                  )
  
              issues_kwargs[a_where[1]] = a_where[2]
          else:
              raise ValueError(
                  f"Unsupported where argument {a_where[1]}"
              )
  
      self.handler.connect()
  
      github_pull_requests_df = pd.DataFrame(columns=self.get_columns())
  
      start = 0
  
      while True:
          try:
              for a_pull in self.handler.connection.get_repo(
                  self.handler.repository
              ).get_pulls(**issues_kwargs)[start : start + 10]:
                  github_pull_requests_df = pd.concat(
                      [
                          github_pull_requests_df,
                          pd.DataFrame(
                              [
                                  {
                                      "number": a_pull.number,
                                      "title": a_pull.title,
                                      "state": a_pull.state,
                                      "creator": a_pull.user.login,
                                      "labels": ",".join(
                                          [
                                              label.name
                                              for label in a_pull.labels
                                          ]
                                      ),
                                      "milestone": a_pull.milestone.title
                                      if a_pull.milestone
                                      else None,
                                      "assignees": ",".join(
                                          [
                                              assignee.login
                                              for assignee in a_pull.assignees
                                          ]
                                      ),
                                      "reviewers": ",".join(
                                          [
                                              reviewer.login
                                              for reviewer in a_pull.requested_reviewers
                                          ]
                                      ),
                                      "teams": ",".join(
                                          [
                                              team.name
                                              for team in a_pull.requested_teams
                                          ]
                                      ),
                                      "comments": a_pull.comments,
                                      "review_comments": a_pull.review_comments,
                                      "draft": a_pull.draft,
                                      "is_merged": a_pull.merged,
                                      "mergeable": a_pull.mergeable,
                                      "mergeable_state": a_pull.mergeable_state,
                                      "merged_by": a_pull.merged_by.login
                                      if a_pull.merged_by
                                      else None,
                                      "rebaseable": a_pull.rebaseable,
                                      "body": a_pull.body,
                                      "base": a_pull.base.ref
                                      if a_pull.base
                                      else None,
                                      "head": a_pull.head.ref
                                      if a_pull.head
                                      else None,
                                      "commits": a_pull.commits,
                                      "additions": a_pull.additions,
                                      "deletions": a_pull.deletions,
                                      "changed_files": a_pull.changed_files,
                                      "created": a_pull.created_at,
                                      "updated": a_pull.updated_at,
                                      "merged": a_pull.merged_at,
                                      "closed": a_pull.closed_at,
                                  }
                              ]
                          ),
                      ]
                  )
  
                  if github_pull_requests_df.shape[0] >= total_results:
                      break
          except IndexError:
              break
  
          if github_pull_requests_df.shape[0] >= total_results:
              break
          else:
              start += 10
  
      selected_columns = []
      for target in query.targets:
          if isinstance(target, ast.Star):
              selected_columns = self.get_columns()
              break
          elif isinstance(target, ast.Identifier):
              selected_columns.append(target.parts[-1])
          else:
              raise ValueError(f"Unknown query target {type(target)}")
  
      if len(github_pull_requests_df) == 0:
          github_pull_requests_df = pd.DataFrame(
              [], columns=selected_columns
          )
      else:
          github_pull_requests_df.columns = self.get_columns()
          for col in set(github_pull_requests_df.columns).difference(
              set(selected_columns)
          ):
              github_pull_requests_df = github_pull_requests_df.drop(
                  col, axis=1
              )
  
          if len(order_by_conditions.get("columns", [])) > 0:
              github_pull_requests_df = (
                  github_pull_requests_df.sort_values(
                      by=order_by_conditions["columns"],
                      ascending=order_by_conditions["ascending"],
                  )
              )
  
      return github_pull_requests_df
  
imports: import pandas
  from typing import List
  from mindsdb.integrations.libs.api_handler import APITable
  from mindsdb.integrations.handlers.utilities.query_utilities import SELECTQueryParser, SELECTQueryExecutor
  from mindsdb.integrations.utilities.sql_utils import extract_comparison_conditions
  from mindsdb.utilities import log
  from mindsdb_sql.parser import ast
label_desc: Use image node_id 1 for calling the GithubPullRequestsTable obj's underlying member method code with example usage: obj.select(query) and returns: github_pull_requests_df