Skip to content
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
24 changes: 24 additions & 0 deletions enginetest/join_op_tests.go
Original file line number Diff line number Diff line change
Expand Up @@ -2363,6 +2363,30 @@ WHERE
},
},
},
{
// https://github.com/dolthub/dolt/issues/10527
name: "join on table with dots in name",
setup: [][]string{
{
"create table t1(id int, name varchar(100), location varchar(100));",
"create index id_name_location on t1 (id, name, location);",
"create index name_id_location on t1(name, id, location);",
"create index location_id_name on t1 (location, id, name);",
"insert into t1 values (1, 'name1', 'loc1');",
"create table `t2.with.dot`(id int, name varchar(100), country varchar(100));",
"create index id_name_country on `t2.with.dot`(id, name, country);",
"create index name_id_country on `t2.with.dot`(name, id, country);",
"create index country_id_name on `t2.with.dot`(country, id, name);",
"insert into `t2.with.dot` values (1, 'name1', 'CA');",
},
},
tests: []JoinOpTests{
{
Query: "SELECT t1.id, t1.name, t1.location, `t2.with.dot`.country FROM t1 JOIN `t2.with.dot` ON t1.id = `t2.with.dot`.id WHERE t1.id = 1;",
Expected: []sql.Row{{1, "name1", "loc1", "CA"}},
},
},
},
}

var rangeJoinOpTests = []JoinOpTests{
Expand Down
5 changes: 4 additions & 1 deletion sql/memo/rel_props.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,10 @@ func newRelProps(rel RelExpr) *relProps {
func idxExprsColumns(idx sql.Index) []string {
exprs := idx.Expressions()
columns := make([]string, len(exprs))
// prefix includes table name and '.' character
prefixLen := len(idx.Table()) + 1
for i, e := range exprs {
colName := e[strings.IndexRune(e, '.')+1:]
colName := e[prefixLen:]
columns[i] = strings.ToLower(colName)
}
return columns
Expand Down Expand Up @@ -229,6 +231,7 @@ func (p *relProps) populateFds() {
normIdx.order = oidx.Order()
}
for i, c := range columns {
// TODO: This doesn't account for when the column is not found and ord is -1
ord := sch.IndexOfColName(strings.ToLower(c))
idOffset := firstCol + sql.ColumnId(ord)
colId, _ := all.Next(idOffset)
Expand Down