examples/text_to_sql/RAT-SQL/evaluation/text2sql_evaluation.py
def parse_col(toks, start_idx, tables_with_alias, schema, default_tables=None):
    """
        :returns next idx, column id
    """
    tok = toks[start_idx]
    if tok == "*":
        return start_idx + 1, schema.id_map[tok]
    if tok in CONST_COLUMN:
        return start_idx + 1, tok

    if '.' in tok:  # if token is a composite
        alias, col = tok.split('.')
        key = tables_with_alias[alias] + "." + col
        return start_idx + 1, schema.id_map[key]

    assert default_tables is not None and len(
        default_tables) > 0, "Default tables should not be None or empty"

    for alias in default_tables:
        table = tables_with_alias[alias]
        if tok in schema.schema[table]:
            key = table + "." + tok
            return start_idx + 1, schema.id_map[key]

    raise RuntimeError("Error col: {},{}".format(tok, toks))

        :returns next idx, column id
    
:returns next idx, column id
: returns next idx column id
def parse_col(toks, start_idx, tables_with_alias, schema, default_tables=None):
    tok = toks[start_idx]
    if tok == "*":
        return start_idx + 1, schema.id_map[tok]
    if tok in CONST_COLUMN:
        return start_idx + 1, tok
    if '.' in tok:  
        alias, col = tok.split('.')
        key = tables_with_alias[alias] + "." + col
        return start_idx + 1, schema.id_map[key]
    assert default_tables is not None and len(
        default_tables) > 0, "Default tables should not be None or empty"
    for alias in default_tables:
        table = tables_with_alias[alias]
        if tok in schema.schema[table]:
            key = table + "." + tok
            return start_idx + 1, schema.id_map[key]
    raise RuntimeError("Error col: {},{}".format(tok, toks))
def parse_col ( toks , start_idx , tables_with_alias , schema , default_tables = None ) : tok = toks [ start_idx ] if tok == "*" : return start_idx + 1 , schema . id_map [ tok ] if tok in CONST_COLUMN : return start_idx + 1 , tok if '.' in tok : alias , col = tok . split ( '.' ) key = tables_with_alias [ alias ] + "." + col return start_idx + 1 , schema . id_map [ key ] assert default_tables is not None and len ( default_tables ) > 0 , "Default tables should not be None or empty" for alias in default_tables : table = tables_with_alias [ alias ] if tok in schema . schema [ table ] : key = table + "." + tok return start_idx + 1 , schema . id_map [ key ] raise RuntimeError ( "Error col: {},{}" . format ( tok , toks ) )
:returns next idx, column id
: returns next idx column id
"""
        :returns next idx, column id
    """ # if token is a composite
toks
start_idx
tables_with_alias
schema
default_tables