class_docstr: The GitHub Commits Table implementation
class_docstr_tok: ["The","GitHub","Commits","Table","implementation"]
docstr: Pulls data from the GitHub "List commits" API
  
  Parameters
  ----------
  query : ast.Select
     Given SQL SELECT query
  
  Returns
  -------
  pd.DataFrame
  
      GitHub commits matching the query
  
  Raises
  ------
  ValueError
      If the query contains an unsupported condition
docstr_tok: ["Pulls","data","from","the","GitHub","``","List","commits","''","API","Parameters","--","--","--","--","--","query",":","ast.Select","Given","SQL","SELECT","query","Returns","--","--","--","-","pd.DataFrame","GitHub","commits","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 commits" API
  
      Parameters
      ----------
      query : ast.Select
         Given SQL SELECT query
  
      Returns
      -------
      pd.DataFrame
  
          GitHub commits 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
  
      commits_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] != "commits":
                  next
  
              if an_order.field.parts[1] in [
                  "author",
                  "date",
                  "message",
              ]:
                  if commits_kwargs != {}:
                      raise ValueError(
                          "Duplicate order conditions found for author/date/message"
                      )
  
                  commits_kwargs["sort"] = an_order.field.parts[1]
                  commits_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] == "author":
              if a_where[0] != "=":
                  raise ValueError(
                      "Unsupported where operation for author"
                  )
              commits_kwargs["author"] = a_where[2]
          else:
              raise ValueError(
                  f"Unsupported where argument {a_where[1]}"
              )
  
      self.handler.connect()
  
      github_commits_df = pd.DataFrame(columns=self.get_columns())
  
      start = 0
  
      while True:
          try:
              for a_commit in self.handler.connection.get_repo(
                  self.handler.repository
              ).get_commits(**commits_kwargs)[start : start + 10]:
                  logger.debug(f"Processing commit {a_commit.sha}")
  
                  github_commits_df = pd.concat(
                      [
                          github_commits_df,
                          pd.DataFrame(
                              [
                                  {
                                      "sha": a_commit.sha,
                                      "author": a_commit.commit.author.name,
                                      "date": a_commit.commit.author.date,
                                      "message": a_commit.commit.message,
                                  }
                              ]
                          ),
                      ]
                  )
  
                  if github_commits_df.shape[0] >= total_results:
                      break
          except IndexError:
              break
  
          if github_commits_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_commits_df) == 0:
          github_commits_df = pd.DataFrame([], columns=selected_columns)
      else:
          github_commits_df.columns = self.get_columns()
          for col in set(github_commits_df.columns).difference(
              set(selected_columns)
          ):
              github_commits_df = github_commits_df.drop(col, axis=1)
  
          if len(order_by_conditions.get("columns", [])) > 0:
              github_commits_df = github_commits_df.sort_values(
                  by=order_by_conditions["columns"],
                  ascending=order_by_conditions["ascending"],
              )
  
      return github_commits_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 GithubCommitsTable obj's underlying member method code with example usage: obj.select(query) and returns: github_commits_df