Skip to content

Commit 527b791

Browse files
authored
Merge pull request #2322 from dolthub/daylon/injected-expr-name-res
Allow InjectedExpr to handle name resolution
2 parents 50fb2b2 + b48e69d commit 527b791

File tree

3 files changed

+14
-6
lines changed

3 files changed

+14
-6
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ require (
66
github.com/dolthub/go-icu-regex v0.0.0-20230524105445-af7e7991c97e
77
github.com/dolthub/jsonpath v0.0.2-0.20240201003050-392940944c15
88
github.com/dolthub/sqllogictest/go v0.0.0-20201107003712-816f3ae12d81
9-
github.com/dolthub/vitess v0.0.0-20240207220624-0c2d2128fb7b
9+
github.com/dolthub/vitess v0.0.0-20240209125211-6c93b0341608
1010
github.com/go-kit/kit v0.10.0
1111
github.com/go-sql-driver/mysql v1.7.2-0.20231213112541-0004702b931d
1212
github.com/gocraft/dbr/v2 v2.7.2

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ github.com/dolthub/jsonpath v0.0.2-0.20240201003050-392940944c15 h1:sfTETOpsrNJP
5858
github.com/dolthub/jsonpath v0.0.2-0.20240201003050-392940944c15/go.mod h1:2/2zjLQ/JOOSbbSboojeg+cAwcRV0fDLzIiWch/lhqI=
5959
github.com/dolthub/sqllogictest/go v0.0.0-20201107003712-816f3ae12d81 h1:7/v8q9XGFa6q5Ap4Z/OhNkAMBaK5YeuEzwJt+NZdhiE=
6060
github.com/dolthub/sqllogictest/go v0.0.0-20201107003712-816f3ae12d81/go.mod h1:siLfyv2c92W1eN/R4QqG/+RjjX5W2+gCTRjZxBjI3TY=
61-
github.com/dolthub/vitess v0.0.0-20240207220624-0c2d2128fb7b h1:7Sxjtwd7Cm2ilQDFvyXPfCkNkJMK//2GBGb3aM9ht7k=
62-
github.com/dolthub/vitess v0.0.0-20240207220624-0c2d2128fb7b/go.mod h1:IwjNXSQPymrja5pVqmfnYdcy7Uv7eNJNBPK/MEh9OOw=
61+
github.com/dolthub/vitess v0.0.0-20240209125211-6c93b0341608 h1:jnInva1KcJJf/QQsxbN9tTJckOZf73EzUen8rrik0Yw=
62+
github.com/dolthub/vitess v0.0.0-20240209125211-6c93b0341608/go.mod h1:IwjNXSQPymrja5pVqmfnYdcy7Uv7eNJNBPK/MEh9OOw=
6363
github.com/dustin/go-humanize v0.0.0-20171111073723-bb3d318650d4/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
6464
github.com/eapache/go-resiliency v1.1.0/go.mod h1:kFI+JgMyC7bLPUVY133qvEBtVayf5mFgVsvEsIPBvNs=
6565
github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21/go.mod h1:+020luEh2TKB4/GOp8oxxtq0Daoen/Cii55CzbTV6DU=

sql/planbuilder/scalar.go

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -243,10 +243,18 @@ func (b *Builder) buildScalar(inScope *scope, e ast.Expr) (ex sql.Expression) {
243243
}
244244
return ret
245245
case ast.InjectedExpr:
246-
if expr, ok := v.Expression.(sql.Expression); ok {
247-
return expr
246+
resolvedChildren := make([]any, len(v.Children))
247+
for i, child := range v.Children {
248+
resolvedChildren[i] = b.buildScalar(inScope, child)
248249
}
249-
b.handleErr(fmt.Errorf("Injected expression is not a valid expression"))
250+
expr, err := v.Expression.WithResolvedChildren(resolvedChildren)
251+
if err != nil {
252+
b.handleErr(err)
253+
}
254+
if sqlExpr, ok := expr.(sql.Expression); ok {
255+
return sqlExpr
256+
}
257+
b.handleErr(fmt.Errorf("Injected expression does not resolve to a valid expression"))
250258
return nil
251259
case *ast.RangeCond:
252260
val := b.buildScalar(inScope, v.Left)

0 commit comments

Comments
 (0)