def _get_tables(tokens):
  """Adds table(s) in sqlparse.sql.Token as SqlTable to sql_tables."""
  sql_tables = []
  table_names = set()
  previous_token = None
  in_from_clause_context = False
  for token in tokens:
    # Don't recurse into nested statements.
    if isinstance(token, list):
      continue
    elif _is_underspecified_table_mention(previous_token, token):
      for token_value in token.value.split(' '):
        sql_table = _get_sql_table(token_value)
        if sql_table.table_name in table_names:
          raise UnsupportedSqlError(
              'Abstract SQL does not support joining a table with itself!')
        table_names.add(sql_table.table_name)
        sql_tables.append(sql_table)
    elif _is_table_mention(previous_token, token, in_from_clause_context):
      in_from_clause_context = True
      sql_table = _get_sql_table(token.value)
      if sql_table.table_name in table_names:
        raise UnsupportedSqlError(
            'Abstract SQL does not support joining a table with itself!')
      table_names.add(sql_table.table_name)
      sql_tables.append(sql_table)
    elif token.value != ',':
      in_from_clause_context = False
    previous_token = token
  return sql_tables
Adds table(s) in sqlparse.sql.Token as SqlTable to sql_tables.
language/xsp/data_preprocessing/abstract_sql.py