MCPcopy
hub / github.com/rilldata/rill / Resolve

Method Resolve

runtime/resolver.go:126–270  ·  view source on GitHub ↗

Resolve resolves a query using the given options. The caller must call Close on the result when done consuming it.

(ctx context.Context, opts *ResolveOptions)

Source from the content-addressed store, hash-verified

124// Resolve resolves a query using the given options.
125// The caller must call Close on the result when done consuming it.
126func (r *Runtime) Resolve(ctx context.Context, opts *ResolveOptions) (res ResolverResult, info *ResolveInfo, resErr error) {
127 // Since claims don't really make sense for some resolver use cases, it's easy to forget to set them.
128 // Adding an early panic to catch this.
129 if opts.Claims == nil {
130 panic("received nil claims")
131 }
132
133 ctx, span := tracer.Start(ctx, "runtime.Resolve", trace.WithAttributes(attribute.String("resolver", opts.Resolver)))
134 var cacheHit bool
135 defer func() {
136 observability.AddRequestAttributes(ctx, attribute.Bool("query.cache_hit", cacheHit))
137 if resErr != nil {
138 span.SetAttributes(attribute.String("err", resErr.Error()))
139 }
140 span.End()
141 }()
142
143 // Initialize the resolver
144 initializer, ok := ResolverInitializers[opts.Resolver]
145 if !ok {
146 return nil, nil, fmt.Errorf("no resolver found for name %q", opts.Resolver)
147 }
148 resolver, err := initializer(ctx, &ResolverOptions{
149 Runtime: r,
150 InstanceID: opts.InstanceID,
151 Properties: opts.ResolverProperties,
152 Args: opts.Args,
153 Claims: opts.Claims,
154 ForExport: false,
155 })
156 if err != nil {
157 return nil, nil, err
158 }
159 defer resolver.Close()
160
161 err = resolver.Validate(ctx)
162 if err != nil {
163 var invalidErr *ResolverUnusedFieldsError
164 if !errors.As(err, &invalidErr) {
165 return nil, nil, err
166 }
167
168 cfg, cfgErr := r.InstanceConfig(ctx, opts.InstanceID)
169 if cfgErr != nil {
170 return nil, nil, fmt.Errorf("failed to get instance config: %w", cfgErr)
171 }
172
173 if cfg.StrictResolverProps {
174 return nil, nil, err
175 }
176 info = &ResolveInfo{
177 Warnings: []string{invalidErr.Error()},
178 }
179 }
180
181 // Get the cache key
182 cacheKey, ok, err := resolver.CacheKey(ctx)
183 if err != nil {

Callers 2

metricsViewCacheKeyMethod · 0.95
InstanceHealthMethod · 0.95

Calls 15

ErrorMethod · 0.95
InstanceConfigMethod · 0.95
ControllerMethod · 0.95
AddRequestAttributesFunction · 0.92
newCachedResolverResultFunction · 0.85
copyMethod · 0.80
DoMethod · 0.80
StringMethod · 0.65
ErrorfMethod · 0.65
CloseMethod · 0.65
ValidateMethod · 0.65
CacheKeyMethod · 0.65

Tested by

no test coverage detected