(
scx: &StatementContext,
format: &FormatSpecifier<Aug>,
envelope: &ast::SourceEnvelope,
)
| 2242 | } |
| 2243 | |
| 2244 | fn get_encoding( |
| 2245 | scx: &StatementContext, |
| 2246 | format: &FormatSpecifier<Aug>, |
| 2247 | envelope: &ast::SourceEnvelope, |
| 2248 | ) -> Result<SourceDataEncoding<ReferencedConnection>, PlanError> { |
| 2249 | let encoding = match format { |
| 2250 | FormatSpecifier::Bare(format) => get_encoding_inner(scx, format)?, |
| 2251 | FormatSpecifier::KeyValue { key, value } => { |
| 2252 | let key = { |
| 2253 | let encoding = get_encoding_inner(scx, key)?; |
| 2254 | Some(encoding.key.unwrap_or(encoding.value)) |
| 2255 | }; |
| 2256 | let value = get_encoding_inner(scx, value)?.value; |
| 2257 | SourceDataEncoding { key, value } |
| 2258 | } |
| 2259 | }; |
| 2260 | |
| 2261 | let requires_keyvalue = matches!( |
| 2262 | envelope, |
| 2263 | ast::SourceEnvelope::Debezium | ast::SourceEnvelope::Upsert { .. } |
| 2264 | ); |
| 2265 | let is_keyvalue = encoding.key.is_some(); |
| 2266 | if requires_keyvalue && !is_keyvalue { |
| 2267 | sql_bail!("ENVELOPE [DEBEZIUM] UPSERT requires that KEY FORMAT be specified"); |
| 2268 | }; |
| 2269 | |
| 2270 | Ok(encoding) |
| 2271 | } |
| 2272 | |
| 2273 | /// Determine the cluster ID to use for this item. |
| 2274 | /// |
no test coverage detected