(self)
| 584 | self._storage_format = storage_format and storage_format.upper() |
| 585 | |
| 586 | def get_avro_schema(self): |
| 587 | avro_schema = {'name': 'my_record', 'type': 'record', 'fields': []} |
| 588 | for col in self.cols: |
| 589 | if issubclass(col.type, get_import('Int')): |
| 590 | avro_type = 'int' |
| 591 | elif issubclass(col.type, get_import('Char')): |
| 592 | avro_type = 'string' |
| 593 | elif issubclass(col.type, get_import('Decimal')): |
| 594 | avro_type = { |
| 595 | "type": "bytes", |
| 596 | "logicalType": "decimal", |
| 597 | "precision": col.exact_type.MAX_DIGITS, |
| 598 | "scale": col.exact_type.MAX_FRACTIONAL_DIGITS} |
| 599 | else: |
| 600 | avro_type = col.type.__name__.lower() |
| 601 | avro_schema['fields'].append({'name': col.name, 'type': ['null', avro_type]}) |
| 602 | return json.dumps(avro_schema) |
| 603 | |
| 604 | def __repr__(self): |
| 605 | return 'Table<name: %s, cols: %s>' \ |
no test coverage detected