Skip to content

Commit e9bfab1

Browse files
committed
find statistics table in table wrappers during replace count star
1 parent ffdc4a9 commit e9bfab1

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

sql/analyzer/catalog.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -467,6 +467,8 @@ func getStatisticsTable(table sql.Table, prevTable sql.Table) (sql.StatisticsTab
467467
return t, true
468468
case sql.TableNode:
469469
return getStatisticsTable(t.UnderlyingTable(), table)
470+
case sql.TableWrapper:
471+
return getStatisticsTable(t.Underlying(), table)
470472
default:
471473
return nil, false
472474
}

sql/analyzer/replace_count_star.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ func replaceCountStar(ctx *sql.Context, a *Analyzer, n sql.Node, _ *plan.Scope,
9595
return n, transform.SameTree, nil
9696
}
9797

98-
if statsTable, ok := rt.Table.(sql.StatisticsTable); ok {
98+
if statsTable, ok := getStatisticsTable(rt.Table, nil); ok {
9999
rowCnt, exact, err := statsTable.RowCount(ctx)
100100
if err == nil && exact {
101101
return plan.NewProject(

0 commit comments

Comments
 (0)