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:
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"))
from factcat import EventsSpec, events_sql
print(events_sql(EventsSpec(
table="analytics.fct_events",
entity="subscription_id",
event_time="occurred_at",
measure="uniques",
)))
Event measures: total, uniques, average (Total / Uniques). Property
measures (on="property", of= a column): sum, average, median,
distinct (mean distinct values per entity). Uniques is COUNT DISTINCT of
entity when exact=True; default exact=False is approx NDV.
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.
SQL generation supports DuckDB, Postgres, BigQuery, Snowflake, Databricks, Spark, Trino,
Presto, ClickHouse and Redshift. Execute adapters push that SQL into the caller's
warehouse. Factcat has no warehouse of its own. pip install factcat is the
product (SQL + chart) and includes no warehouse SDK. Run queries with
pip install factcat[bigquery]. Later warehouses are extras of the same
shape; factcat[all] is every shipped driver. The adapter contract is
dialect plus run(sql).
from factcat import RetentionSpec, retention_sql
from factcat.warehouses import connect
sql = retention_sql(spec, dialect="bigquery")
bq = connect("bigquery", project="my-proj", location="EU")
result = bq.run(sql)
Application-default credentials by default (gcloud auth application-default login), or
pass a service-account JSON path as credentials. Queries are capped at 10 GiB scanned
unless you raise maximum_bytes_billed or pass None for unlimited. project and
location are required so an EU dataset is not sent to US.
Full documentation: https://github.com/gordonkjlee/factcat
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file factcat-0.2.0.tar.gz.
File metadata
- Download URL: factcat-0.2.0.tar.gz
- Upload date:
- Size: 28.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
03e769b9584d9d50c4bea400ef11d10cf826d69fd9ab136daa1409151464753f
|
|
| MD5 |
c42cdf92be0e55fb298c5695ea2bb123
|
|
| BLAKE2b-256 |
62d3616592e3610f77a49d68512f6d5f54971d17b0b511892c46d3a8cb1f49c9
|
Provenance
The following attestation bundles were made for factcat-0.2.0.tar.gz:
Publisher:
publish.yml on gordonkjlee/factcat
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
factcat-0.2.0.tar.gz -
Subject digest:
03e769b9584d9d50c4bea400ef11d10cf826d69fd9ab136daa1409151464753f - Sigstore transparency entry: 2626071194
- Sigstore integration time:
-
Permalink:
gordonkjlee/factcat@78ac5984f667dcdd9a6bda55621a4621acba04a8 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/gordonkjlee
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@78ac5984f667dcdd9a6bda55621a4621acba04a8 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file factcat-0.2.0-py3-none-any.whl.
File metadata
- Download URL: factcat-0.2.0-py3-none-any.whl
- Upload date:
- Size: 23.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e7eff0554067ff6c841c0d25db151fee9ee662a305ca1795c0b4f341e88a3457
|
|
| MD5 |
c860f3a6c1449c0ee321a7986f05dcb7
|
|
| BLAKE2b-256 |
7366f96d7e14b836eeac7ed61a71fa6a501856a1ba52ee9df1400ac74507c592
|
Provenance
The following attestation bundles were made for factcat-0.2.0-py3-none-any.whl:
Publisher:
publish.yml on gordonkjlee/factcat
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
factcat-0.2.0-py3-none-any.whl -
Subject digest:
e7eff0554067ff6c841c0d25db151fee9ee662a305ca1795c0b4f341e88a3457 - Sigstore transparency entry: 2626071204
- Sigstore integration time:
-
Permalink:
gordonkjlee/factcat@78ac5984f667dcdd9a6bda55621a4621acba04a8 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/gordonkjlee
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@78ac5984f667dcdd9a6bda55621a4621acba04a8 -
Trigger Event:
workflow_dispatch
-
Statement type: