(
&self,
catalog: &Arc<dyn Catalog>,
name: &ObjectName,
operations: &[AlterTableOperation],
if_exists: bool,
)
| 805 | } |
| 806 | |
| 807 | async fn handle_alter_table( |
| 808 | &self, |
| 809 | catalog: &Arc<dyn Catalog>, |
| 810 | name: &ObjectName, |
| 811 | operations: &[AlterTableOperation], |
| 812 | if_exists: bool, |
| 813 | ) -> DFResult<DataFrame> { |
| 814 | let identifier = self.resolve_table_name(name)?; |
| 815 | |
| 816 | let mut changes = Vec::new(); |
| 817 | let mut rename_to: Option<Identifier> = None; |
| 818 | |
| 819 | for op in operations { |
| 820 | match op { |
| 821 | AlterTableOperation::AddColumn { column_def, .. } => { |
| 822 | let change = column_def_to_add_column(column_def)?; |
| 823 | changes.push(change); |
| 824 | } |
| 825 | AlterTableOperation::DropColumn { |
| 826 | column_names, |
| 827 | if_exists: _, |
| 828 | .. |
| 829 | } => { |
| 830 | for col in column_names { |
| 831 | changes.push(SchemaChange::drop_column(col.value.clone())); |
| 832 | } |
| 833 | } |
| 834 | AlterTableOperation::RenameColumn { |
| 835 | old_column_name, |
| 836 | new_column_name, |
| 837 | } => { |
| 838 | changes.push(SchemaChange::rename_column( |
| 839 | old_column_name.value.clone(), |
| 840 | new_column_name.value.clone(), |
| 841 | )); |
| 842 | } |
| 843 | AlterTableOperation::RenameTable { table_name } => { |
| 844 | let new_name = match table_name { |
| 845 | RenameTableNameKind::To(name) | RenameTableNameKind::As(name) => { |
| 846 | object_name_to_string(name) |
| 847 | } |
| 848 | }; |
| 849 | rename_to = Some(Identifier::new(identifier.database().to_string(), new_name)); |
| 850 | } |
| 851 | AlterTableOperation::SetTblProperties { table_properties } => { |
| 852 | for opt in table_properties { |
| 853 | if let SqlOption::KeyValue { key, value } = opt { |
| 854 | let v = value.to_string(); |
| 855 | let v = v |
| 856 | .strip_prefix('\'') |
| 857 | .and_then(|s| s.strip_suffix('\'')) |
| 858 | .unwrap_or(&v) |
| 859 | .to_string(); |
| 860 | changes.push(SchemaChange::set_option(key.value.clone(), v)); |
| 861 | } |
| 862 | } |
| 863 | } |
| 864 | AlterTableOperation::DropPartitions { |
no test coverage detected