def _get_from_clause_for_tables(table_names, fk_relations):
  """Returns list of SqlSpan tuples for FROM clause."""
  visited_tables, fk_relations = _get_fk_relations_linking_tables(
      table_names, fk_relations)
  sql_spans = []
  sql_spans.append(make_sql_span(table_name=visited_tables[0]))
  for i in range(len(visited_tables) - 1):
    table_a = visited_tables[i]
    table_b = visited_tables[i + 1]
    column_a, column_b = fk_relations[i]
    # join table_b on table_a.column_a = table_b.column_b
    sql_spans.append(make_sql_span(sql_token='join'))
    sql_spans.append(make_sql_span(table_name=table_b))
    sql_spans.append(make_sql_span(sql_token='on'))
    sql_spans.append(
        make_sql_span(
            column=SqlColumn(column_name=column_a, table_name=table_a)))
    sql_spans.append(make_sql_span(sql_token='='))
    sql_spans.append(
        make_sql_span(
            column=SqlColumn(column_name=column_b, table_name=table_b)))
  return sql_spans
Returns list of SqlSpan tuples for FROM clause.
language/xsp/data_preprocessing/abstract_sql.py