def _get_all_aliases(sql, example):
  """Returns a dictionary of aliases for the tables."""
  root = sql
  while True:
    if root.parent is None:
      break
    root = root.parent

  aliases = {}
  for item in _iterate_sql(root):
    if not _is_table_alias(item):
      continue

    tokens = _get_tokens(item.parent.parent)
    if len(tokens) == 3 and tokens[1].value.lower() == 'as':
      table_annotation = _find_table_annotation(tokens[0], example)
      aliases[tokens[2].value.lower()] = table_annotation

  return aliases
Returns a dictionary of aliases for the tables.
language/xsp/data_preprocessing/sql_parsing.py