how to store mongodb data as single object using f...
# ask-ai
a
how to store mongodb data as single object using free version of airbyte/
k
Based on the knowledge sources, I can explain how to store MongoDB data in a way that preserves the document structure in Airbyte. Airbyte has a schemaless mode for MongoDB that stores each document as a single object. According to the [MongoDB V2 source connector documentation](https://docs.airbyte.com/integrations/sources/mongodb-v2#replication-methods), when schema enforcement is disabled, MongoDB collections are read in schema-less mode, which results in each document being stored with the following structure:
Copy code
{     "_id": <document id>,     "data": {<a JSON containing the entire set of fields found in document>}   }
In this mode, the entire MongoDB document is preserved as a JSON object within the
data
field, allowing for greater flexibility with unstructured data or documents that vary significantly in structure. To enable this in the free (open-source) version of Airbyte: 1. When configuring your MongoDB source connector, look for the Schema Enforced parameter in the configuration settings 2. Disable this option to enable schemaless mode As noted in the [December 2023 release notes](https://docs.airbyte.com/release_notes/december_2023), Airbyte introduced this schemaless mode specifically to "improve our ability to sync data from collections with varying fields for each document" and to "ensure reliable data propagation, even when upstream teams modify the fields uploaded to new MongoDB documents." This feature is available in both Airbyte Cloud and Airbyte Open Source (the free version), as it's part of the MongoDB V2 source connector itself.
a
@kapa.ai but the destenation is clickhouse and it is converted to tabular by default why?
k
A message from kapa.ai
Based on the knowledge sources, I can explain why ClickHouse converts the data to tabular format by default. The new ClickHouse V2 destination connector uses [Direct Load with typed columns](https://docs.airbyte.com/integrations/destinations/clickhouse), which means "Airbyte writes data directly to typed columns matching your source schema, rather than storing everything as JSON in raw tables." This is a fundamental architectural change from the legacy V1 connector. According to the [ClickHouse destination documentation](https://docs.airbyte.com/integrations/destinations/clickhouse#output-schema), the connector converts Airbyte data types to ClickHouse types, including: - Object types →
JSON
if you enable JSON in the connector configuration, otherwise →
String
This means that by default, object types (like your MongoDB documents in the
data
field) are converted to strings in a tabular format. However, there's an important note from the [ClickHouse V2 beta discussion](https://github.com/airbytehq/airbyte/discussions/62035): > "We currently are serializing columns of type Object into strings. We are not supporting storing them as JSON as that is a separate paid feature in ClickHouse we can't rely on every user to have available to them." So the reason your MongoDB data is being converted to tabular format is because: 1. The ClickHouse V2 connector is designed to write data to typed columns by default 2. Object types are serialized as strings unless you have ClickHouse's JSON data type feature enabled 3. The JSON data type in ClickHouse was historically a paid feature (though one commenter notes it may now be available in open-source ClickHouse from version 25.3) If you need to preserve the nested structure, you would need to either: - Enable JSON support in your ClickHouse configuration (if available in your version) - Use ClickHouse's JSON functions to parse the string values after they're loaded The knowledge sources indicate this is a known limitation that the Airbyte team is aware of and gathering feedback on.