Skip to content

HogQL: tables under the posthog namespace are hard to discover #105869

Description

@jonmcwest

Problem

Users who query a newer PostHog table without the posthog. prefix get Unknown table and no hint about the fix.

  • SELECT * FROM logs works. SELECT * FROM trace_spans fails with Unknown table \trace_spans`. Only posthog.trace_spans` works.
  • The cause is intended. Since feat(hogql): All new tables must be under the posthog namespace #42595, new tables live only under the posthog namespace. Tables that existed before stay in ROOT_TABLES__DO_NOT_ADD_ANY_MORE, so they work with or without the prefix.
  • Discovery does not reflect this. By default, get_posthog_table_names() in posthog/hogql/database/database.py returns a hardcoded list: events, groups, persons, sessions, logs and the system tables. posthog.* tables only appear with include_hidden=True, so autocomplete and the sidebar never suggest posthog.trace_spans.

Tables affected include posthog.trace_spans, posthog.trace_attributes, posthog.metrics and posthog.ai_events.

Proposal

  1. Better error. When an unknown table name matches a child of the posthog node, say Unknown table 'trace_spans'. Did you mean 'posthog.trace_spans'?. This covers every current and future namespaced table.
  2. Better discovery. List the user-facing posthog.* tables (at least posthog.trace_spans and posthog.metrics) in the default get_posthog_table_names() output, so they appear in autocomplete and the sidebar.

This keeps the namespace rule from #42595 intact. It does not add anything to the root namespace.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions