@@ -202,36 +202,23 @@ func pruneTableCols(
202
202
return n , transform .SameTree , nil
203
203
}
204
204
205
+ // columns don't need to be pruned if there's a star
205
206
_ , selectStar := parentStars [table .Name ()]
206
- if unqualifiedStar {
207
- selectStar = true
207
+ if selectStar || unqualifiedStar {
208
+ return n , transform . SameTree , nil
208
209
}
209
210
210
- // Don't prune columns if they're needed by a virtual column
211
- virtualColDeps := make (map [string ]int )
212
- if ! selectStar { // if selectStar, we're adding all columns anyway
213
- if vct , isVCT := n .WrappedTable ().(* plan.VirtualColumnTable ); isVCT {
214
- for _ , projection := range vct .Projections {
215
- transform .InspectExpr (projection , func (e sql.Expression ) bool {
216
- if cd , isCD := e .(* sql.ColumnDefaultValue ); isCD {
217
- transform .InspectExpr (cd .Expr , func (e sql.Expression ) bool {
218
- if gf , ok := e .(* expression.GetField ); ok {
219
- virtualColDeps [gf .Name ()]++
220
- }
221
- return false
222
- })
223
- }
224
- return false
225
- })
226
- }
227
- }
211
+ // pruning VirtualColumnTable underlying tables causes indexing errors when VirtualColumnTable.Projections (which are sql.Expression)
212
+ // are evaluated
213
+ if _ , isVCT := n .WrappedTable ().(* plan.VirtualColumnTable ); isVCT {
214
+ return n , transform .SameTree , nil
228
215
}
229
216
230
217
cols := make ([]string , 0 )
231
218
source := strings .ToLower (table .Name ())
232
219
for _ , col := range table .Schema () {
233
220
c := newTableCol (source , col .Name )
234
- if selectStar || parentCols [c ] > 0 || virtualColDeps [ c . Name () ] > 0 {
221
+ if parentCols [c ] > 0 {
235
222
cols = append (cols , c .col )
236
223
}
237
224
}
0 commit comments