MCPcopy Create free account
hub / github.com/dolthub/doltgresql / WithResolvedChildren

Method WithResolvedChildren

server/expression/explicit_cast.go:193–225  ·  view source on GitHub ↗

WithResolvedChildren implements the vitess.InjectableExpression interface.

(ctx context.Context, children []any)

Source from the content-addressed store, hash-verified

191
192// WithResolvedChildren implements the vitess.InjectableExpression interface.
193func (c *ExplicitCast) WithResolvedChildren(ctx context.Context, children []any) (any, error) {
194 if len(children) != 1 {
195 return nil, errors.Errorf("invalid vitess child count, expected `1` but got `%d`", len(children))
196 }
197 resolvedExpression, ok := children[0].(sql.Expression)
198 if !ok {
199 return nil, errors.Errorf("expected vitess child to be an expression but has type `%T`", children[0])
200 }
201 if !c.castToType.IsResolvedType() {
202 sqlCtx, ok := ctx.(*sql.Context)
203 if !ok {
204 return nil, errors.Errorf("%T requires a SQL context for type resolution", c)
205 }
206 typeColl, err := core.GetTypesCollectionFromContext(sqlCtx, "")
207 if err != nil {
208 return nil, err
209 }
210 resolvedType, err := typeColl.ResolveType(sqlCtx, c.castToType.ID)
211 if err != nil {
212 return nil, err
213 }
214 c.castToType = resolvedType
215 }
216 if !c.castToType.IsDefined {
217 return nil, pgtypes.ErrTypeIsOnlyAShell.New(c.castToType.Name())
218 }
219 return &ExplicitCast{
220 sqlChild: resolvedExpression,
221 castToType: c.castToType,
222 domainNullable: c.domainNullable,
223 domainChecks: c.domainChecks,
224 }, nil
225}
226
227// WithCastToType returns a copy of the expression with castToType replaced.
228func (c *ExplicitCast) WithCastToType(t *pgtypes.DoltgresType) sql.Expression {

Callers

nothing calls this directly

Calls 5

IsResolvedTypeMethod · 0.80
ErrorfMethod · 0.65
ResolveTypeMethod · 0.65
NameMethod · 0.65

Tested by

no test coverage detected