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

Function object_name_to_qualifier

datafusion/sql/src/planner.rs:1014–1044  ·  view source on GitHub ↗

Construct a WHERE qualifier suitable for e.g. information_schema filtering from the provided object identifiers (catalog, schema and table names).

(
    sql_table_name: &ObjectName,
    enable_normalization: bool,
)

Source from the content-addressed store, hash-verified

1012/// Construct a WHERE qualifier suitable for e.g. information_schema filtering
1013/// from the provided object identifiers (catalog, schema and table names).
1014pub fn object_name_to_qualifier(
1015 sql_table_name: &ObjectName,
1016 enable_normalization: bool,
1017) -> Result<String> {
1018 let columns = vec!["table_name", "table_schema", "table_catalog"].into_iter();
1019 let normalizer = IdentNormalizer::new(enable_normalization);
1020 sql_table_name
1021 .0
1022 .iter()
1023 .rev()
1024 .zip(columns)
1025 .map(|(object_name_part, column_name)| {
1026 object_name_part
1027 .as_ident()
1028 .map(|ident| {
1029 format!(
1030 r#"{} = '{}'"#,
1031 column_name,
1032 normalizer.normalize(ident.clone())
1033 )
1034 })
1035 .ok_or_else(|| {
1036 plan_datafusion_err!(
1037 "Expected identifier, but found: {:?}",
1038 object_name_part
1039 )
1040 })
1041 })
1042 .collect::<Result<Vec<_>>>()
1043 .map(|parts| parts.join(" AND "))
1044}

Callers 2

show_columns_to_planMethod · 0.85

Calls 6

newFunction · 0.85
as_identMethod · 0.80
into_iterMethod · 0.45
mapMethod · 0.45
iterMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…