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

Method col_alias_overrides

datafusion/sql/src/unparser/dialect.rs:662–683  ·  view source on GitHub ↗
(&self, alias: &str)

Source from the content-addressed store, hash-verified

660 }
661
662 fn col_alias_overrides(&self, alias: &str) -> Result<Option<String>> {
663 // Check if alias contains any special characters not supported by BigQuery col names
664 // https://cloud.google.com/bigquery/docs/schemas#flexible-column-names
665 let special_chars: [char; 20] = [
666 '!', '"', '$', '(', ')', '*', ',', '.', '/', ';', '?', '@', '[', '\\', ']',
667 '^', '`', '{', '}', '~',
668 ];
669
670 if alias.chars().any(|c| special_chars.contains(&c)) {
671 let mut encoded_name = String::new();
672 for c in alias.chars() {
673 if special_chars.contains(&c) {
674 encoded_name.push_str(&format!("_{}", c as u32));
675 } else {
676 encoded_name.push(c);
677 }
678 }
679 Ok(Some(encoded_name))
680 } else {
681 Ok(Some(alias.to_string()))
682 }
683 }
684
685 fn unnest_as_table_factor(&self) -> bool {
686 true

Callers 2

select_item_to_sqlMethod · 0.45
col_to_sqlMethod · 0.45

Calls 5

newFunction · 0.85
anyMethod · 0.45
containsMethod · 0.45
pushMethod · 0.45
to_stringMethod · 0.45

Tested by

no test coverage detected