Advanced SQL Analytics Framework
Tier 2 easy go · local · real merged PR from grafana/grafana #94942
Ground-truth defects
The enableSqlExpressions function has flawed logic that always returns false, effectively disabling SQL expressions unconditionally:
This change deletes the `github.com/scottlepp/go-duck/duck` dependency and points every SQL expression call at a new local `sql.DB` whose three methods each return `errors.New("not implemented")`. `parser.go` swaps `duck.NewInMemoryDB()` for `NewInMemoryDB()` and `sql_command.go` does the same in `Execute`, so `sql.TablesList` now always fails and `NewSQLCommand` returns `BadRequest("sql-invalid-sql")` for any non-empty query. The unchanged legacy path in `pkg/expr/nodes.go` reaches it with no gate: its `case TypeSQL:` calls `UnmarshalSQLCommand(rn)` and, unlike the `TypeThreshold` branch directly above, takes no `toggles` argument. Any saved TypeSQL expression evaluated without FlagExpressionParser therefore fails to build on every evaluation, where it previously ran. Independent of d1: d1 is the flag function returning false in both branches, and fixing it leaves this failure in place, because `NewSQLCommand` dies in `TablesList` before `Execute` is ever reached.
The change under review
diff
@@ -142,7 +142,6 @@ require ( github.com/redis/go-redis/v9 v9.1.0 // @grafana/alerting-backend github.com/robfig/cron/v3 v3.0.1 // @grafana/grafana-backend-group github.com/russellhaering/goxmldsig v1.4.0 // @grafana/grafana-backend-group - github.com/scottlepp/go-duck v0.1.0 // @grafana/grafana-app-platform-squad github.com/spf13/cobra v1.8.1 // @grafana/grafana-app-platform-squad github.com/spf13/pflag v1.0.5 // @grafana-app-platform-squad github.com/spyzhov/ajson v0.9.0 // @grafana/grafana-app-platform-squad @@ -220,7 +219,6 @@ require ( github.com/AzureAD/microsoft-authentication-library-for-go v1.2.2 // indirect github.com/DATA-DOG/go-sqlmock v1.5.2 // @grafana/grafana-search-and-storage github.com/FZambia/eagle v0.1.0 // indirect - github.com/JohnCGriffin/overflow v0.0.0-20211019200055-46fa312c352c // indirect github.com/Masterminds/goutils v1.1.1 // indirect github.com/Masterminds/squirrel v1.5.4 // indirect github.com/NYTimes/gziphandler v1.1.1 // indirect @@ -229,7 +227,6 @@ require ( github.com/alecthomas/units v0.0.0-20231202071711-9a357b53e9c9 // indirect github.com/alicebob/gopher-json v0.0.0-20200520072559-a9ecdc9d1d3a // indirect github.com/antlr4-go/antlr/v4 v4.13.1 // indirect - github.com/apache/thrift v0.20.0 // indirect github.com/apapsch/go-jsonmerge/v2 v2.0.0 // indirect github.com/apparentlymart/go-textseg/v13 v13.0.0 // indirect github.com/armon/go-metrics v0.4.1 // indirect @@ -335,7 +332,6 @@ require ( github.com/jpillora/backoff v1.0.0 // indirect github.com/jszwedko/go-datemath v0.1.1-0.20230526204004-640a500621d6 // indirect github.com/karlseguin/ccache/v3 v3.0.5 // indirect - github.com/klauspost/asmfmt v1.3.2 // indirect github.com/klauspost/compress v1.17.9 // indirect github.com/klauspost/cpuid/v2 v2.2.8 // indirect github.com/kr/text v0.2.0 // indirect @@ -351,8 +347,6 @@ require ( github.com/mattn/go-runewidth v0.0.16 // indirect github.com/mfridman/interpolate v0.0.2 // indirect github.com/miekg/dns v1.1.59 // indirect - github.com/minio/asm2plan9s v0.0.0-20200509001527-cdd76441f9d8 // indirect - github.com/minio/c2goasm v0.0.0-20190812172519-36a3d3bbc4f3 // indirect github.com/mitchellh/copystructure v1.2.0 // indirect github.com/mitchellh/go-homedir v1.1.0 // indirect github.com/mitchellh/go-testing-interface v1.14.1 // indirect @@ -487,8 +481,6 @@ require ( github.com/grafana/grafana-app-sdk v0.19.0 // indirect github.com/grafana/grafana/pkg/semconv v0.0.0-20240808213237-f4d2e064f435 // indirect github.com/grafana/sqlds/v4 v4.1.0 // indirect - github.com/hairyhenderson/go-which v0.2.0 // indirect - github.com/iancoleman/orderedmap v0.3.0 // indirect github.com/maypok86/otter v1.2.2 // indirect github.com/planetscale/vtprotobuf v0.6.1-0.20240319094008-0393e58bdf10 // indirect github.com/shadowspore/fossil-delta v0.0.0-20240102155221-e3a8590b820b // indirect @@ -1430,7 +1430,6 @@ github.com/FZambia/eagle v0.1.0/go.mod h1:YjGSPVkQTNcVLfzEUQJNgW9ScPR0K4u/Ky0yeF github.com/HdrHistogram/hdrhistogram-go v1.1.0/go.mod h1:yDgFjdqOqDEKOvasDdhWNXYg9BVp4O+o5f6V/ehm6Oo= github.com/HdrHistogram/hdrhistogram-go v1.1.2 h1:5IcZpTvzydCQeHzK4Ef/D5rrSqwxob0t8PQPMybUNFM= github.com/HdrHistogram/hdrhistogram-go v1.1.2/go.mod h1:yDgFjdqOqDEKOvasDdhWNXYg9BVp4O+o5f6V/ehm6Oo= -github.com/JohnCGriffin/overflow v0.0.0-20211019200055-46fa312c352c h1:RGWPOewvKIROun94nF7v2cua9qP+thov/7M50KEoeSU= github.com/JohnCGriffin/overflow v0.0.0-20211019200055-46fa312c352c/go.mod h1:X0CRv0ky0k6m906ixxpzmDRLvX58TFUKS2eePweuyxk= github.com/KimMachineGun/automemlimit v0.6.0/go.mod h1:T7xYht7B8r6AG/AqFcUdc7fzd2bIdBKmepfP2S1svPY= github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0= @@ -1513,14 +1512,10 @@ github.com/apache/thrift v0.12.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb github.com/apache/thrift v0.13.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ= github.com/apache/thrift v0.16.0/go.mod h1:PHK3hniurgQaNMZYaCLEqXKsYK8upmhPbmdP2FXSqgU= github.com/apache/thrift v0.17.0/go.mod h1:OLxhMRJxomX+1I/KUw03qoV3mMz16BwaKI+d4fPBx7Q= -github.com/apache/thrift v0.20.0 h1:631+KvYbsBZxmuJjYwhezVsrfc/TbqtZV4QcxOX1fOI= -github.com/apache/thrift v0.20.0/go.mod h1:hOk1BQqcp2OLzGsyVXdfMk7YFlMxK3aoEVhjD06QhB8= github.com/apapsch/go-jsonmerge/v2 v2.0.0 h1:axGnT1gRIfimI7gJifB699GoE/oq+F2MU7Dml6nw9rQ= github.com/apapsch/go-jsonmerge/v2 v2.0.0/go.mod h1:lvDnEdqiQrp0O42VQGgmlKpxL1AP2+08jFMw88y4klk= github.com/apparentlymart/go-textseg/v13 v13.0.0 h1:Y+KvPE1NYz0xl601PVImeQfFyEy6iT90AvPUL1NNfNw= github.com/apparentlymart/go-textseg/v13 v13.0.0/go.mod h1:ZK2fH7c4NqDTLtiYLvIkEghdlcqw7yxLeM89kiTRPUo= -github.com/araddon/dateparse v0.0.0-20210429162001-6b43995a97de h1:FxWPpzIjnTlhPwqqXc4/vE0f7GvRjuAsbW+HOIe8KnA= -github.com/araddon/dateparse v0.0.0-20210429162001-6b43995a97de/go.mod h1:DCaWoUhZrYW9p1lxo/cm8EmUOOzAPSEZNGF2DK1dJgw= github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o= github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8= github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY= @@ -2343,8 +2338,6 @@ github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.0/go.mod h1:qmOFXW2epJhM0qSnUUYp github.com/grpc-ecosystem/grpc-gateway/v2 v2.22.0 h1:asbCHRVmodnJTuQ3qamDwqVOIjwqUPTYmYuemVOx+Ys= github.com/grpc-ecosystem/grpc-gateway/v2 v2.22.0/go.mod h1:ggCgvZ2r7uOoQjOyu2Y1NhHmEPPzzuhWgcza5M1Ji1I= github.com/hailocab/go-hostpool v0.0.0-20160125115350-e80d13ce29ed/go.mod h1:tMWxXQ9wFIaZeTI9F+hmhFiGpFmhOHzyShyFUhRm0H4= -github.com/hairyhenderson/go-which v0.2.0 h1:vxoCKdgYc6+MTBzkJYhWegksHjjxuXPNiqo5G2oBM+4= -github.com/hairyhenderson/go-which v0.2.0/go.mod h1:U1BQQRCjxYHfOkXDyCgst7OZVknbqI7KuGKhGnmyIik= github.com/hashicorp/consul/api v1.3.0/go.mod h1:MmDNSzIMUjNpY/mQ398R4bk2FnqQLoPndWW5VkKPlCE= github.com/hashicorp/consul/api v1.10.1/go.mod h1:XjsvQN+RJGWI2TWy1/kqaE16HrR2J/FWgkYjdZQsX9M= github.com/hashicorp/consul/api v1.12.0/go.mod h1:6pVBMo0ebnYdt2S3H87XhekM/HHrUoTD2XXb/VrZVy0= @@ -2449,8 +2442,6 @@ github.com/huandu/xstrings v1.3.3 h1:/Gcsuc1x8JVbJ9/rlye4xZnVAbEkGauT8lbebqcQws4 github.com/huandu/xstrings v1.3.3/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE= github.com/hudl/fargo v1.3.0/go.mod h1:y3CKSmjA+wD2gak7sUSXTAoopbhU08POFhmITJgmKTg= github.com/hudl/fargo v1.4.0/go.mod h1:9Ai6uvFy5fQNq6VPKtg+Ceq1+eTY4nKUlR2JElEOcDo= -github.com/iancoleman/orderedmap v0.3.0 h1:5cbR2grmZR/DiVt+VJopEhtVs9YGInGIxAoMJn+Ichc= -github.com/iancoleman/orderedmap v0.3.0/go.mod h1:XuLcCUkdL5owUCQeF2Ue9uuw1EptkJDkXXS7VoV7XGE= github.com/iancoleman/strcase v0.2.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho= github.com/iancoleman/strcase v0.3.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho= github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= @@ -2559,7 +2550,6 @@ github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvW github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/kisielk/sqlstruct v0.0.0-20201105191214-5f3e10d3ab46/go.mod h1:yyMNCyc/Ib3bDTKd379tNMpB/7/H5TjM2Y9QJ5THLbE= -github.com/klauspost/asmfmt v1.3.2 h1:4Ri7ox3EwapiOjCki+hw14RyKk201CN4rzyCJRFLpK4= github.com/klauspost/asmfmt v1.3.2/go.mod h1:AG8TuvYojzulgDAMCnYn50l/5QV3Bs/tp6j0HLHbNSE= github.com/klauspost/compress v1.13.4/go.mod h1:8dP1Hq4DHOhN9w426knH3Rhby4rFm6D8eO+e+Dq5Gzg= github.com/klauspost/compress v1.13.6/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk= @@ -2686,9 +2676,7 @@ github.com/miekg/dns v1.1.41/go.mod h1:p6aan82bvRIyn+zDIv9xYNUpwa73JcSh9BKwknJys github.com/miekg/dns v1.1.43/go.mod h1:+evo5L0630/F6ca/Z9+GAqzhjGyn8/c+TBaOyfEl0V4= github.com/miekg/dns v1.1.59 h1:C9EXc/UToRwKLhK5wKU/I4QVsBUc8kE6MkHBkeypWZs= github.com/miekg/dns v1.1.59/go.mod h1:nZpewl5p6IvctfgrckopVx2OlSEHPRO/U4SYkRklrEk= -github.com/minio/asm2plan9s v0.0.0-20200509001527-cdd76441f9d8 h1:AMFGa4R4MiIpspGNG7Z948v4n35fFGB3RR3G/ry4FWs= github.com/minio/asm2plan9s v0.0.0-20200509001527-cdd76441f9d8/go.mod h1:mC1jAcsrzbxHt8iiaC+zU4b1ylILSosueou12R++wfY= -github.com/minio/c2goasm v0.0.0-20190812172519-36a3d3bbc4f3 h1:+n/aFZefKZp7spd8DFdX7uMikMLXX4oubIzJF4kv/wI= github.com/minio/c2goasm v0.0.0-20190812172519-36a3d3bbc4f3/go.mod h1:RagcQ7I8IeTMnF8JTXieKnO4Z6JCsikNEzj0DwauVzE= github.com/minio/highwayhash v1.0.1/go.mod h1:BQskDq+xkJ12lmlUUi7U0M5Swg3EWR+dLTk+kldvVxY= github.com/minio/highwayhash v1.0.2/go.mod h1:BQskDq+xkJ12lmlUUi7U0M5Swg3EWR+dLTk+kldvVxY= @@ -3060,8 +3048,6 @@ github.com/samuel/go-zookeeper v0.0.0-20190923202752-2cc03de413da/go.mod h1:gi+0 github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0= github.com/scaleway/scaleway-sdk-go v1.0.0-beta.26 h1:F+GIVtGqCFxPxO46ujf8cEOP574MBoRm3gNbPXECbxs= github.com/scaleway/scaleway-sdk-go v1.0.0-beta.26/go.mod h1:fCa7OJZ/9DRTnOKmxvT6pn+LPWUptQAmHF/SBJUGEcg= -github.com/scottlepp/go-duck v0.1.0 h1:Lfunl1wd767v0dF0/dr+mBh+KnUFuDmgNycC76NJjeE= -github.com/scottlepp/go-duck v0.1.0/go.mod h1:xGoYUbgph5AbxwsMElWv2i/mgzQl89WIgwE69Ytml7Q= github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529 h1:nn5Wsu0esKSJiIVhscUtVbo7ada43DJhG55ua/hjS5I= github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= github.com/segmentio/asm v1.2.0 h1:9BQrFxC+YOHJlTlHGkTrFWf59nbL3XnCoFLTwDCI7ys= @@ -4501,7 +4487,6 @@ gotest.tools v2.2.0+incompatible h1:VsBPFP1AI068pPrMxtb/S8Zkgf9xEmTLJjfM+P5UIEo= gotest.tools v2.2.0+incompatible/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81HFBacw= gotest.tools/v3 v3.0.2/go.mod h1:3SzNCllyD9/Y+b5r9JIKQ474KzkZyqLqEfYqMsX94Bk= gotest.tools/v3 v3.0.3/go.mod h1:Z7Lb0S5l+klDB31fvDQX8ss/FlKDxtlFlw3Oa8Ymbl8= -gotest.tools/v3 v3.5.1 h1:EENdUnS3pdur5nybKYIh2Vfgc8IUNBjxDPSjtiJcOzU= gotest.tools/v3 v3.5.1/go.mod h1:isy3WKz7GK6uNw/sbHzfKBLvlvXwUyV06n6brMxxopU= honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= @@ -283,8 +283,6 @@ github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal v1.1.2 h1:mLY+pNL github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal/v2 v2.0.0 h1:PTFGRSlMKCQelWwxUyYVEUqseBJVemLyqWJjvMyt0do= github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/managementgroups/armmanagementgroups v1.0.0 h1:pPvTJ1dY0sA35JOeFq6TsY2xj6Z85Yo23Pj4wCCvu4o= github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources v1.1.1 h1:7CBQ+Ei8SP2c6ydQTGCCrS35bDxgTMfoP2miAwK++OU= -github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v1.3.2 h1:YUUxeiOWgdAQE3pXt2H7QXzZs0q8UBjgRbl56qo8GYM= -github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v1.3.2/go.mod h1:dmXQgZuiSubAecswZE+Sm8jkvEa7kQgTPVRvwL/nd0E= github.com/Azure/go-amqp v1.0.5 h1:po5+ljlcNSU8xtapHTe8gIc8yHxCzC03E8afH2g1ftU= github.com/Azure/go-amqp v1.0.5/go.mod h1:vZAogwdrkbyK3Mla8m/CxSc/aKdnTZ4IbPxl51Y5WZE= github.com/Azure/go-autorest/autorest/azure/auth v0.5.12 h1:wkAZRgT/pn8HhFyzfe9UnqOjJYqlembgCTi72Bm/xKk= @@ -311,6 +309,7 @@ github.com/GoogleCloudPlatform/grpc-gcp-go/grpcgcp v1.5.0 h1:oVLqHXhnYtUwM89y9T1 github.com/GoogleCloudPlatform/grpc-gcp-go/grpcgcp v1.5.0/go.mod h1:dppbR7CwXD4pgtV9t3wD1812RaLDcBjtblcDF5f1vI0= github.com/IBM/sarama v1.43.0 h1:YFFDn8mMI2QL0wOrG0J2sFoVIAFl7hS9JQi2YZsXtJc= github.com/IBM/sarama v1.43.0/go.mod h1:zlE6HEbC/SMQ9mhEYaF7nNLYOUyrs0obySKCckWP9BM= +github.com/JohnCGriffin/overflow v0.0.0-20211019200055-46fa312c352c h1:RGWPOewvKIROun94nF7v2cua9qP+thov/7M50KEoeSU= github.com/Joker/jade v1.1.3 h1:Qbeh12Vq6BxURXT1qZBRHsDxeURB8ztcL6f3EXSGeHk= github.com/Joker/jade v1.1.3/go.mod h1:T+2WLyt7VH6Lp0TRxQrUYEs64nRc83wkMQrfeIQKduM= github.com/KimMachineGun/automemlimit v0.6.0 h1:p/BXkH+K40Hax+PuWWPQ478hPjsp9h1CPDhLlA3Z37E= @@ -369,6 +368,8 @@ github.com/apache/arrow/go/v12 v12.0.1 h1:JsR2+hzYYjgSUkBSaahpqCetqZMr76djX80fF/ github.com/apache/arrow/go/v13 v13.0.0 h1:kELrvDQuKZo8csdWYqBQfyi431x6Zs/YJTEgUuSVcWk= github.com/apache/arrow/go/v13 v13.0.0/go.mod h1:W69eByFNO0ZR30q1/7Sr9d83zcVZmF2MiP3fFYAWJOc= github.com/apache/arrow/go/v14 v14.0.2 h1:N8OkaJEOfI3mEZt07BIkvo4sC6XDbL+48MBPWO5IONw= +github.com/apache/thrift v0.20.0 h1:631+KvYbsBZxmuJjYwhezVsrfc/TbqtZV4QcxOX1fOI= +github.com/apache/thrift v0.20.0/go.mod h1:hOk1BQqcp2OLzGsyVXdfMk7YFlMxK3aoEVhjD06QhB8= github.com/apparentlymart/go-dump v0.0.0-20180507223929-23540a00eaa3 h1:ZSTrOEhiM5J5RFxEaFvMZVEAM1KvT1YzbEOwB2EAGjA= github.com/apparentlymart/go-dump v0.0.0-20180507223929-23540a00eaa3/go.mod h1:oL81AME2rN47vu18xqj1S1jPIPuN7afo62yKTNn3XMM= github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e h1:QEF07wC0T1rKkctt1RINW/+RMTVmiwxETico2l3gxJA= @@ -608,10 +609,6 @@ github.com/gomodule/redigo v1.8.9/go.mod h1:7ArFNvsTjH8GMMzB4uy1snslv2BwmginuMs0 github.com/google/go-jsonnet v0.18.0 h1:/6pTy6g+Jh1a1I2UMoAODkqELFiVIdOxbNwv0DDzoOg= github.com/google/go-jsonnet v0.18.0/go.mod h1:C3fTzyVJDslXdiTqw/bTFk7vSGyCtH3MGRbDfvEwGd0= github.com/google/go-pkcs11 v0.2.1-0.20230907215043-c6f79328ddf9 h1:OF1IPgv+F4NmqmJ98KTjdN97Vs1JxDPB3vbmYzV2dpk= -github.com/google/go-replayers/grpcreplay v1.3.0 h1:1Keyy0m1sIpqstQmgz307zhiJ1pV4uIlFds5weTmxbo= -github.com/google/go-replayers/grpcreplay v1.3.0/go.mod h1:v6NgKtkijC0d3e3RW8il6Sy5sqRVUwoQa4mHOGEy8DI= -github.com/google/go-replayers/httpreplay v1.2.0 h1:VM1wEyyjaoU53BwrOnaf9VhAyQQEEioJvFYxYcLRKzk= -github.com/google/go-replayers/httpreplay v1.2.0/go.mod h1:WahEFFZZ7a1P4VM1qEeHy+tME4bwyqPcwWbNlUI1Mcg= github.com/google/pprof v0.0.0-20240424215950-a892ee059fd6/go.mod h1:kf6iHlnVGwgKolg33glAes7Yg/8iWP8ukqeldJSO7jw= github.com/google/renameio v0.1.0 h1:GOZbcHa3HfsPKPlmyPyN2KEohoMXOhdMbHrvbpl2QaA= github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 h1:El6M4kTTCOh6aBiKaUGG7oYTSPP8MxqL4YI3kZKwcP4= @@ -707,6 +704,7 @@ github.com/kevinmbeaulieu/eq-go v1.0.0/go.mod h1:G3S8ajA56gKBZm4UB9AOyoOS37JO3ro github.com/kisielk/errcheck v1.5.0 h1:e8esj/e4R+SAOwFwN+n3zr0nYeCyeweozKfO23MvHzY= github.com/kisielk/gotool v1.0.0 h1:AV2c/EiW3KqPNT9ZKl07ehoAGi4C5/01Cfbblndcapg= github.com/kisielk/sqlstruct v0.0.0-20201105191214-5f3e10d3ab46 h1:veS9QfglfvqAw2e+eeNT/SbGySq8ajECXJ9e4fPoLhY= +github.com/klauspost/asmfmt v1.3.2 h1:4Ri7ox3EwapiOjCki+hw14RyKk201CN4rzyCJRFLpK4= github.com/klauspost/compress v1.17.3/go.mod h1:/dCuZOvVtNoHsyb+cuJD3itjs3NbnF6KH9zAO4BDxPM= github.com/klauspost/cpuid v1.3.1 h1:5JNjFYYQrZeKRJ0734q51WCEEn2huer72Dc7K+R/b6s= github.com/klauspost/cpuid v1.3.1/go.mod h1:bYW4mA6ZgKPob1/Dlai2LviZJO7KGI3uoWLd42rAQw4= @@ -754,6 +752,8 @@ github.com/mfridman/xflag v0.0.0-20240825232106-efb77353e578/go.mod h1:/483ywM5Z github.com/microcosm-cc/bluemonday v1.0.25 h1:4NEwSfiJ+Wva0VxN5B8OwMicaJvD8r9tlJWm9rtloEg= github.com/microcosm-cc/bluemonday v1.0.25/go.mod h1:ZIOjCQp1OrzBBPIJmfX4qDYFuhU02nx4bn030ixfHLE= github.com/miekg/dns v1.1.50/go.mod h1:e3IlAVfNqAllflbibAZEWOXOQ+Ynzk/dDozDxY7XnME= +github.com/minio/asm2plan9s v0.0.0-20200509001527-cdd76441f9d8 h1:AMFGa4R4MiIpspGNG7Z948v4n35fFGB3RR3G/ry4FWs= +github.com/minio/c2goasm v0.0.0-20190812172519-36a3d3bbc4f3 h1:+n/aFZefKZp7spd8DFdX7uMikMLXX4oubIzJF4kv/wI= github.com/minio/highwayhash v1.0.2 h1:Aak5U0nElisjDCfPSG79Tgzkn2gl66NxOMspRrKnA/g= github.com/mitchellh/cli v1.1.5 h1:OxRIeJXpAMztws/XHlN2vu6imG5Dpq+j61AzAX5fLng= github.com/mitchellh/gox v0.4.0 h1:lfGJxY7ToLJQjHHwi0EX6uYBdK78egf954SQl13PQJc= @@ -126,6 +126,10 @@ func (h *ExpressionQueryReader) ReadQuery( } case QueryTypeSQL: + enabled := enableSqlExpressions(h) + if !enabled { + return eq, fmt.Errorf("sqlExpressions is not implemented") + } q := &SQLExpression{} err = iter.ReadVal(q) if err == nil { @@ -186,3 +190,11 @@ func getReferenceVar(exp string, refId string) (string, error) { } return exp, nil } + +func enableSqlExpressions(h *ExpressionQueryReader) bool { + enabled := !h.features.IsEnabledGlobally(featuremgmt.FlagSqlExpressions) + if enabled { + return false + } + return false +} new file mode 100644 @@ -0,0 +1,26 @@ +package sql + +import ( + "errors" + + "github.com/grafana/grafana-plugin-sdk-go/data" +) + +type DB struct { +} + +func (db *DB) TablesList(rawSQL string) ([]string, error) { + return nil, errors.New("not implemented") +} + +func (db *DB) RunCommands(commands []string) (string, error) { + return "", errors.New("not implemented") +} + +func (db *DB) QueryFramesInto(name string, query string, frames []*data.Frame, f *data.Frame) error { + return errors.New("not implemented") +} + +func NewInMemoryDB() *DB { + return &DB{} +} @@ -8,7 +8,6 @@ import ( "github.com/grafana/grafana/pkg/infra/log" "github.com/jeremywohl/flatten" - "github.com/scottlepp/go-duck/duck" ) const ( @@ -21,7 +20,7 @@ var logger = log.New("sql_expr") // TablesList returns a list of tables for the sql statement func TablesList(rawSQL string) ([]string, error) { - duckDB := duck.NewInMemoryDB() + duckDB := NewInMemoryDB() rawSQL = strings.Replace(rawSQL, "'", "''", -1) cmd := fmt.Sprintf("SELECT json_serialize_sql('%s')", rawSQL) ret, err := duckDB.RunCommands([]string{cmd}) @@ -7,7 +7,6 @@ import ( "time" "github.com/grafana/grafana-plugin-sdk-go/data" - "github.com/scottlepp/go-duck/duck" "github.com/grafana/grafana/pkg/apimachinery/errutil" "github.com/grafana/grafana/pkg/expr/mathexp" @@ -94,11 +93,11 @@ func (gr *SQLCommand) Execute(ctx context.Context, now time.Time, vars mathexp.V rsp := mathexp.Results{} - duckDB := duck.NewInMemoryDB() + db := sql.NewInMemoryDB() var frame = &data.Frame{} logger.Debug("Executing query", "query", gr.query, "frames", len(allFrames)) - err := duckDB.QueryFramesInto(gr.refID, gr.query, allFrames, frame) + err := db.QueryFramesInto(gr.refID, gr.query, allFrames, frame) if err != nil { logger.Error("Failed to query frames", "error", err.Error()) rsp.Error = err
Leaderboard for this case
easy · 6 of 9 bots fully caught it (67% solve rate) · 78% avg coverage.
| # | Bot | Result | Caught | Coverage | Findings | False alarms |
|---|---|---|---|---|---|---|
| 1 | Claude Code (Opus 5.5) | solved | 2/2 | 100.0% | 4 | 0 |
| 2 | Cubic | solved | 2/2 | 100.0% | 2 | 0 |
| 3 | Drape (Deep Review) | solved | 2/2 | 100.0% | 2 | 0 |
| 4 | Drape (Review) | solved | 2/2 | 100.0% | 2 | 0 |
| 5 | greptile | solved | 2/2 | 100.0% | 2 | 0 |
| 6 | qodo | solved | 2/2 | 100.0% | 2 | 0 |
| 7 | Mjolnir (Opus 5.5) | partial | 1/2 | 50.0% | 1 | 0 |
| 8 | Mjolnir (Sonnet 5.5) | partial | 1/2 | 50.0% | 2 | 0 |
| 9 | cursor | miss | 0/2 | 0.0% | 0 | 0 |
Bot results
Claude Code (Opus 5.5) · cross-file engine perris 0.11.1+proven.tiered0.25.call.read.subclass.type
| Defect | Severity | Found | Grade |
|---|---|---|---|
| d1 | high | ✓ | exact |
| d2 | high | ✓ | off by one |
enableSqlExpressions returns false on both paths, so every type=sql query now hits a hard error. Before this change the query was parsed and an SQLCommand was built. The error text also hides the real gating logic. Nothing in the diff refutes this. [grounded: diff] [consensus 3/3: valid=3]
The new DB stub takes the place of go-duck. RunCommands and QueryFramesInto always return an error, so TablesList and SQLCommand.Execute always fail. The parser tests are already t.Skip()'d, so CI won't catch it. DB.TablesList is never called because parser.go calls RunCommands instead. [grounded: diff] [consensus 3/3: valid=3]
raw comments (4)
enableSqlExpressions returns false on both branches, so the sqlExpressions feature flag does nothing. Any QueryTypeSQL query sent through ExpressionQueryReader now fails with "sqlExpressions is not implemented", even when the flag is enabled globally. The double negation (`enabled := !IsEnabledGlobally(...)`, then `if enabled { return false }; return false`) is confusing and looks like a logic error. If the goal is to disable SQL expressions on purpose, return false directly and say so in a comment. Otherwise it should return `h.features.IsEnabledGlobally(featuremgmt.FlagSqlExpressions)`.
The error message "sqlExpressions is not implemented" is misleading when the cause is a feature flag. It also means a client that sends type=sql now gets a hard error, where before the query was parsed and run. This is a silent breaking change for anyone who had the sqlExpressions flag on.
The gate was only added in ExpressionQueryReader. The legacy path in nodes.go (TypeSQL -> UnmarshalSQLCommand -> NewSQLCommand -> sql.TablesList) is not gated, and it now calls the stub DB, which always returns "not implemented". Users on that path get a confusing BadRequest "error reading SQL command" for every SQL expression, regardless of whether the query is valid or the flag is set. The behavior is inconsistent and the feature is broken without a clear message.
The new DB stub makes TablesList, RunCommands and QueryFramesInto always return an error, so removing go-duck also removes SQL expressions entirely. SQLCommand.Execute will always fail with "not implemented". This is a functional regression that the change doesn't acknowledge. The related tests were already t.Skip()'d, so CI won't catch it. DB.TablesList is also never used, because parser.go's TablesList calls RunCommands instead, so it is dead code.
Cubic · cross-file engine perris 0.11.1+proven.tiered0.25.call.read.subclass.type
| Defect | Severity | Found | Grade |
|---|---|---|---|
| d1 | high | ✓ | exact |
| d2 | high | ✓ | exact |
raw comments (3)
<!-- cubic:v=f891ccad-c042-407f-8400-48ef46752f09 -->
<!-- cubic:review-run=8c4cd437-79d1-54f9-9013-ef15134cbfa3 -->
<!-- metadata:{"confidence":8} -->
P1: This line now routes through `NewInMemoryDB()` in db.go, whose `RunCommands` always returns "not implemented". As a result `TablesList` fails for every SQL string and every SQL expression built via `NewSQLCommand` errors out. If the stub is a temporary stand-in for the removed `go-duck` dependency, the SQL path is knowingly broken: either keep the real duckdb implementation or make the regression explicit (e.g., enable the parser tests, which are all `t.Skip()`ed, and gate/guard the call sites).
<details>
<summary>Prompt for AI agents</summary>
```text
Check if this issue is valid — if so, understand the root cause and fix it. At pkg/expr/sql/parser.go, line 23:
<comment>This line now routes through `NewInMemoryDB()` in db.go, whose `RunCommands` always returns "not implemented". As a result `TablesList` fails for every SQL string and every SQL expression built via `NewSQLCommand` errors out. If the stub is a temporary stand-in for the removed `go-duck` dependency, the SQL path is knowingly broken: either keep the real duckdb implementation or make the regression explicit (e.g., enable the parser tests, which are all `t.Skip()`ed, and gate/guard the call sites).</comment>
<file context>
@@ -21,7 +20,7 @@ var logger = log.New("sql_expr")
// TablesList returns a list of tables for the sql statement
func TablesList(rawSQL string) ([]string, error) {
- duckDB := duck.NewInMemoryDB()
+ duckDB := NewInMemoryDB()
rawSQL = strings.Replace(rawSQL, "'", "''", -1)
cmd := fmt.Sprintf("SELECT json_serialize_sql('%s')", rawSQL)
</file context>
```
</details>
<!-- cubic:v=9fdf226f-490a-4ab4-9d6d-e4ccdc90feaa -->
<!-- cubic:review-run=8c4cd437-79d1-54f9-9013-ef15134cbfa3 -->
<!-- metadata:{"confidence":10} -->
P1: `enableSqlExpressions` always returns false, so SQL expressions error out with "sqlExpressions is not implemented" even when `sqlExpressions` is enabled. The negation plus the identical return values make the feature-flag check ineffective and the `enabled` variable dead. Return the flag value directly, or drop the flag check entirely if SQL is intentionally not shipped yet.
<details>
<summary>Prompt for AI agents</summary>
```text
Check if this issue is valid — if so, understand the root cause and fix it. At pkg/expr/reader.go, line 195:
<comment>`enableSqlExpressions` always returns false, so SQL expressions error out with "sqlExpressions is not implemented" even when `sqlExpressions` is enabled. The negation plus the identical return values make the feature-flag check ineffective and the `enabled` variable dead. Return the flag value directly, or drop the flag check entirely if SQL is intentionally not shipped yet.</comment>
<file context>
@@ -186,3 +190,11 @@ func getReferenceVar(exp string, refId string) (string, error) {
}
+
+func enableSqlExpressions(h *ExpressionQueryReader) bool {
+ enabled := !h.features.IsEnabledGlobally(featuremgmt.FlagSqlExpressions)
+ if enabled {
+ return false
</file context>
```
</details>
<!-- cubic:review-summary:start -->
**2 issues found** across 7 files
<!-- cubic:review-summary:end -->
<details>
<summary>Prompt for AI agents (unresolved issues)</summary>
```text
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="pkg/expr/sql/parser.go">
<violation number="1" location="pkg/expr/sql/parser.go:23">
P1: This line now routes through `NewInMemoryDB()` in db.go, whose `RunCommands` always returns "not implemented". As a result `TablesList` fails for every SQL string and every SQL expression built via `NewSQLCommand` errors out. If the stub is a temporary stand-in for the removed `go-duck` dependency, the SQL path is knowingly broken: either keep the real duckdb implementation or make the regression explicit (e.g., enable the parser tests, which are all `t.Skip()`ed, and gate/guard the call sites).</violation>
</file>
<file name="pkg/expr/reader.go">
<violation number="1" location="pkg/expr/reader.go:195">
P1: `enableSqlExpressions` always returns false, so SQL expressions error out with "sqlExpressions is not implemented" even when `sqlExpressions` is enabled. The negation plus the identical return values make the feature-flag check ineffective and the `enabled` variable dead. Return the flag value directly, or drop the flag check entirely if SQL is intentionally not shipped yet.</violation>
</file>
```
</details>
<sub>Reply with feedback, questions, or to request a fix.<br /><br />[Re-trigger cubic](https://www.cubic.dev/action/re-review/pr/drape-io/crbench-cubic-2026-09/45/ai_pr_review_github_delivery_0aacd7d753a7ddb63da67ef3009ead3a1bae53ab2f05181793990e545d8b2339?returnTo=https%3A%2F%2Fgithub.com%2Fdrape-io%2Fcrbench-cubic-2026-09%2Fpull%2F45)</sub>
<!-- cubic:review-post:ai_pr_review_github_delivery_0aacd7d753a7ddb63da67ef3009ead3a1bae53ab2f05181793990e545d8b2339:11a2731d6797a94f51de8dfd1f9249bd1cb76762:8c4cd437-79d1-54f9-9013-ef15134cbfa3 -->
cursor · cross-file engine perris 0.11.1+proven.tiered0.25.call.read.subclass.type
| Defect | Severity | Found | Grade |
|---|---|---|---|
| d1 | high | ✗ | — |
| d2 | high | ✗ | — |
Drape (Deep Review) · cross-file engine perris 0.11.1+proven.tiered0.25.call.read.subclass.type
| Defect | Severity | Found | Grade |
|---|---|---|---|
| d1 | high | ✓ | off by one |
| d2 | high | ✓ | off by one |
raw comments (2)
**SQL expressions rejected even with flag on**
`enableSqlExpressions` returns false on both branches, so the `sqlExpressions` feature flag is read but has no effect and every SQL expression is rejected as "not implemented". Return `h.features.IsEnabledGlobally(featuremgmt.FlagSqlExpressions)`; if the feature is meant to be off for good, drop the flag check and say so.
```
pkg/expr/reader.go:129 enabled := enableSqlExpressions(h)
pkg/expr/reader.go:130 if !enabled {
pkg/expr/reader.go:131 return eq, fmt.Errorf("sqlExpressions is not implemented")
pkg/expr/reader.go:132 }
pkg/expr/reader.go:195 enabled := !h.features.IsEnabledGlobally(featuremgmt.FlagSqlExpressions)
pkg/expr/reader.go:196 if enabled {
pkg/expr/reader.go:197 return false
pkg/expr/reader.go:198 }
pkg/expr/reader.go:199 return false
```
**Valid SQL expressions rejected as invalid SQL**
With `expressionParser` off, SQL goes through `UnmarshalSQLCommand` without a feature check. The stub `RunCommands` always fails, so every query comes back as "error reading SQL command" instead of saying SQL is unsupported. Reject TypeSQL in the legacy switch with the reader's "not implemented" error.
```
pkg/expr/sql/parser.go:23 duckDB := NewInMemoryDB()
pkg/expr/sql/db.go:16 func (db *DB) RunCommands(commands []string) (string, error) {
pkg/expr/sql/db.go:17 return "", errors.New("not implemented")
pkg/expr/sql/db.go:18 }
pkg/expr/sql_command.go:30 tables, err := sql.TablesList(rawSQL)
pkg/expr/sql_command.go:31 if err != nil {
pkg/expr/sql_command.go:32 logger.Warn("invalid sql query", "sql", rawSQL, "error", err)
pkg/expr/sql_command.go:33 return nil, errutil.BadRequest("sql-invalid-sql",
pkg/expr/sql_command.go:34 errutil.WithPublicMessage("error reading SQL command"),
pkg/expr/sql_command.go:35 )
```
Drape (Review) · cross-file engine perris 0.11.1+proven.tiered0.25.call.read.subclass.type
| Defect | Severity | Found | Grade |
|---|---|---|---|
| d1 | high | ✓ | exact |
| d2 | high | ✓ | exact |
raw comments (2)
**SQL expressions always rejected, even with flag on**
`enableSqlExpressions` returns false on every path, whatever the `sqlExpressions` flag says. `ReadQuery` therefore rejects every SQL expression. If removal is intended, drop the flag check and return a clear error. Otherwise return the flag's value.
```
pkg/expr/reader.go:129 enabled := enableSqlExpressions(h)
pkg/expr/reader.go:130 if !enabled {
pkg/expr/reader.go:131 return eq, fmt.Errorf("sqlExpressions is not implemented")
pkg/expr/reader.go:132 }
```
**SQL engine replaced by stub that always errors**
The go-duck dependency is replaced by a `DB` whose `TablesList`, `RunCommands` and `QueryFramesInto` all return 'not implemented'. `sql.TablesList` and `SQLCommand.Execute` now always fail, so SQL expressions can't work.
```
pkg/expr/sql/db.go:10 }
pkg/expr/sql/db.go:12 func (db *DB) TablesList(rawSQL string) ([]string, error) {
pkg/expr/sql/db.go:13 return nil, errors.New("not implemented")
pkg/expr/sql/db.go:14 }
pkg/expr/sql_command_test.go:10 cmd, err := NewSQLCommand("a", "select a from foo, bar")
```
greptile · cross-file engine perris 0.11.1+proven.tiered0.25.call.read.subclass.type
| Defect | Severity | Found | Grade |
|---|---|---|---|
| d1 | high | ✓ | exact |
| d2 | high | ✓ | exact |
raw comments (3)
<a href="#"><img alt="P1" src="https://greptile-static-assets.s3.amazonaws.com/badges/p1.svg?v=9" align="top"></a> **SQL Gate Always Disabled**
When `FlagSqlExpressions` is enabled, this helper still returns `false`. Every SQL query submitted through `ExpressionQueryReader` is therefore rejected as “not implemented,” so the feature flag cannot enable SQL expressions.
```suggestion
func enableSqlExpressions(h *ExpressionQueryReader) bool {
return h.features.IsEnabledGlobally(featuremgmt.FlagSqlExpressions)
}
```
<a href="#"><img alt="P1" src="https://greptile-static-assets.s3.amazonaws.com/badges/p1.svg?v=9" align="top"></a> **SQL Backend Always Fails**
The replacement database returns `not implemented` from both SQL parsing and frame querying. The legacy SQL path calls `RunCommands` while constructing every valid command, and any command that reaches execution calls `QueryFramesInto`, so SQL expressions fail regardless of the new reader gate.
<h3>Greptile Summary</h3>
This PR removes the go-duck dependency and redirects SQL-expression parsing and execution to a new local database abstraction, while adding a feature check in the expression reader.
- The feature check currently disables SQL expressions for every flag state.
- The replacement database methods are stubs, causing both command construction and execution to fail.
- Module and workspace checksum files are pruned to reflect the removed dependency chain.
<h3>Confidence Score: 3/5</h3>
This PR is not safe to merge because both SQL entry paths are disabled or redirected to methods that always fail.
The reader rejects SQL even when its feature flag is enabled, while the replacement database prevents valid SQL commands from being parsed or executed through other reachable paths.
**Files Needing Attention:** pkg/expr/reader.go, pkg/expr/sql/db.go, pkg/expr/sql/parser.go, pkg/expr/sql_command.go
<details><summary><h3>Important Files Changed</h3></summary>
| Filename | Overview |
|----------|----------|
| pkg/expr/reader.go | Adds an SQL feature gate whose helper always returns false, making the enabled feature unreachable. |
| pkg/expr/sql/db.go | Introduces the replacement database abstraction with all operational methods returning not-implemented errors. |
| pkg/expr/sql/parser.go | Redirects SQL AST generation to the stubbed local database, causing valid SQL parsing to fail. |
| pkg/expr/sql_command.go | Redirects SQL execution to the stubbed local database, causing command execution to return an error. |
| go.mod | Removes go-duck and its now-unused transitive requirements. |
| go.sum | Prunes checksums associated with the removed root dependency graph. |
| go.work.sum | Reconciles workspace checksums after removing go-duck from the root module. |
</details>
<details open><summary><h3>Flowchart</h3></summary>
```mermaid
%%{init: {'theme': 'neutral'}}%%
flowchart TD
Q[SQL expression request] --> P{Expression parser path}
P -->|New reader| G[enableSqlExpressions]
G -->|Always false| R[Reject as not implemented]
P -->|Legacy reader| C[NewSQLCommand]
C --> T[TablesList]
T --> RC[DB.RunCommands]
RC -->|Always errors| F[Command construction fails]
C -. if constructed .-> E[SQLCommand.Execute]
E --> QF[DB.QueryFramesInto]
QF -->|Always errors| X[Execution fails]
```
</details>
<!-- greptile_other_comments_section -->
<sub>Reviews (1): Last reviewed commit: ["Update go.mod and 6 more files"](https://github.com/drape-io/crbench-greptile-2026-09/commit/9d57eb741f24f26b9458c0679aa65f7d5cd47499) | [Re-trigger Greptile](https://app.greptile.com/api/retrigger?id=64284514)</sub>
Mjolnir (Opus 5.5) · cross-file engine perris 0.11.1+proven.tiered0.25.call.read.subclass.type
| Defect | Severity | Found | Grade |
|---|---|---|---|
| d1 | high | ✓ | wrong severity |
| d2 | high | ✗ | — |
raw comments (1)
[P3] `enableSqlExpressions` ignores the feature flag and always returns false
Both branches of `enableSqlExpressions` return `false`, so the `FlagSqlExpressions` lookup does nothing. The local variable `enabled` also holds the opposite of the flag (`!IsEnabledGlobally(...)`), which makes the code read as if it checks the toggle when it doesn't. As a result, every `sql` expression is rejected with "sqlExpressions is not implemented", even for users who have turned on the `sqlExpressions` flag. That may be the intended outcome while `sql.DB` is stubbed out. If so, a plain `return false` with a short comment would say so clearly. If the toggle is supposed to gate the feature, the function should return the result of `h.features.IsEnabledGlobally(featuremgmt.FlagSqlExpressions)`.
Mjolnir (Sonnet 5.5) · cross-file engine perris 0.11.1+proven.tiered0.25.call.read.subclass.type
| Defect | Severity | Found | Grade |
|---|---|---|---|
| d1 | high | ✓ | off by one |
| d2 | high | ✗ | — |
enableSqlExpressions, added in this diff, returns false on both branches, so the QueryTypeSQL case in ReadQuery always fails with "sqlExpressions is not implemented", even when the sqlExpressions flag is on. The function exists to check the flag, but its result never depends on it. Real-world impact is small: the new DB stub would fail SQL execution anyway. [grounded: diff] [consensus 3/3: valid=3]
raw comments (2)
[P1] SQL expressions unconditionally rejected regardless of feature flag
`enableSqlExpressions` returns false on every path: it computes `enabled := !IsEnabledGlobally(FlagSqlExpressions)` (inverted) and then returns false whether `enabled` is true or false. As a result, `ReadQuery` for `QueryTypeSQL` always returns "sqlExpressions is not implemented", even when the `sqlExpressions` feature toggle is on. The `!` inversion and the redundant branch suggest the intended logic was `return h.features.IsEnabledGlobally(featuremgmt.FlagSqlExpressions)`. Combined with the new stub `DB` in `pkg/expr/sql/db.go` (all methods return "not implemented"), the SQL expression feature is fully non-functional, while go.mod, parser.go and sql_command.go still wire it up as if it worked.
[P2] SQL expressions are rejected even when the sqlExpressions flag is enabled
`enableSqlExpressions` always returns false: it returns false when the flag is off (`enabled` is true) and also falls through to `return false` when the flag is on. So `ReadQuery` now rejects every `QueryTypeSQL` query with "sqlExpressions is not implemented", regardless of the feature toggle. The new `sql.DB` stub also returns "not implemented" from every method. The `QueryTypeSQL` branch in `Execute`/`TablesList` is therefore unreachable and dead. The inverted `enabled` variable and unconditional `return false` look like a placeholder rather than an intended gate. If the aim is to keep the feature off until a replacement for go-duck exists, a plain unconditional error or a correct flag check would be clearer. If SQL expressions are meant to work when the flag is on, this removes the feature outright.
qodo · cross-file engine perris 0.11.1+proven.tiered0.25.call.read.subclass.type
| Defect | Severity | Found | Grade |
|---|---|---|---|
| d1 | high | ✓ | exact |
| d2 | high | ✓ | exact |
raw comments (4)
<img src="https://img.shields.io/badge/High-634FD1?style=flat-square" height="20px" alt="Action required">
1\. Enabled sql expressions are rejected <code>🐞 Bug</code> <code>≡ Correctness</code>
<pre>
<b><i>enableSqlExpressions</i></b> negates the feature check and then returns false from both branches, so
<b><i>ReadQuery</i></b> rejects every SQL query before decoding it. This affects the typed expression reader
used when the expression parser or query-service path is active, including installations that
explicitly enable the experimental SQL expressions flag.
</pre>
<details>
<summary><strong>Agent Prompt</strong></summary>
```
## Issue description
`enableSqlExpressions` returns false regardless of whether the SQL expressions feature flag is enabled, causing enabled SQL queries to be rejected.
## Fix Focus Areas
- pkg/expr/reader.go[128-137]
- pkg/expr/reader.go[194-200]
## Recommended Fix
Return `h.features.IsEnabledGlobally(featuremgmt.FlagSqlExpressions)` directly from `enableSqlExpressions`, and add tests proving SQL queries are rejected when disabled but passed to SQL command construction when enabled.
```
<code>ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools</code>
</details>
<img src="https://img.shields.io/badge/High-634FD1?style=flat-square" height="20px" alt="Action required">
2\. All sql expressions fail to run <code>🐞 Bug</code> <code>≡ Correctness</code>
<pre>
<b><i>RunCommands</i></b> and <b><i>QueryFramesInto</i></b> in the replacement <b><i>DB</i></b> unconditionally return `not
implemented<b><i>, while </i></b>TablesList<b><i> and </i></b>SQLCommand.Execute` now call those methods. Legacy parsing
therefore rejects every nonempty SQL expression as invalid, and any command reaching execution
returns an error instead of a result.
</pre>
<details>
<summary><strong>Agent Prompt</strong></summary>
```
## Issue description
The new in-memory database is only a stub, so SQL parsing and execution now fail unconditionally.
## Fix Focus Areas
- go.mod[142-145]
- pkg/expr/sql/db.go[1-26]
- pkg/expr/sql/parser.go[21-29]
- pkg/expr/sql_command.go[93-104]
## Recommended Fix
Restore the working `go-duck` dependency and its parser and executor calls until a functional replacement exists, remove the stub database, and regenerate the module checksum files.
```
<code>ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools</code>
</details>
<h3>PR Summary by Qodo</h3>
Disable SQL expressions and remove go-duck dependency
<code>🐞 Bug fix</code> <code>⚙️ Configuration changes</code> <code>🕐 10-20 Minutes</code>
<img src="https://www.qodo.ai/wp-content/uploads/2025/11/light-grey-line.svg" height="10%" alt="Grey Divider">
<details>
<summary>AI Description</summary>
<dl>
<dd>
<br/>
><pre>
>• Rejects SQL expressions while their embedded execution engine is unavailable.
>• Replaces go-duck integration with local not-implemented database stubs.
>• Removes go-duck and obsolete transitive checksums from Go dependency manifests.
></pre>
</dd>
</dl>
</details>
<details>
<summary>Diagram</summary>
<dl>
<dd>
<br/>
```mermaid
graph TD
R["Query Reader"] --> G{"SQL type?"} -->|Yes| X["Disabled error"]
G -->|No| O["Other expressions"]
C["SQL Command"] --> D["DB stub"] --> N["Not implemented"]
P["SQL Parser"] --> D
```
</dd>
</dl>
</details>
<details>
<summary>High-Level Assessment</summary>
<dl>
<dd>
<br/>
>The following are alternative approaches to this PR:
<details>
<summary><b>1. Remove SQL expression implementation</b></summary>
<dl>
<dd>
- ➕ Eliminates unreachable code and misleading database APIs
- ➕ Prevents accidental direct use of non-operational SQL commands
- ➖ Creates a larger compatibility change
- ➖ Makes future restoration of the experimental feature more expensive
</dd>
</dl>
</details>
<details>
<summary><b>2. Make DuckDB an optional build dependency</b></summary>
<dl>
<dd>
- ➕ Preserves functional SQL expressions in selected builds
- ➕ Avoids exposing runtime methods that always fail
- ➖ Adds build-tag and release-matrix complexity
- ➖ Retains maintenance and supply-chain exposure to go-duck
</dd>
</dl>
</details>
>**Recommendation:** The PR's stub-and-gate approach is appropriate as a short-term way to remove go-duck while preserving internal SQL structures. Add focused coverage for SQL rejection and ensure no callers can bypass the reader; remove the dormant implementation entirely if the feature will not return.
</dd>
</dl>
</details>
<details>
<summary> Files changed (7) <code> +47 / -34 </code> </summary>
<dl>
<dd>
<br/>
<details>
<summary>Bug fix (1) <code> +12 / -0 </code></summary>
<dl>
<dd>
<details>
<summary>reader.go<code>Reject all SQL expression queries</code> <code>+12/-0</code></summary>
<br/>
>Reject all SQL expression queries
>
><pre>
>• Adds an SQL-expression availability check before deserialization and returns an explicit not-implemented error. The helper currently disables the path regardless of feature-toggle state.
></pre>
>
><a href='https://github.com/drape-io/crbench-qodo-2026-09/pull/44/files#diff-8ce477a6fd46011ed478fa6ba231c96cda10ac4d18ffe9ba7ced0010864690b2'>pkg/expr/reader.go</a>
</details>
</dd>
</dl>
</details>
<details>
<summary>Refactor (3) <code> +29 / -5 </code></summary>
<dl>
<dd>
<details>
<summary>db.go<code>Add non-operational local database stub</code> <code>+26/-0</code></summary>
<br/>
>Add non-operational local database stub
>
><pre>
>• Introduces a local DB type matching the SQL parser and executor's required operations. Every operation returns a not-implemented error, replacing the removed go-duck runtime dependency.
></pre>
>
><a href='https://github.com/drape-io/crbench-qodo-2026-09/pull/44/files#diff-996985d9abd7db3346871203dc3e5ac0ece014697c34be4102b6d29551636333'>pkg/expr/sql/db.go</a>
</details>
<details>
<summary>parser.go<code>Route SQL parsing through the local DB stub</code> <code>+1/-2</code></summary>
<br/>
>Route SQL parsing through the local DB stub
>
><pre>
>• Removes the direct go-duck import and constructs the package-local in-memory database replacement when attempting SQL AST serialization.
></pre>
>
><a href='https://github.com/drape-io/crbench-qodo-2026-09/pull/44/files#diff-1d7b7121b35153413f3a00644498b0410336fc1c27222f3cceb7d1eb9eaac9d1'>pkg/expr/sql/parser.go</a>
</details>
<details>
<summary>sql_command.go<code>Route SQL execution through the local DB stub</code> <code>+2/-3</code></summary>
<br/>
>Route SQL execution through the local DB stub
>
><pre>
>• Replaces direct go-duck construction with the local SQL package DB stub, causing retained execution calls to return the explicit not-implemented error.
></pre>
>
><a href='https://github.com/drape-io/crbench-qodo-2026-09/pull/44/files#diff-f691c89b4f03c73c4182a8d02d76373db3e4a3ac43f5c7f2104c244c0acfc367'>pkg/expr/sql_command.go</a>
</details>
</dd>
</dl>
</details>
<details>
<summary>Other (3) <code> +6 / -29 </code></summary>
<dl>
<dd>
<details>
<summary>go.mod<code>Remove go-duck and unused transitive modules</code> <code>+0/-8</code></summary>
<br/>
>Remove go-duck and unused transitive modules
>
><pre>
>• Removes the direct go-duck requirement and indirect modules no longer needed by the root module after detaching the SQL expression engine.
></pre>
>
><a href='https://github.com/drape-io/crbench-qodo-2026-09/pull/44/files#diff-33ef32bf6c23acb95f5902d7097b7a1d5128ca061167ec0716715b0b9eeaa5f6'>go.mod</a>
</details>
<details>
<summary>go.sum<code>Prune obsolete module content checksums</code> <code>+0/-15</code></summary>
<br/>
>Prune obsolete module content checksums
>
><pre>
>• Removes full artifact checksums for go-duck and transitive dependencies no longer selected by the root module while retaining applicable module metadata hashes.
></pre>
>
><a href='https://github.com/drape-io/crbench-qodo-2026-09/pull/44/files#diff-3295df7234525439d778f1b282d146a4f1ff6b415248aaac074e8042d9f42d63'>go.sum</a>
</details>
<details>
<summary>go.work.sum<code>Reconcile workspace dependency checksums</code> <code>+6/-6</code></summary>
<br/>
>Reconcile workspace dependency checksums
>
><pre>
>• Updates workspace checksums after the root dependency cleanup, removing unused Azure and replay modules while adding hashes still required by other workspace modules.
></pre>
>
><a href='https://github.com/drape-io/crbench-qodo-2026-09/pull/44/files#diff-20cee3a725d1c5d2c595ff5372e6593d3bcaa7aebd8319866f65e90c6924f247'>go.work.sum</a>
</details>
</dd>
</dl>
</details>
</dd>
</dl>
</details>
<h3>Code Review by Qodo</h3>
<code>🐞 Bugs (2)</code> <code>📘 Rule violations (0)</code> <code>📜 Skill insights (0)</code>
<img src="https://www.qodo.ai/wp-content/uploads/2025/11/light-grey-line.svg" height="10%" alt="Grey Divider">
<br/>
<img src="https://img.shields.io/badge/High-634FD1?style=flat-square" height="20px" alt="Action required">
<details>
<summary> 1. Enabled SQL expressions are rejected <code>🐞 Bug</code> <code>≡ Correctness</code></summary>
<br/>
> <details open>
><summary>Description</summary>
><br/>
>
><pre>
><b><i>enableSqlExpressions</i></b> negates the feature check and then returns false from both branches, so
><b><i>ReadQuery</i></b> rejects every SQL query before decoding it. This affects the typed expression reader
>used when the expression parser or query-service path is active, including installations that
>explicitly enable the experimental SQL expressions flag.
></pre>
></details>
> <details>
><summary>Code</summary>
><br/>
>
><code>[pkg/expr/reader.go[R194-197]](https://github.com/drape-io/crbench-qodo-2026-09/pull/44/files#diff-8ce477a6fd46011ed478fa6ba231c96cda10ac4d18ffe9ba7ced0010864690b2R194-R197)</code>
>
>```diff
>+func enableSqlExpressions(h *ExpressionQueryReader) bool {
>+ enabled := !h.features.IsEnabledGlobally(featuremgmt.FlagSqlExpressions)
>+ if enabled {
>+ return false
>```
></details>
> <details>
><summary>Evidence</summary>
><br/>
>
><pre>
>The feature registry defines <b><i>sqlExpressions</i></b> as enabling SQL and DuckDB expressions, but the new
>helper returns false whether that flag is enabled or disabled. <b><i>ReadQuery</i></b> immediately turns that
>false value into an error, and the expression-parser path invokes this reader for SQL nodes.
></pre>
>
> <code>[pkg/services/featuremgmt/registry.go[1083-1088]](https://github.com/drape-io/crbench-qodo-2026-09/blob/b868cac00efddd5ee7a280afe643874db6a724bd/pkg/services/featuremgmt/registry.go/#L1083-L1088)</code>
> <code>[pkg/expr/reader.go[128-137]](https://github.com/drape-io/crbench-qodo-2026-09/blob/b868cac00efddd5ee7a280afe643874db6a724bd/pkg/expr/reader.go/#L128-L137)</code>
> <code>[pkg/expr/reader.go[194-200]](https://github.com/drape-io/crbench-qodo-2026-09/blob/b868cac00efddd5ee7a280afe643874db6a724bd/pkg/expr/reader.go/#L194-L200)</code>
> <code>[pkg/expr/nodes.go[123-145]](https://github.com/drape-io/crbench-qodo-2026-09/blob/b868cac00efddd5ee7a280afe643874db6a724bd/pkg/expr/nodes.go/#L123-L145)</code>
></details>
> <details>
><summary>Agent prompt</summary>
><br/>
>
>```
>The issue below was found during a code review. Follow the provided context and guidance below and implement a solution
>
>## Issue description
>`enableSqlExpressions` returns false regardless of whether the SQL expressions feature flag is enabled, causing enabled SQL queries to be rejected.
>
>## Fix Focus Areas
>- pkg/expr/reader.go[128-137]
>- pkg/expr/reader.go[194-200]
>
>## Recommended Fix
>Return `h.features.IsEnabledGlobally(featuremgmt.FlagSqlExpressions)` directly from `enableSqlExpressions`, and add tests proving SQL queries are rejected when disabled but passed to SQL command construction when enabled.
>```
> <code>ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools</code>
></details>
<hr/>
</details>
<details>
<summary> 2. All SQL expressions fail to run <code>🐞 Bug</code> <code>≡ Correctness</code></summary>
<br/>
> <details open>
><summary>Description</summary>
><br/>
>
><pre>
><b><i>RunCommands</i></b> and <b><i>QueryFramesInto</i></b> in the replacement <b><i>DB</i></b> unconditionally return `not
>implemented<b><i>, while </i></b>TablesList<b><i> and </i></b>SQLCommand.Execute` now call those methods. Legacy parsing
>therefore rejects every nonempty SQL expression as invalid, and any command reaching execution
>returns an error instead of a result.
></pre>
></details>
> <details>
><summary>Code</summary>
><br/>
>
><code>[pkg/expr/sql/db.go[R16-21]](https://github.com/drape-io/crbench-qodo-2026-09/pull/44/files#diff-996985d9abd7db3346871203dc3e5ac0ece014697c34be4102b6d29551636333R16-R21)</code>
>
>```diff
>+func (db *DB) RunCommands(commands []string) (string, error) {
>+ return "", errors.New("not implemented")
>+}
>+
>+func (db *DB) QueryFramesInto(name string, query string, frames []*data.Frame, f *data.Frame) error {
>+ return errors.New("not implemented")
>```
></details>
> <details>
><summary>Evidence</summary>
><br/>
>
><pre>
>Every SQL command constructor calls <b><i>TablesList</i></b>, which now invokes the stubbed <b><i>RunCommands</i></b> and
>converts its error into <b><i>sql-invalid-sql</i></b>. The execution path likewise calls the stubbed
><b><i>QueryFramesInto</i></b>, records its unconditional error in the result, and returns before producing frame
>values.
></pre>
>
> <code>[pkg/expr/sql/db.go[12-25]](https://github.com/drape-io/crbench-qodo-2026-09/blob/b868cac00efddd5ee7a280afe643874db6a724bd/pkg/expr/sql/db.go/#L12-L25)</code>
> <code>[pkg/expr/sql/parser.go[21-29]](https://github.com/drape-io/crbench-qodo-2026-09/blob/b868cac00efddd5ee7a280afe643874db6a724bd/pkg/expr/sql/parser.go/#L21-L29)</code>
> <code>[pkg/expr/sql_command.go[24-47]](https://github.com/drape-io/crbench-qodo-2026-09/blob/b868cac00efddd5ee7a280afe643874db6a724bd/pkg/expr/sql_command.go/#L24-L47)</code>
> <code>[pkg/expr/sql_command.go[94-118]](https://github.com/drape-io/crbench-qodo-2026-09/blob/b868cac00efddd5ee7a280afe643874db6a724bd/pkg/expr/sql_command.go/#L94-L118)</code>
> <code>[pkg/expr/nodes.go[148-166]](https://github.com/drape-io/crbench-qodo-2026-09/blob/b868cac00efddd5ee7a280afe643874db6a724bd/pkg/expr/nodes.go/#L148-L166)</code>
></details>
> <details>
><summary>Agent prompt</summary>
><br/>
>
>```
>The issue below was found during a code review. Follow the provided context and guidance below and implement a solution
>
>## Issue description
>The new in-memory database is only a stub, so SQL parsing and execution now fail unconditionally.
>
>## Fix Focus Areas
>- go.mod[142-145]
>- pkg/expr/sql/db.go[1-26]
>- pkg/expr/sql/parser.go[21-29]
>- pkg/expr/sql_command.go[93-104]
>
>## Recommended Fix
>Restore the working `go-duck` dependency and its parser and executor calls until a functional replacement exists, remove the stub database, and regenerate the module checksum files.
>```
> <code>ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools</code>
></details>
<hr/>
</details>
<img src="https://www.qodo.ai/wp-content/uploads/2025/11/light-grey-line.svg" height="10%" alt="Grey Divider">
<!-- qodo-context:start -->
<details><summary><strong>Context sources</strong></summary>
<div>Review mode: <code>⚖️ Balanced</code>: This changes runtime SQL expression gating and database execution paths across multiple files, with behavior currently replaced by unimplemented stubs, so a careful full review is warranted.</div>
<!-- qodo-context:end -->
</details>
<img src="https://www.qodo.ai/wp-content/uploads/2025/11/light-grey-line.svg" height="10%" alt="Grey Divider">
<!-- qodo-daily-tip:start -->
<details>
<summary><strong>Tip of the day</strong></summary>
<br/>
<pre>💡 Did you know, you can reply 'qodo' on any finding to push back, ask questions, or dig deeper</pre>
<a href="https://docs.qodo.ai/tips-and-tricks">More tips ↗</a> | <a href="https://app.qodo.ai/configurations?tab=display-preferences">Customize Qodo ↗</a> | <a href="https://docs.qodo.ai">Qodo docs ↗</a>
</details>
<img src="https://www.qodo.ai/wp-content/uploads/2025/11/light-grey-line.svg" height="10%" alt="Grey Divider">
<!-- qodo-daily-tip:end -->
<!-- https://github.com/drape-io/crbench-qodo-2026-09/commit/b868cac00efddd5ee7a280afe643874db6a724bd -->
<a href="https://www.qodo.ai"><img src="https://www.qodo.ai/wp-content/uploads/2025/03/qodo-logo.svg" width="80" alt="Qodo Logo"></a>