avro中的字节格式

时间:2018-09-04 12:47:44

标签: oracle11g apache-kafka avro confluent confluent-schema-registry

在使用融合版5.0.0将Oracle表加载到Kafka时,如何停止将数字转换为字节格式?在重新使用代理中的数据时,转换为字节会产生很多问题。是否可以在vertica db中直接将字节格式转换为十进制?

更多详细信息: 每次我从oracle向Kafa发送表时,数字类型都会转换为字节,而日期类型转换为long。当我使用KafkaSource和KafkaAvroParser将数据加载到vertica时,数据不会被解码回去。

有没有一种方法可以在融合版本5.0.0中的schema-registry中编辑schema formate

详细信息:

curl -X GET http://localhost:8081/subjects/test-oracle-jdbc-EMP1-value/versions/1

{“ subject”:“ test-oracle-jdbc-EMP1-value”,“ version”:1,“ id”:2,“ schema”:“ {\” type \“:\” record \“, \“名称\”:\“ EMP1 \”,\“字段\”:[{\“名称\”:\“ EMPNO \”,\“类型\”:{\“类型\”:\“字节\” ,\“ scale \”:0,\“ precision \”:64,\“ connect.version \”:1,\“ connect.parameters \”:{\“ scale \”:\“ 0 \”},\ “ connect.name \”:\“ org.apache.kafka.connect.data.Decimal \”,\“ logicalType \”:\“ decimal \”}}},{\“ name \”:\“ ENAME \”, \“ type \”:[\“ null \”,\“ string \”],\“ default \”:null},{\“ name \”:\“ JOB \”,\“ type \”:[\ “ null \”,\“ string \”],\“ default \”:null},{\“ name \”:\“ MGR \”,\“ type \”:[\“ null \”,{\“ type \“:\” bytes \“,\” scale \“:0,\” precision \“:64,\” connect.version \“:1,\” connect.parameters \“:{\” scale \“ :\“ 0 \”},\“ connect.name \”:\“ org.apache.kafka.connect.data.Decimal \”,\“ logicalType \”:\“ decimal \”}}],\“ default \ “:null},{\” name \“:\” HIREDATE \“,\” type \“:[\” null \“,{\” type \“:\” long \“,\” connect.version \ “:1,\” connect.name \“:\” org.apache.kafka.connect.data.Timestamp \“,\” logicalType \“:\” timestamp-millis \“}}],\”默认\“: null},{\“ name \”:\“ SAL \”,\“ type \”:[\“ null \”,{\“ type \”:\“ byte s \“,\” scale \“:2,\” precision \“:64,\” connect.version \“:1,\” connect.parameters \“:{\” scale \“:\” 2 \“ },\“ connect.name \”:\“ org.apache.kafka.connect.data.Decimal \”,\“ logicalType \”:\“ decimal \”}],\“ default \”:null},{ \“ name \”:\“ COMM \”,\“ type \”:[\“ null \”,{\“ type \”:\“ bytes \”,\“ scale \”:2,\“ precision \ “:64,\” connect.version \“:1,\” connect.parameters \“:{\” scale \“:\” 2 \“},\” connect.name \“:\” org.apache。 kafka.connect.data.Decimal \“,\” logicalType \“:\” decimal \“}],\” default \“:null},{\” name \“:\” DEPTNO \“,\” type \ “:[\” null \“,{\” type \“:\” bytes \“,\” scale \“:0,\” precision \“:64,\” connect.version \“:1,\” connect.parameters \“:{\” scale \“:\” 0 \“},\” connect.name \“:\” org.apache.kafka.connect.data.Decimal \“,\” logicalType \“: \“ decimal \”}],\“ default \”:null}],\“ connect.name \”:\“ EMP1 \”}“}

1 个答案:

答案 0 :(得分:0)

罗宾关于数字映射是正确的。至于显示的时间是很长的时间(以毫秒为单位)。要将该值转换为Vertica HIREDATE,请将该数字除以1000,然后将其转换为时间戳。

SELECT TO_TIMESTAMP(HIREDATE / 1000) ... 为例,请执行以下操作:

let predicate = NSPredicate(format: "%K = %@", #keyPath(BodyPart.name), name)