Skip to content

Add examples/session: canonical patterns for sessions, catalogs, providers, and extensions#33

Merged
everettVT merged 6 commits into
mainfrom
everettVT/catalog-patterns
Apr 20, 2026
Merged

Add examples/session: canonical patterns for sessions, catalogs, providers, and extensions#33
everettVT merged 6 commits into
mainfrom
everettVT/catalog-patterns

Conversation

@everettVT
Copy link
Copy Markdown
Contributor

Summary

  • Adds examples/session/ with 7 focused example scripts covering the full Daft session API surface
  • Each script uses a clean factory-of-functions style: one function per pattern, docstring explains it, __main__ calls them in sequence
  • All scripts tested green locally; registered in tests/registry.py
  • Adds daft-h3 to project dependencies

Scripts

File Patterns demonstrated
session_basics.py Explicit session, context manager, global helpers
session_providers.py Global, custom-endpoint, named, multi-provider, per-call override
session_catalogs.py In-memory catalog, attach, create/temp tables, existence checks, external catalog factories
session_sql.py SELECT/WHERE, DISTINCT, JOIN, global daft.sql(), temp-table joins
session_namespaces.py Create/use/drop namespaces, Identifier, pattern-filtered listing
session_context_config.py Execution config, planning config, scoped context managers, S3 IO config
session_extension_h3.py load_extension() with daft-h3: lat/lng→cells, hex↔UInt64, inspect, parent rollup, grid distance

Test plan

  • session_basics.py — passes
  • session_catalogs.py — passes
  • session_namespaces.py — passes
  • session_sql.py — passes
  • session_context_config.py — passes (reads public S3)
  • session_providers.py — passes (requires OPENAI_API_KEY)
  • session_extension_h3.py — passes (requires daft-h3)

🤖 Generated with Claude Code

everettVT and others added 3 commits April 19, 2026 16:05
…providers, and extensions

- session_basics: explicit session, context manager, global helpers
- session_providers: global/custom-endpoint/named/multi-provider patterns
- session_catalogs: in-memory catalog, attach, create/temp tables, existence checks
- session_sql: SELECT, DISTINCT, JOIN, temp-table queries via sess.sql()
- session_namespaces: create/use/drop namespaces, Identifier, pattern listing
- session_context_config: execution config, planning config, scoped context managers
- session_extension_h3: load_extension() with daft-h3 for H3 geospatial indexing

All scripts tested green; registered in tests/registry.py. Added daft-h3 to
project dependencies.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 135acec0cd

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread examples/session/session_namespaces.py Outdated

def pattern_filtered_listing(sess: Session) -> None:
"""Filter catalog listings with a glob pattern."""
sess.list_tables("sales.*")
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Use SQL LIKE pattern for list_tables filtering

Session.list_tables() on the in-memory catalog expects SQL LIKE syntax (%, _), but this example passes a glob pattern ("sales.*"). In this context * is treated literally, so the filter won’t match sales.orders/sales.customers and the demo silently fails to show namespace-scoped listing. Use a LIKE pattern such as "sales.%" so the function behaves as described.

Useful? React with 👍 / 👎.

everettVT and others added 3 commits April 19, 2026 17:43
Print active provider name, has_provider checks, and detach confirmation
for functions that don't otherwise produce output.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Print namespace/table listings, active namespace before/after set,
identifier parts, existence check results, and state after drops.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- session_catalogs: print has_catalog/has_table results in existence_checks
- session_context_config: print config values after enable_dynamic_batching,
  fine_tuned_execution_config, and enable_strict_filter_pushdown

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@everettVT everettVT merged commit 5ffdd8d into main Apr 20, 2026
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant