MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / merge_source_alias

Function merge_source_alias

nodedb-sql/src/planner/merge.rs:136–158  ·  view source on GitHub ↗

Determine the alias used to qualify source-column references in WHEN arms.

(factor: &ast::TableFactor, source_plan: &SqlPlan)

Source from the content-addressed store, hash-verified

134
135/// Determine the alias used to qualify source-column references in WHEN arms.
136fn merge_source_alias(factor: &ast::TableFactor, source_plan: &SqlPlan) -> String {
137 match factor {
138 ast::TableFactor::Table { name, alias, .. } => alias
139 .as_ref()
140 .map(|a| normalize_ident(&a.name))
141 .unwrap_or_else(|| {
142 normalize_object_name_checked(name).unwrap_or_else(|_| "source".to_string())
143 }),
144 ast::TableFactor::Derived { alias, .. } => alias
145 .as_ref()
146 .map(|a| normalize_ident(&a.name))
147 .unwrap_or_else(|| "source".to_string()),
148 _ => match source_plan {
149 SqlPlan::Scan {
150 collection: _,
151 alias: Some(a),
152 ..
153 } => a.clone(),
154 SqlPlan::Scan { collection, .. } => collection.clone(),
155 _ => "source".to_string(),
156 },
157 }
158}
159
160// ── ON clause parsing ──────────────────────────────────────────────────────
161

Callers 1

plan_mergeFunction · 0.85

Calls 5

normalize_identFunction · 0.85
to_stringMethod · 0.80
as_refMethod · 0.45
cloneMethod · 0.45

Tested by

no test coverage detected