MCPcopy Create free account
hub / github.com/MaterializeInc/materialize / parse_long

Method parse_long

src/avro/src/schema.rs:1380–1410  ·  view source on GitHub ↗

Parse a [`serde_json::Value`] representing an Avro Int64/Long type The debezium/kafka types are document at [the debezium site][1], and the avro ones are documented at [Avro][2]. [1]: https://debezium.io/docs/connectors/mysql/#temporal-values [2]: https://avro.apache.org/docs/++version++/specification/

(complex: &Map<String, Value>)

Source from the content-addressed store, hash-verified

1378 /// [1]: https://debezium.io/docs/connectors/mysql/#temporal-values
1379 /// [2]: https://avro.apache.org/docs/++version++/specification/
1380 fn parse_long(complex: &Map<String, Value>) -> Result<SchemaPiece, AvroError> {
1381 const AVRO_MILLI_TS: &str = "timestamp-millis";
1382 const AVRO_MICRO_TS: &str = "timestamp-micros";
1383
1384 const CONNECT_MILLI_TS: &[&str] = &[
1385 "io.debezium.time.Timestamp",
1386 "org.apache.kafka.connect.data.Timestamp",
1387 ];
1388 const CONNECT_MICRO_TS: &str = "io.debezium.time.MicroTimestamp";
1389
1390 if let Some(serde_json::Value::String(name)) = complex.get("connect.name") {
1391 if CONNECT_MILLI_TS.contains(&&**name) {
1392 return Ok(SchemaPiece::TimestampMilli);
1393 }
1394 if name == CONNECT_MICRO_TS {
1395 return Ok(SchemaPiece::TimestampMicro);
1396 }
1397 }
1398 if let Some(name) = complex.get("logicalType") {
1399 if name == AVRO_MILLI_TS {
1400 return Ok(SchemaPiece::TimestampMilli);
1401 }
1402 if name == AVRO_MICRO_TS {
1403 return Ok(SchemaPiece::TimestampMicro);
1404 }
1405 }
1406 if !complex.is_empty() {
1407 debug!("parsing complex type as regular long: {:?}", complex);
1408 }
1409 Ok(SchemaPiece::Long)
1410 }
1411
1412 fn from_string(complex: &Map<String, Value>) -> SchemaPiece {
1413 const CONNECT_JSON: &str = "io.debezium.data.Json";

Callers

nothing calls this directly

Calls 3

getMethod · 0.45
containsMethod · 0.45
is_emptyMethod · 0.45

Tested by

no test coverage detected