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

Method new

crates/paimon/src/table/data_evolution_writer.rs:72–120  ·  view source on GitHub ↗

Create a new writer for the given table and update columns. Validates: - `data-evolution.enabled = true` - `row-tracking.enabled = true` - No primary keys - Update columns don't include partition keys

(table: &Table, update_columns: Vec<String>)

Source from the content-addressed store, hash-verified

70 /// - No primary keys
71 /// - Update columns don't include partition keys
72 pub fn new(table: &Table, update_columns: Vec<String>) -> Result<Self> {
73 let schema = table.schema();
74 let core_options = CoreOptions::new(schema.options());
75
76 if !core_options.data_evolution_enabled() {
77 return Err(crate::Error::Unsupported {
78 message:
79 "MERGE INTO is only supported for tables with 'data-evolution.enabled' = 'true'"
80 .to_string(),
81 });
82 }
83 if !core_options.row_tracking_enabled() {
84 return Err(crate::Error::Unsupported {
85 message: "MERGE INTO requires 'row-tracking.enabled' = 'true'".to_string(),
86 });
87 }
88 if !schema.trimmed_primary_keys().is_empty() {
89 return Err(crate::Error::Unsupported {
90 message: "MERGE INTO on data evolution tables does not support primary keys"
91 .to_string(),
92 });
93 }
94
95 let partition_keys = schema.partition_keys();
96 let blob_descriptor_fields = core_options.blob_descriptor_fields();
97 for col in &update_columns {
98 if partition_keys.contains(col) {
99 return Err(crate::Error::Unsupported {
100 message: format!("Cannot update partition column '{col}' in MERGE INTO"),
101 });
102 }
103 if let Some(field) = schema.fields().iter().find(|f| f.name() == col) {
104 if field.data_type().is_blob_type() && !blob_descriptor_fields.contains(col) {
105 return Err(crate::Error::Unsupported {
106 message: format!(
107 "Cannot update raw-data BLOB column '{col}' in MERGE INTO. \
108 Only BLOB columns listed in 'blob-descriptor-field' can be updated"
109 ),
110 });
111 }
112 }
113 }
114
115 Ok(Self {
116 table: table.clone(),
117 update_columns,
118 matched_batches: Vec::new(),
119 })
120 }
121
122 /// Add a batch of matched rows.
123 ///

Callers

nothing calls this directly

Calls 15

row_tracking_enabledMethod · 0.80
trimmed_primary_keysMethod · 0.80
partition_keysMethod · 0.80
containsMethod · 0.80
is_blob_typeMethod · 0.80
data_typeMethod · 0.80
to_vecMethod · 0.80
legacy_partition_nameMethod · 0.80
target_file_sizeMethod · 0.80

Tested by

no test coverage detected