:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
feat(customer_analytics): Move federated system tables to product facade (#67902)
Arthur Moreira de Deusc2bab28774ce
diff --git a/.agents/skills/isolating-product-facade-contracts/SKILL.md b/.agents/skills/isolating-product-facade-contracts/SKILL.mdindex efcf5ed7b010..4c1b0a127b0a 100644--- a/.agents/skills/isolating-product-facade-contracts/SKILL.md+++ b/.agents/skills/isolating-product-facade-contracts/SKILL.md@@ -129,7 +129,7 @@ least leave a string to grep for.## Clearing coupling the scan won't show-`product:isolate:scan` walks the import graph of `backend.*`. Three kinds of+`product:isolate:scan` walks the import graph of `backend.*`. Four kinds ofcoupling escape it — none is a dead end, each has a defined move. After thebackend sweep, `git grep "products.<name>"` (not just `.backend`) and read thescan's string-reference section to find them.@@ -163,6 +163,22 @@ defer the expensive ones (nested-serializer or transactional viewsets) as named`ignore_imports` for the presentation wave. Providing the facade function whiledeferring its caller is a legitimate intermediate state, not a half-migration.+**Product-owned HogQL system tables.** When core mounts a product's federated+system tables (`schema/system.py`, `lazy_join_registry.py`), answer two independent questions:++- _Can the reference be a normal facade import?_ Yes — table defs and lazy-join+ functions are plain module-level objects; move them into the product+ (e.g. `facade/hogql.py`) and reroute core's import, like any other wiring.+- _Do the objects enter the **static** pickled catalog?_ Core builds the+ catalog once and reloads it per request through a restricted unpickler+ (`build_database_root_node` in `posthog/hogql/database/database.py`).+ Any product-defined **class** in the catalog tree (a `PostgresTable`/`LazyTable`+ subclass) needs its module added to `_CATALOG_PICKLE_MODULES` — allowlisted+ individually, not by prefix. A missing entry fails the core catalog tests+ with a message naming the module. Warehouse-style per-team tables are built+ at request time and never enter the static catalog, which is why most+ products never hit this.+The web_analytics migration is the worked example of all three: its preagg testbase moved down to core, its timezone integration test moved into the product,its Dagster assets gained a `facade/dags.py`, and its filter-preset reads landeddiff --git a/.gitignore b/.gitignoreindex 814fc74fb8e1..3bf494b092b4 100644--- a/.gitignore+++ b/.gitignore@@ -158,6 +158,7 @@ posthog/management/commands/clear_demo_data.py.claude/settings.local.json.claude/worktrees/.claude/scheduled_tasks.lock+.claude/plans/# Ignore local mprocs configsbin/mprocs*.local.yamldiff --git a/posthog/hogql/database/database.py b/posthog/hogql/database/database.pyindex 76286fe6c97c..0945c71444bf 100644--- a/posthog/hogql/database/database.py+++ b/posthog/hogql/database/database.py@@ -324,10 +324,16 @@ _DATABASE_ROOT_NODE_BLOBS_LOCK = threading.Lock()# We only ever load our own freshly-built blob, but restrict the unpickler anyway as defense in depth:# it can reconstruct only the classes the catalog is built from, so even a future change that fed it# untrusted bytes couldn't instantiate arbitrary code (os.system, etc.). Every catalog class lives-# under posthog.hogql.* except the Workload enum, so new table/field/AST types keep working and-# anything else fails loudly.+# under posthog.hogql.* except the Workload enum and product-owned facade schema modules+# (allowlisted individually, not by prefix, to keep the surface minimal), so new table/field/AST+# types keep working and anything else fails loudly._CATALOG_PICKLE_MODULE_PREFIXES = ("posthog.hogql.",)-_CATALOG_PICKLE_MODULES = frozenset({"posthog.clickhouse.workload"})+_CATALOG_PICKLE_MODULES = frozenset(+ {+ "posthog.clickhouse.workload",+ "products.customer_analytics.backend.facade.hogql",+ }+)class _CatalogUnpickler(pickle.Unpickler):diff --git a/posthog/hogql/database/lazy_join_registry.py b/posthog/hogql/database/lazy_join_registry.pyindex e874a3caa6f7..592006464410 100644--- a/posthog/hogql/database/lazy_join_registry.py+++ b/posthog/hogql/database/lazy_join_registry.py@@ -2,11 +2,6 @@ from collections.abc import Callablefrom typing import TYPE_CHECKINGfrom posthog.hogql.database import lazy_join_tags as tags-from posthog.hogql.database.schema.account_aggregates import (- account_custom_properties_join,- account_notebooks_join,- account_tags_join,-)from posthog.hogql.database.schema.error_tracking_fingerprint_issue_state import (join_with_error_tracking_fingerprint_issue_state_table,)@@ -36,6 +31,12 @@ from posthog.hogql.database.warehouse_join_resolvers import (resolve_foreign_key_join,)+from products.customer_analytics.backend.facade.hogql import (+ account_custom_properties_join,+ account_notebooks_join,+ account_tags_join,+)+if TYPE_CHECKING:from posthog.hogql import astfrom posthog.hogql.context import HogQLContextdiff --git a/posthog/hogql/database/schema/system.py b/posthog/hogql/database/schema/system.pyindex fc556a20e760..4dbc469a789d 100644--- a/posthog/hogql/database/schema/system.py+++ b/posthog/hogql/database/schema/system.py@@ -17,19 +17,19 @@ from posthog.hogql.database.models import (UUIDDatabaseField,)from posthog.hogql.database.postgres_table import PostgresTable-from posthog.hogql.database.schema.account_aggregates import (- _account_custom_property_values,- _account_resource_notebooks,- _account_tagged_items,- account_custom_properties_lazy_join,- account_notebooks_lazy_join,- account_tags_lazy_join,-)from posthog.hogql.database.schema.information_schema import information_schema_nodefrom posthog.hogql.parser import parse_exprfrom posthog.scopes import APIScopeObject+from products.customer_analytics.backend.facade.hogql import (+ account_custom_property_values,+ account_resource_notebooks,+ account_tagged_items,+ accounts,+ custom_property_definitions,+)+class IngestionWarningsTable(Table):description: str = (@@ -208,74 +208,6 @@ cohort_calculation_history: PostgresTable = PostgresTable(},)-accounts: PostgresTable = PostgresTable(- name="accounts",- postgres_table_name="customer_analytics_account",- # Object-level access control filters out ids directly off access_scope, so we use- # `account` here (where the per-object grants are stored) instead of the- # `customer_analytics` umbrella. Resource-level gating still works via RESOURCE_INHERITANCE_MAP.- access_scope="account",- description="Customer analytics accounts (companies/organizations being tracked); one row per account, with CRM identifiers extracted from properties.",- fields={- "id": UUIDDatabaseField(name="id", description="Account UUID."),- "team_id": IntegerDatabaseField(name="team_id"),- "external_id": StringDatabaseField(- name="external_id", nullable=True, description="Identifier of the account in the source system."- ),- "name": StringDatabaseField(name="name", description="Display name of the account."),- "properties": StringJSONDatabaseField(- name="properties",- description="JSON map of account properties; the CRM id columns below are extracted from this.",- ),- "stripe_customer_id": ExpressionField(- name="stripe_customer_id",- expr=parse_expr("JSONExtractString(properties, 'stripe_customer_id')"),- ),- "hubspot_deal_id": ExpressionField(- name="hubspot_deal_id",- expr=parse_expr("JSONExtractString(properties, 'hubspot_deal_id')"),- ),- "billing_id": ExpressionField(- name="billing_id",- expr=parse_expr("JSONExtractString(properties, 'billing_id')"),- ),- "sfdc_id": ExpressionField(- name="sfdc_id",- expr=parse_expr("JSONExtractString(properties, 'sfdc_id')"),- ),- "zendesk_id": ExpressionField(- name="zendesk_id",- expr=parse_expr("JSONExtractString(properties, 'zendesk_id')"),- ),- "csm": ExpressionField(- name="csm",- expr=parse_expr("JSONExtract(properties, 'csm', 'Tuple(id Nullable(Int64), email Nullable(String))')"),- ),- "account_executive": ExpressionField(- name="account_executive",- expr=parse_expr(- "JSONExtract(properties, 'account_executive', 'Tuple(id Nullable(Int64), email Nullable(String))')"- ),- ),- "account_owner": ExpressionField(- name="account_owner",- expr=parse_expr(- "JSONExtract(properties, 'account_owner', 'Tuple(id Nullable(Int64), email Nullable(String))')"- ),- ),- "created_by_id": IntegerDatabaseField(- name="created_by_id", nullable=True, description="User who created the account record."- ),- "created_at": DateTimeDatabaseField(name="created_at", description="When the account record was created."),- "updated_at": DateTimeDatabaseField(- name="updated_at", nullable=True, description="When the account record was last updated."- ),- "tags": account_tags_lazy_join,- "notebooks": account_notebooks_lazy_join,- "custom_properties": account_custom_properties_lazy_join,- },-)-cohorts: PostgresTable = PostgresTable(name="cohorts",postgres_table_name="posthog_cohort",@@ -315,41 +247,6 @@ cohorts: PostgresTable = PostgresTable(},)-custom_property_definitions: PostgresTable = PostgresTable(- name="custom_property_definitions",- postgres_table_name="customer_analytics_custompropertydefinition",- # Sub-resource of accounts; gated at the account resource level (see customer_analytics backend CLAUDE.md).- access_scope="account",- description="Customer analytics custom property definitions: team-scoped attribute shapes (the property's name and type), one row per definition. Per-account values are exposed via the system.accounts.custom_properties lazy join.",- fields={- "id": UUIDDatabaseField(name="id", description="Custom property definition UUID."),- "team_id": IntegerDatabaseField(name="team_id"),- "name": StringDatabaseField(- name="name", description="Human-readable name of the custom property; unique within the team."- ),- "description": StringDatabaseField(- name="description", nullable=True, description="Optional description of what the property represents."- ),- "display_type": StringDatabaseField(- name="display_type",- description="How the property is interpreted and rendered: 'text', 'number', 'currency', 'percent', 'date', 'datetime', or 'boolean'.",- ),- "_is_big_number": BooleanDatabaseField(name="is_big_number", hidden=True),- "is_big_number": ExpressionField(- name="is_big_number",- expr=ast.Call(name="toInt", args=[ast.Field(chain=["_is_big_number"])]),- description="1 if large numeric values are abbreviated (e.g. 10,000 -> 10K), 0 otherwise.",- ),- "created_by_id": IntegerDatabaseField(- name="created_by_id", nullable=True, description="User who created the definition."- ),- "created_at": DateTimeDatabaseField(name="created_at", description="When the definition was created."),- "updated_at": DateTimeDatabaseField(- name="updated_at", nullable=True, description="When the definition was last updated."- ),- },-)-dashboards: PostgresTable = PostgresTable(name="dashboards",postgres_table_name="posthog_dashboard",@@ -2111,12 +2008,12 @@ class SystemTables(TableNode):name: str = "system"children: dict[str, TableNode] = {"accounts": TableNode(name="accounts", table=accounts),- "_account_tagged_items": TableNode(name="_account_tagged_items", table=_account_tagged_items, hidden=True),+ "_account_tagged_items": TableNode(name="_account_tagged_items", table=account_tagged_items, hidden=True),"_account_resource_notebooks": TableNode(- name="_account_resource_notebooks", table=_account_resource_notebooks, hidden=True+ name="_account_resource_notebooks", table=account_resource_notebooks, hidden=True),"_account_custom_property_values": TableNode(- name="_account_custom_property_values", table=_account_custom_property_values, hidden=True+ name="_account_custom_property_values", table=account_custom_property_values, hidden=True),"activity_logs": TableNode(name="activity_logs", table=activity_logs),"actions": TableNode(name="actions", table=actions),diff --git a/posthog/hogql/database/test/test_database.py b/posthog/hogql/database/test/test_database.pyindex e41f41bf76cd..61ccc370fa58 100644--- a/posthog/hogql/database/test/test_database.py+++ b/posthog/hogql/database/test/test_database.py@@ -26,6 +26,8 @@ from posthog.hogql import astfrom posthog.hogql.constants import MAX_SELECT_RETURNED_ROWSfrom posthog.hogql.context import HogQLContextfrom posthog.hogql.database.database import (+ _CATALOG_PICKLE_MODULE_PREFIXES,+ _CATALOG_PICKLE_MODULES,ROOT_TABLES__DO_NOT_ADD_ANY_MORE,Database,_CatalogUnpickler,@@ -152,6 +154,31 @@ class TestBuildDatabaseRootNode(TestCase):restored_extra = pickle.loads(pickle.dumps(with_extra, protocol=pickle.HIGHEST_PROTOCOL))assert restored_extra.__pydantic_extra__ == {"extra_key": "value"}+ def test_catalog_pickle_allowlist_covers_every_catalog_class(self):+ # A missing allowlist entry (e.g. a product mounts a static catalog table without touching+ # _CATALOG_PICKLE_MODULES) already fails the round-trip tests above, but with a bare+ # UnpicklingError — this failure names the offending module and the fix.+ modules: set[str] = set()++ class RecordingUnpickler(pickle.Unpickler):+ def find_class(self, module: str, name: str) -> Any:+ modules.add(module)+ return super().find_class(module, name)++ blob = pickle.dumps(_construct_database_root_node(include_posthog_tables=True), pickle.HIGHEST_PROTOCOL)+ RecordingUnpickler(io.BytesIO(blob)).load()++ unlisted = {+ module+ for module in modules+ if not module.startswith(_CATALOG_PICKLE_MODULE_PREFIXES) and module not in _CATALOG_PICKLE_MODULES+ }+ assert not unlisted, (+ f"The static HogQL catalog pickles classes from modules the restricted unpickler rejects: "+ f"{sorted(unlisted)}. Add each module to _CATALOG_PICKLE_MODULES in "+ f"posthog/hogql/database/database.py, or the catalog will fail to load at request time."+ )+def test_catalog_unpickler_allowlists_catalog_classes_and_rejects_others(self):# Restricted unpickler resolves catalog classes but rejects anything else, so a tampered blob# can't instantiate code-execution gadgets.diff --git a/posthog/hogql/database/schema/account_aggregates.py b/products/customer_analytics/backend/facade/hogql.pysimilarity index 66%rename from posthog/hogql/database/schema/account_aggregates.pyrename to products/customer_analytics/backend/facade/hogql.pyindex ff2334da4d01..89494379f39f 100644--- a/posthog/hogql/database/schema/account_aggregates.py+++ b/products/customer_analytics/backend/facade/hogql.py@@ -1,10 +1,17 @@-"""Internal aggregating tables and lazy joins that power `system.accounts.tags` and-`system.accounts.notebooks`.--The two raw federated tables (`_account_tagged_items`, `_account_resource_notebooks`)-are tag/notebook junction rows from PostgreSQL. They have no `team_id` column and-should not be reachable directly from the SQL editor — they exist only so the lazy-join subqueries below can be resolved by the planner.+"""Customer analytics' federated HogQL system tables (`system.accounts`,+`system.custom_property_definitions`) and the aggregating tables plus lazy joins that+power `system.accounts.tags`, `system.accounts.notebooks`, and+`system.accounts.custom_properties`.++Owned here rather than in core so the coupling between core's HogQL schema and this+product's Postgres tables is import-visible (tach) and facade-gated (CI): core+`schema/system.py` and `lazy_join_registry.py` import these definitions instead of+hardcoding the product's table and column names.++The raw federated junction tables (`_account_tagged_items`, `_account_resource_notebooks`,+`_account_custom_property_values`) have no `team_id` column and should not be reachable+directly from the SQL editor — they exist only so the lazy join subqueries below can be+resolved by the planner."""from posthog.hogql import ast@@ -15,6 +22,7 @@ from posthog.hogql.database.models import (BooleanDatabaseField,DANGEROUS_NoTeamIdCheckTable,DateTimeDatabaseField,+ ExpressionField,FieldOrTable,FloatDatabaseField,IntegerDatabaseField,@@ -47,7 +55,7 @@ class _AccountScopedPostgresTable(PostgresTable, DANGEROUS_NoTeamIdCheckTable):predicates: list[Expr] = [parse_expr("account_id IN (SELECT id FROM system.accounts)")]-_account_tagged_items: _AccountScopedPostgresTable = _AccountScopedPostgresTable(+account_tagged_items: _AccountScopedPostgresTable = _AccountScopedPostgresTable(name="_account_tagged_items",postgres_table_name="posthog_taggeditem",description="Internal federated junction table (PostgreSQL `posthog_taggeditem`) of tag-to-account links; not for direct querying — use `system.accounts.tags`.",@@ -60,7 +68,7 @@ _account_tagged_items: _AccountScopedPostgresTable = _AccountScopedPostgresTable},)-_account_resource_notebooks: _AccountScopedPostgresTable = _AccountScopedPostgresTable(+account_resource_notebooks: _AccountScopedPostgresTable = _AccountScopedPostgresTable(name="_account_resource_notebooks",postgres_table_name="posthog_resourcenotebook",description="Internal federated junction table (PostgreSQL `posthog_resourcenotebook`) of notebook-to-account links; not for direct querying — use `system.accounts.notebooks`.",@@ -76,7 +84,7 @@ _account_resource_notebooks: _AccountScopedPostgresTable = _AccountScopedPostgre)-_account_custom_property_values: _AccountScopedPostgresTable = _AccountScopedPostgresTable(+account_custom_property_values: _AccountScopedPostgresTable = _AccountScopedPostgresTable(name="_account_custom_property_values",postgres_table_name="customer_analytics_custompropertyvalue",description="Internal federated table (PostgreSQL `customer_analytics_custompropertyvalue`) of custom property values per account; not for direct querying — use `system.accounts.custom_properties`.",@@ -316,3 +324,108 @@ account_custom_properties_lazy_join: LazyJoin = LazyJoin(join_table=_AccountCustomPropertiesTable(),resolver=ACCOUNT_CUSTOM_PROPERTIES,)+++accounts: PostgresTable = PostgresTable(+ name="accounts",+ postgres_table_name="customer_analytics_account",+ # Object-level access control filters out ids directly off access_scope, so we use+ # `account` here (where the per-object grants are stored) instead of the+ # `customer_analytics` umbrella. Resource-level gating still works via RESOURCE_INHERITANCE_MAP.+ access_scope="account",+ description="Customer analytics accounts (companies/organizations being tracked); one row per account, with CRM identifiers extracted from properties.",+ fields={+ "id": UUIDDatabaseField(name="id", description="Account UUID."),+ "team_id": IntegerDatabaseField(name="team_id"),+ "external_id": StringDatabaseField(+ name="external_id", nullable=True, description="Identifier of the account in the source system."+ ),+ "name": StringDatabaseField(name="name", description="Display name of the account."),+ "properties": StringJSONDatabaseField(+ name="properties",+ description="JSON map of account properties; the CRM id columns below are extracted from this.",+ ),+ "stripe_customer_id": ExpressionField(+ name="stripe_customer_id",+ expr=parse_expr("JSONExtractString(properties, 'stripe_customer_id')"),+ ),+ "hubspot_deal_id": ExpressionField(+ name="hubspot_deal_id",+ expr=parse_expr("JSONExtractString(properties, 'hubspot_deal_id')"),+ ),+ "billing_id": ExpressionField(+ name="billing_id",+ expr=parse_expr("JSONExtractString(properties, 'billing_id')"),+ ),+ "sfdc_id": ExpressionField(+ name="sfdc_id",+ expr=parse_expr("JSONExtractString(properties, 'sfdc_id')"),+ ),+ "zendesk_id": ExpressionField(+ name="zendesk_id",+ expr=parse_expr("JSONExtractString(properties, 'zendesk_id')"),+ ),+ "csm": ExpressionField(+ name="csm",+ expr=parse_expr("JSONExtract(properties, 'csm', 'Tuple(id Nullable(Int64), email Nullable(String))')"),+ ),+ "account_executive": ExpressionField(+ name="account_executive",+ expr=parse_expr(+ "JSONExtract(properties, 'account_executive', 'Tuple(id Nullable(Int64), email Nullable(String))')"+ ),+ ),+ "account_owner": ExpressionField(+ name="account_owner",+ expr=parse_expr(+ "JSONExtract(properties, 'account_owner', 'Tuple(id Nullable(Int64), email Nullable(String))')"+ ),+ ),+ "created_by_id": IntegerDatabaseField(+ name="created_by_id", nullable=True, description="User who created the account record."+ ),+ "created_at": DateTimeDatabaseField(name="created_at", description="When the account record was created."),+ "updated_at": DateTimeDatabaseField(+ name="updated_at", nullable=True, description="When the account record was last updated."+ ),+ "tags": account_tags_lazy_join,+ "notebooks": account_notebooks_lazy_join,+ "custom_properties": account_custom_properties_lazy_join,+ },+)+++custom_property_definitions: PostgresTable = PostgresTable(+ name="custom_property_definitions",+ postgres_table_name="customer_analytics_custompropertydefinition",+ # Sub-resource of accounts; gated at the account resource level (see customer_analytics backend CLAUDE.md).+ access_scope="account",+ description="Customer analytics custom property definitions: team-scoped attribute shapes (the property's name and type), one row per definition. Per-account values are exposed via the system.accounts.custom_properties lazy join.",+ fields={+ "id": UUIDDatabaseField(name="id", description="Custom property definition UUID."),+ "team_id": IntegerDatabaseField(name="team_id"),+ "name": StringDatabaseField(+ name="name", description="Human-readable name of the custom property; unique within the team."+ ),+ "description": StringDatabaseField(+ name="description", nullable=True, description="Optional description of what the property represents."+ ),+ "display_type": StringDatabaseField(+ name="display_type",+ description="How the property is interpreted and rendered: 'text', 'number', 'currency', 'percent', 'date', 'datetime', or 'boolean'.",+ ),+ "_is_big_number": BooleanDatabaseField(name="is_big_number", hidden=True),+ "is_big_number": ExpressionField(+ name="is_big_number",+ expr=ast.Call(name="toInt", args=[ast.Field(chain=["_is_big_number"])]),+ description="1 if large numeric values are abbreviated (e.g. 10,000 -> 10K), 0 otherwise.",+ ),+ "created_by_id": IntegerDatabaseField(+ name="created_by_id", nullable=True, description="User who created the definition."+ ),+ "created_at": DateTimeDatabaseField(name="created_at", description="When the definition was created."),+ "updated_at": DateTimeDatabaseField(+ name="updated_at", nullable=True, description="When the definition was last updated."+ ),+ },+)diff --git a/products/customer_analytics/backend/test/test_facade_hogql.py b/products/customer_analytics/backend/test/test_facade_hogql.pynew file mode 100644index 000000000000..4179ba7415a7--- /dev/null+++ b/products/customer_analytics/backend/test/test_facade_hogql.py@@ -0,0 +1,51 @@+# The facade owns the PostgresTable defs that core exposes as `system.accounts`,+# `system.custom_property_definitions`, `system.accounts.custom_properties`, and the hidden+# junction tables behind `system.accounts.tags`/`.notebooks`. Core's own system-table suite+# is skipped on this product's CI shard by the isolation contract-check, so this guard lives+# in-product: it fails here if a backing table is renamed or a model column is renamed/dropped+# without updating facade/hogql.py, catching the drift on the shard that actually runs for+# model changes.+from django.test import SimpleTestCase++from parameterized import parameterized++from posthog.hogql.database.models import ExpressionField, LazyJoin, Table++from posthog.models import TaggedItem++from products.customer_analytics.backend.facade.hogql import (+ account_custom_property_values,+ account_resource_notebooks,+ account_tagged_items,+ accounts,+ custom_property_definitions,+)+from products.customer_analytics.backend.models import Account, CustomPropertyDefinition, CustomPropertyValue+from products.notebooks.backend.models import ResourceNotebook+++class TestFacadeHogqlSystemTables(SimpleTestCase):+ @parameterized.expand(+ [+ ("accounts", accounts, Account),+ ("custom_property_definitions", custom_property_definitions, CustomPropertyDefinition),+ ("account_custom_property_values", account_custom_property_values, CustomPropertyValue),+ ("account_tagged_items", account_tagged_items, TaggedItem),+ ("account_resource_notebooks", account_resource_notebooks, ResourceNotebook),+ ]+ )+ def test_federated_table_matches_model(self, _name, table, model):+ assert table.postgres_table_name == model._meta.db_table, (+ f"system.{table.name} federates PostgreSQL table {table.postgres_table_name!r}, but "+ f"{model.__name__} is stored in {model._meta.db_table!r}. Update the PostgresTable def "+ f"in facade/hogql.py to match the model."+ )+ model_columns = {field.column for field in model._meta.concrete_fields}+ exposed_columns = {+ field.name for field in table.fields.values() if not isinstance(field, (ExpressionField, LazyJoin, Table))+ }+ missing = exposed_columns - model_columns+ assert not missing, (+ f"system.{table.name} exposes {sorted(missing)}, which no longer exist as columns on "+ f"{model.__name__}. Update the PostgresTable def in facade/hogql.py to match the model."+ )