Elementary data observability support for SQLite (dbt-sqlite adapter).
Problem: dbt Elementary is not officially supported for SQLite. When trying to configure and run Elementary with the sqlite adapter, it fails with multiple SQL syntax errors:
Database Error
near "s": syntax error -- ❌ escape_special_chars uses \' instead of ''
Runtime Error
unrecognized token: ":" -- ❌ current_timestamp::timestamp not supported in SQLite
Compilation Error
Could not render type 'varchar(4096)' -- ❌ SQLite uses TEXT, not varchar
Root Cause: Elementary has adapter-specific implementations for:
- ✅ snowflake, bigquery, redshift, postgres, databricks, spark, athena, trino, clickhouse, dremio
- ❌ sqlite - Not supported
Solution: This package provides sqlite__ macro implementations that make Elementary work with SQLite by translating all SQL constructs to SQLite-compatible syntax.
packages:
- package: elementary-data/elementary
version: 0.22.1
- git: https://github.com/accelerate-data/vd-dbt-elementary-sqlite.git
revision: maindispatch:
- macro_namespace: elementary
search_order:
- elementary_sqlite # Check our package first
- elementary # Then Elementary's own macrosmodels:
elementary:
+schema: elementary
+tags: ["elementary"]dbt depsProvides 34 sqlite__ macro implementations for Elementary:
sqlite__edr_type_string()- Returns "text"sqlite__edr_type_long_string()- Returns "text"sqlite__edr_type_bool()- Returns "integer"sqlite__edr_type_timestamp()- Returns "text"sqlite__edr_type_date()- Returns "text"sqlite__data_type_list(data_type)- SQLite-specific type listssqlite__get_normalized_data_type(exact_data_type)- Type normalization
sqlite__escape_special_chars(string_value)- Uses''instead of\'sqlite__contains(string, string_to_search, case_sensitive)- Usesinstr()sqlite__const_as_text(string)- Cast constant as text
sqlite__edr_current_timestamp()-datetime('now')sqlite__edr_current_timestamp_in_utc()-datetime('now')sqlite__edr_cast_as_timestamp(field)-cast(field as text)sqlite__edr_cast_as_date(field)-date(field)sqlite__edr_date_trunc(date_part, date_expression)- Usesstrftime()sqlite__edr_datediff(first_date, second_date, datepart)- Usesjulianday()sqlite__edr_timeadd(date_part, number, timestamp_expression)- Usesdatetime()modifierssqlite__edr_to_char(column, format)- Usesstrftime()
sqlite__edr_day_of_week_expression(date_expr)- Usesstrftime('%w')sqlite__edr_hour_of_day_expression(date_expr)- Usesstrftime('%H')sqlite__edr_hour_of_week_expression(date_expr)- Combined day + hour
sqlite__edr_safe_cast(field, type)-cast(field as type)sqlite__edr_cast_as_float(column)-cast(column as real)sqlite__edr_cast_as_numeric(column)-cast(column as numeric)
sqlite__has_temp_table_support()- Returns truesqlite__insert_rows(...)- Handles adapter transaction state for proper commitssqlite__create_or_replace(temporary, relation, sql_query)- Table creationsqlite__replace_table_data(relation, rows)- Delete and re-insertsqlite__get_delete_and_insert_queries(...)- Separate DELETE/INSERT (no transaction wrapping)sqlite__get_relation_max_name_length()- Returns none (no limit)
sqlite__target_database()- Returns target.databasesqlite__get_columns_from_information_schema(...)- Returns empty (SQLite limitation)sqlite__generate_elementary_profile_args(...)- SQLite profile config
sqlite__complete_buckets_cte(...)- Recursive CTE for time bucket generationsqlite__get_clean_elementary_test_tables_queries(...)- Test table cleanup
SQLite uses '' for escaping single quotes, not \' (which is PostgreSQL/MySQL syntax).
dbt-sqlite adapter's commit() fails when transaction_open is False after the model run phase. This package opens an adapter transaction before inserts so adapter.commit() succeeds, preventing data loss in dbt_run_results and dbt_invocations.
SQLite has no native timestamp type. All date/time operations use:
datetime(),date(),strftime()for formattingjulianday()for date difference calculations- String modifiers like
'+1 days'for date arithmetic
SQLite has a flexible type system: TEXT, INTEGER, REAL, NUMERIC. No varchar(n), boolean, or timestamp types.
Tested with:
- ✅ dbt-sqlite adapter v1.10.0
- ✅ Elementary v0.22.1
- ✅ dbt-core v1.11.6
Confirmed functionality:
- ✅ All 33 Elementary models compile and run (PASS=35, 0 errors)
- ✅ All Elementary runtime tables populated (dbt_models, dbt_tests, dbt_run_results, dbt_invocations, dbt_columns)
- ✅ On-run-end hook completes successfully
- ✅ Metadata collection on every dbt run
- ❌ Elementary CLI: Not supported for SQLite
⚠️ Information Schema:get_columns_from_information_schemareturns empty (SQLite limitation)⚠️ No SAFE_CAST: SQLitecast()does not have a safe/try variant
When Elementary releases a new version:
- Check if new dispatched macros were added
- Add corresponding
sqlite__implementations - Test with your project
- Update version in README
This package is maintained by the AccelerateData team for internal use but is open source.
Issues and PRs welcome at: https://github.com/accelerate-data/vd-dbt-elementary-sqlite
- Elementary Documentation
- dbt-sqlite adapter
- dbt-elementary-fabricspark - Similar package for Fabric Lakehouse
Status: ✅ Production Ready
Last Updated: 2026-02-27