MCPcopy Create free account
hub / github.com/apache/datafusion / generate_schema_search_terms

Function generate_schema_search_terms

datafusion/sql/src/expr/identifier.rs:354–369  ·  view source on GitHub ↗

Possibilities we search with, in order from top to bottom for each len: len = 2: 1. (table.column) 2. (column).nested len = 3: 1. (schema.table.column) 2. (table.column).nested 3. (column).nested1.nested2 len = 4: 1. (catalog.schema.table.column) 2. (schema.table.column).nested1 3. (table.column).nested1.nested2 4. (column).nested1.nested2.nested3 len = 5: 1. (catalog.schema.table.column).nest

(
    ids: &[String],
)

Source from the content-addressed store, hash-verified

352// 3. (table.column).nested1.nested2.nested3[.nestedN]+
353// 4. (column).nested1.nested2.nested3.nested4[.nestedN]+
354fn generate_schema_search_terms(
355 ids: &[String],
356) -> impl Iterator<Item = (Option<TableReference>, &String, &[String])> {
357 // Take at most 4 identifiers to form a Column to search with
358 // - 1 for the column name
359 // - 0 to 3 for the TableReference
360 let bound = ids.len().min(4);
361 // Search terms from most specific to least specific
362 (0..bound).rev().map(|i| {
363 let nested_names_index = i + 1;
364 let qualifier_and_column = &ids[0..nested_names_index];
365 // Safe unwrap as qualifier_and_column can never be empty or exceed the bounds
366 let (relation, column_name) = form_identifier(qualifier_and_column).unwrap();
367 (relation, column_name, &ids[nested_names_index..])
368 })
369}
370
371#[cfg(test)]
372mod test {

Callers 2

search_dfschemaFunction · 0.85

Calls 4

form_identifierFunction · 0.85
minMethod · 0.45
lenMethod · 0.45
mapMethod · 0.45

Tested by 1

Used in the wild real call sites across dependent graphs

searching dependent graphs…