sqlite
Allows to perform queries on data stored in a SQLite database.
Syntax
Arguments
db_path— Path to a file with an SQLite database. String.table_name— Name of a table in the SQLite database, or a query passed to SQLite as is (see Passing a query instead of a table name). String.
Returned value
- A table object with the same columns as in the original
SQLitetable.
Passing a query instead of a table name
Instead of a table name, the second argument can be a SELECT query that is passed to SQLite as is. The structure of the resulting table is inferred from the query result. The query can be written either as a subquery, or wrapped into the query function:
Such a table is read-only: INSERT into it is not allowed. The same syntax is supported by the SQLite table engine.
The subquery form (SELECT ...) is parsed by ClickHouse and re-serialized before being sent to SQLite. It must therefore be valid ClickHouse SQL. To pass SQLite-specific syntax that ClickHouse does not parse, use the query('...') form, whose text is sent to SQLite verbatim.
Any outer WHERE, LIMIT, aggregation, etc. of the surrounding ClickHouse query is not pushed down into the passed query — it is applied in ClickHouse after the full query result is fetched. To restrict the data read from SQLite, put the filter inside the passed query. With external_table_strict_query = 1 an outer filter that cannot be pushed down is rejected with an exception instead of being applied locally.
Example
Related
- SQLite table engine
- SQLite database engine — Data types support section