Metadata-Version: 2.5
Name: factcat
Version: 0.1.0
Summary: Product analytics on the event model already in your warehouse
Project-URL: Homepage, https://github.com/gordonkjlee/factcat
Project-URL: Source, https://github.com/gordonkjlee/factcat
Author: Gordon Lee
License: MIT
Keywords: analytics,dbt,funnel,retention,sql,warehouse
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Database
Classifier: Topic :: Scientific/Engineering :: Information Analysis
Requires-Python: >=3.10
Requires-Dist: sqlglot>=25.0.0
Provides-Extra: dev
Requires-Dist: duckdb>=1.0.0; extra == 'dev'
Requires-Dist: pytest>=8.0.0; extra == 'dev'
Description-Content-Type: text/markdown

# factcat

Product analytics on the event model already in your warehouse. Your grain, your periods,
your definitions.

Every other product analytics tool hard-codes `entity = user`, `period = a calendar bucket`,
and `retained = did any event`. Real definitions violate all three:

```python
from factcat import RetentionSpec, retention_sql

spec = RetentionSpec(
    table="analytics.fct_subscription_payments",
    entity="subscription_id",   # not the user
    entity_time="sub_start",
    event_time="paid_at",
    period_days=35,             # a billing cycle plus dunning, not a calendar bucket
    n_periods=12,
    retained="status = 'collected' AND within_period_offset <= 5",
)

print(retention_sql(spec, dialect="snowflake"))
```

`retained` is arbitrary SQL over any column in your table, plus the derived columns
`offset_days`, `period_index` and `within_period_offset`.

Generates SQL and queries in place. No SDK, no ingestion, no copy of your data. Supports
DuckDB, Postgres, BigQuery, Snowflake, Databricks, Spark, Trino, Presto, ClickHouse and
Redshift.

Full documentation: https://github.com/gordonkjlee/factcat
