def _get_sql_column(column_token, tables, aliases_to_table_names,
                    table_schemas):
  """Returns SqlColumn tuple for the given column_token string."""
  # Check if token has alias.
  column_token = column_token.lower()

  if '.' in column_token:
    splits = column_token.split('.')
    if len(splits) != 2:
      raise ParseError('Unexpected token: %s' % column_token)
    if splits[0] in aliases_to_table_names:
      table_name = aliases_to_table_names[splits[0]].lower()
      return SqlColumn(column_name=splits[1], table_name=table_name)
    else:
      # Assume splits[0] is a table name.
      return SqlColumn(column_name=splits[1], table_name=splits[0].lower())
  else:
    # No prefix, check if there is only one table in statement.
    if len(tables) == 1:
      table_name = tables[0].table_name.lower()
      return SqlColumn(column_name=column_token, table_name=table_name)
    else:
      # Need to use schema information to disambiguate.
      if table_schemas is None:
        raise ParseError('Column name %s requires disambiguating between '
                         'tables %s using schema, but no schema provided.' %
                         (column_token, tables))
      table_name = _find_table_name_for_column(column_token, tables,
                                               table_schemas)
      if not table_name:
        raise UnsupportedSqlError('Unexpected tables %s given column token %s' %
                                  (tables, column_token))
      return SqlColumn(column_name=column_token, table_name=table_name.lower())
Returns SqlColumn tuple for the given column_token string.
language/xsp/data_preprocessing/abstract_sql.py