Skip to content

Conversation

@leoyvens
Copy link
Collaborator

@leoyvens leoyvens commented Dec 18, 2025

Consolidate four nearly-identical table/function resolution implementations into a single resolve_logical_catalog function with a SchemaResolver trait that abstracts over different resolution strategies:

  • DynamicResolver: For user queries (resolves via store)
  • PreResolvedResolver: For derived datasets (looks up in dependencies map)

Key changes:

  • Add SelfReferences type for self.function() resolution in derived datasets
  • Use error_with_causes in admin-api for full error chain in responses

This eliminates ~200 lines of duplicated resolution logic while maintaining proper error semantics.

Consolidate four nearly-identical table/function resolution implementations
into a single `resolve_logical_catalog` function with a `SchemaResolver` trait
that abstracts over different resolution strategies:

- `DynamicResolver`: For user queries (resolves via store)
- `PreResolvedResolver`: For derived datasets (looks up in dependencies map)

Key changes:
- Add `SelfReferences` type for self.function() resolution in derived datasets
- Nest `ResolveError` in `Resolution` variant to preserve error types for
  correct HTTP status code mapping (400 for alias not found, 404 for
  function/table not found)
- Use `error_with_causes` in admin-api for full error chain in responses
- Add `schema` field to `FunctionNotFound` for better error messages
  (shows 'eth.func' instead of just 'func')
- Fix unqualified table detection when flattening references

This eliminates ~200 lines of duplicated resolution logic while maintaining
proper error semantics.
/// This trait provides the minimal interface required for SQL catalog building,
/// abstracting over the dataset store implementation.
pub trait DatasetAccess {
pub trait DatasetAccess: Send + Sync + 'static {
Copy link
Contributor

@LNSD LNSD Dec 19, 2025

Choose a reason for hiding this comment

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

Are these necessary? Can't we just require them in the where clause, or let the compiler infer them?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We can put them in the where clause, but I have the habit of doing this for syntactical convenience. It's an internal trait so we can change whenever.

More descriptive name that clarifies this resolver is used for
registry-based schema resolution (user queries via the dataset store).
Reorganize the file to put the main public function near the top,
after its type dependencies. The implementation-specific
RegistrySchemaResolver is moved to the bottom.
When an error variant has #[source], including {0} in the message
duplicates the source error. The source is automatically included
in the error chain via error_with_causes.
@leoyvens leoyvens marked this pull request as ready for review December 19, 2025 17:32
@leoyvens
Copy link
Collaborator Author

@LNSD all comments addressed afaict

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.

3 participants