b4562327a4554689d8ab0906c605476ccf817336,language/xsp/data_preprocessing/abstract_sql.py,,_get_from_clause_for_tables,#Any#Any#,549

Before Change


  Returns list of SqlSpan tuples for FROM clause.
  if not table_names:
    raise ParseError("No table names provided.")
  if len(table_names) == 1:
    return [make_sql_span(table_name=table_names[0])]

  // Map of (table_a, table_b) to (column_a, column_b)
  fk_relations_map = {}
  for relation in fk_relations:
    fk_relations_map[(relation.child_table,
                      relation.parent_table)] = (relation.child_column,
                                                 relation.parent_column)
    // Also add the reverse.
    fk_relations_map[(relation.parent_table,
                      relation.child_table)] = (relation.parent_column,
                                                relation.child_column)

  // Naively try every permutation of table_names until we get a hit.
  // TODO(petershaw): Could probably speed up this up quite a bit and provide
  // better error handling for ambiguous cases.

After Change


  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


def _get_all_table_names(sql_spans):
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 9

Instances


Project Name: google-research/language
Commit Name: b4562327a4554689d8ab0906c605476ccf817336
Time: 2019-11-15
Author: kentonl@google.com
File Name: language/xsp/data_preprocessing/abstract_sql.py
Class Name:
Method Name: _get_from_clause_for_tables


Project Name: ilastik/ilastik
Commit Name: 23bf9b02f92cbebc772fe0574b69a598aa3cd367
Time: 2015-11-25
Author: bergs@janelia.hhmi.org
File Name: ilastik/applets/featureSelection/featureSelectionSerializer.py
Class Name: FeatureSelectionSerializer
Method Name: _serializeToHdf5


Project Name: uber/ludwig
Commit Name: e0008f1fc54b5917f5505c2913ffae93bff8e87d
Time: 2020-09-20
Author: w4nderlust@gmail.com
File Name: tests/integration_tests/test_validation_metrics.py
Class Name:
Method Name: test_validation_metrics