Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

*: fix cannot get column info from generate column (#55447) #55510

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pkg/executor/test/analyzetest/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ go_test(
"main_test.go",
],
flaky = True,
shard_count = 48,
shard_count = 49,
deps = [
"//pkg/config",
"//pkg/domain",
Expand Down
9 changes: 9 additions & 0 deletions pkg/executor/test/analyzetest/analyze_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3127,3 +3127,12 @@ func TestAnalyzePartitionVerify(t *testing.T) {
}
}
}

func TestIssue55438(t *testing.T) {
store := testkit.CreateMockStore(t)
tk := testkit.NewTestKit(t, store)
tk.MustExec("use test")
tk.MustExec("CREATE TABLE t0(c0 NUMERIC , c1 BIGINT UNSIGNED AS ((CASE 0 WHEN false THEN 1358571571 ELSE TRIM(c0) END )));")
tk.MustExec("CREATE INDEX i0 ON t0(c1);")
tk.MustExec("analyze table t0")
}
10 changes: 10 additions & 0 deletions pkg/planner/core/expression_rewriter.go
Original file line number Diff line number Diff line change
Expand Up @@ -2396,6 +2396,16 @@ func (er *expressionRewriter) toColumn(v *ast.ColumnName) {
}
er.ctxStackAppend(column, er.names[idx])
return
} else if er.planCtx == nil && er.sourceTable != nil &&
(v.Table.L == "" || er.sourceTable.Name.L == v.Table.L) {
colInfo := er.sourceTable.FindPublicColumnByName(v.Name.L)
if colInfo == nil || colInfo.Hidden {
er.err = plannererrors.ErrUnknownColumn.GenWithStackByArgs(v.Name, clauseMsg[er.clause()])
return
}
er.ctxStackAppend(&expression.Column{RetType: &colInfo.FieldType, ID: colInfo.ID, UniqueID: colInfo.ID},
&types.FieldName{ColName: v.Name})
return
}

planCtx := er.planCtx
Expand Down