| 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 |