def copy_table_regex(bq_client, dataset, dest, table_name_pattern):
  """Copy the tables with the name that matches certern regex pattern.
  """
  table_list = table_list_handler.list_regex_table(
      bq_client,
      dataset,
      table_name_pattern,
      sys.maxint)
  _copy_table_list(bq_client, dataset, dest, table_list)
def delete_table_with_regex(bq_client, dataset, table_name_pattern,
                            ignore_confirm=False):
  """Delete all the tables that match given regex pattern.
  """
  table_list = table_list_handler.list_regex_table(bq_client,
                                                   dataset,
                                                   table_name_pattern,
                                                   sys.maxint)
  _delete_table_list(bq_client, dataset, table_list, ignore_confirm)
Example #3
0
def list_table(list_command):
  dataset = list_command.dataset
  limit = list_command.limit

  if isinstance(list_command, ListCommand):
    return table_list_handler.list_all_table(GOOGLE_BIGQUERY_CLIENT,
                                             dataset,
                                             limit)
  elif isinstance(list_command, ListRegexCommand):
    return table_list_handler.list_regex_table(GOOGLE_BIGQUERY_CLIENT,
                                               dataset,
                                               list_command.table_name_pattern,
                                               limit)
  elif isinstance(list_command, ListWildcardCommand):
    return table_list_handler.list_wildcard_table(GOOGLE_BIGQUERY_CLIENT,
                                                  dataset,
                                                  list_command.table_prefix,
                                                  list_command.start_date,
                                                  list_command.end_date,
                                                  limit)
  else:
    raise ValueError("Unrecognised command type.")
def delete_data_with_regex(bq_client, dataset, condition, table_name_pattern):
    """Delete all the tables that match given regex pattern.
  """
    table_list = table_list_handler.list_regex_table(bq_client, dataset, table_name_pattern, sys.maxint)
    __delete_data_process(bq_client, dataset, condition, table_list)