-
Notifications
You must be signed in to change notification settings - Fork 4
refactor(catalog): unify name resolution with SchemaResolver trait #1492
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
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 { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
|
@LNSD all comments addressed afaict |
Consolidate four nearly-identical table/function resolution implementations into a single
resolve_logical_catalogfunction with aSchemaResolvertrait that abstracts over different resolution strategies:DynamicResolver: For user queries (resolves via store)PreResolvedResolver: For derived datasets (looks up in dependencies map)Key changes:
SelfReferencestype for self.function() resolution in derived datasetserror_with_causesin admin-api for full error chain in responsesThis eliminates ~200 lines of duplicated resolution logic while maintaining proper error semantics.