python을 이용한 avro 기본 api 에서 The datum XX is not an example of the schema 오류가 발생하는 경우가 있습니다.
Traceback (most recent call last):
File "test.py", line 77, in <module>
bytes_data = quickstart_schema.encode(sample_data)
File "test.py", line 41, in encode
self._writer.write(data, encoder)
File "/home/deploy/.local/lib/python2.7/site-packages/avro/io.py", line 979, in write
raise AvroTypeException(self.writers_schema, datum)
avro.io.AvroTypeException: The datum {'empdetails': {'age': 100, 'experience': 'AA'}} is not an example of the schema {
"namespace": "tutorialspoint",
"type": "record",
"name": "empdetails",
"fields": [
{
"type": "string",
"name": "experience"
},
{
"type": "int",
"name": "age"
}
]
}
https://avro.apache.org/docs/current/gettingstartedpython.html
원인
첫 번째 원인은 스키마와 값이 다를 때 발생합니다. 이 경우는 스키마를 잘 확인하고, 데이터의 타입을 잘 맞추어 주면 됩니다.
두번째는 python2에서 실행할 때 발생할 수 있습니다. 공식 문서에는 python2도 지원하고, pip를 이용해서 설치할 수 있지만 python2에서는 오류가 발생했습니다. python3로 실행하면 문제가 해결 됩니다.
반응형
'빅데이터' 카테고리의 다른 글
[atlas] 아파치 아틀라스(apache atlas) 빌드 및 실행 (0) | 2021.08.21 |
---|---|
[ranger] 아파치 레인저 빌드 및 실행 하기 (0) | 2021.08.19 |
[avro] 파이썬을 이용한 avro 예제 (0) | 2021.07.07 |
[빅데이터] LDAP 설치 및 기본 설정 (0) | 2021.06.22 |
[grafana] 우분투(ubuntu)에 그라파나(grafana) 설치 (0) | 2021.04.12 |