mongodb+srv) is not yet supported.
Creating a table
Alternatively, you can pass a URI:
Types mappings
If key is not found in MongoDB document (for example, column name doesn’t match), default value or
NULL (if the column is nullable) will be inserted.
OID
If you want aString to be treated as oid in the WHERE clause, just put the column’s name in the last argument of the table engine.
This may be necessary when querying a record by the _id column, which by default has oid type in MongoDB.
If the _id field in the table has other type, for example uuid, you need to specify empty oid_columns, otherwise the default value for this parameter _id is used.
_id is treated as oid column.
0, because ClickHouse doesn’t know that another_oid_column has oid type, so let’s fix it:
Supported clauses
Only queries with simple expressions are supported (for example,WHERE field = <constant> ORDER BY field2 LIMIT <constant>).
Such expressions are translated to MongoDB query language and executed on the server side.
You can disable all these restriction, using mongodb_throw_on_unsupported_query.
In that case ClickHouse tries to convert query on best effort basis, but it can lead to full table scan and processing on ClickHouse side.
It’s always better to explicitly set type of literal because Mongo requires strict typed filters.
For example you want to filter byThis will not work because Mongo will not cast string to This applied for
For example you want to filter by
Date:Date, so you need to cast it manually:Date, Date32, DateTime, Bool, UUID.Usage example
Assuming MongoDB has sample_mflix dataset loaded Create a table in ClickHouse which allows to read data from MongoDB collection:Query
Query
Response
Query
Response
Query
Response