MCPcopy Create free account
hub / github.com/apache/paimon-rust / apply_changes

Method apply_changes

crates/paimon/src/spec/schema.rs:130–152  ·  view source on GitHub ↗

Apply a list of schema changes and return a new schema with incremented ID.

(&self, changes: Vec<crate::spec::SchemaChange>)

Source from the content-addressed store, hash-verified

128
129 /// Apply a list of schema changes and return a new schema with incremented ID.
130 pub fn apply_changes(&self, changes: Vec<crate::spec::SchemaChange>) -> crate::Result<Self> {
131 let mut new_schema = self.clone();
132 new_schema.id += 1;
133 new_schema.time_millis = chrono::Utc::now().timestamp_millis();
134
135 for change in changes {
136 match change {
137 crate::spec::SchemaChange::SetOption { key, value } => {
138 new_schema.options.insert(key, value);
139 }
140 crate::spec::SchemaChange::RemoveOption { key } => {
141 new_schema.options.remove(&key);
142 }
143 other => {
144 return Err(crate::Error::Unsupported {
145 message: format!("Schema change not yet supported: {other:?}"),
146 });
147 }
148 }
149 }
150
151 Ok(new_schema)
152 }
153
154 pub fn comment(&self) -> Option<&str> {
155 self.comment.as_deref()

Callers 1

alter_tableMethod · 0.80

Calls 2

insertMethod · 0.80
removeMethod · 0.80

Tested by

no test coverage detected