airbyte_cdk.sources.file_based.config.avro_format
1# 2# Copyright (c) 2023 Airbyte, Inc., all rights reserved. 3# 4 5 6from pydantic.v1 import BaseModel, Field 7 8from airbyte_cdk.utils.oneof_option_config import OneOfOptionConfig 9 10 11class AvroFormat(BaseModel): 12 class Config(OneOfOptionConfig): 13 title = "Avro Format" 14 discriminator = "filetype" 15 16 filetype: str = Field( 17 "avro", 18 const=True, 19 ) 20 21 double_as_string: bool = Field( 22 title="Convert Double Fields to Strings", 23 description="Whether to convert double fields to strings. This is recommended if you have decimal numbers with a high degree of precision because there can be a loss precision when handling floating point numbers.", 24 default=False, 25 )
class
AvroFormat(pydantic.v1.main.BaseModel):
12class AvroFormat(BaseModel): 13 class Config(OneOfOptionConfig): 14 title = "Avro Format" 15 discriminator = "filetype" 16 17 filetype: str = Field( 18 "avro", 19 const=True, 20 ) 21 22 double_as_string: bool = Field( 23 title="Convert Double Fields to Strings", 24 description="Whether to convert double fields to strings. This is recommended if you have decimal numbers with a high degree of precision because there can be a loss precision when handling floating point numbers.", 25 default=False, 26 )
Base class to configure a Pydantic model that's used as a oneOf option in a parent model in a way that's compatible with all Airbyte consumers.
Inherit from this class in the nested Config class in a model and set title and description (these show up in the UI) and discriminator (this is making sure it's marked as required in the schema).
Usage:
class OptionModel(BaseModel): mode: Literal["option_a"] = Field("option_a", const=True) option_a_field: str = Field(...) class Config(OneOfOptionConfig): title = "Option A" description = "Option A description" discriminator = "mode"