Skip to content
Merged
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
27 changes: 18 additions & 9 deletions sql/analyzer/symbol_resolution.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,10 @@ func pruneTableCols(
cols := make([]string, 0)
source := strings.ToLower(table.Name())
for _, col := range table.Schema() {
c := newTableCol(source, col.Name)
c := tableCol{
table: source,
col: strings.ToLower(col.Name),
}
if parentCols[c] > 0 {
cols = append(cols, c.col)
}
Expand Down Expand Up @@ -310,26 +313,32 @@ func gatherTableAlias(
alias := strings.ToLower(n.Name())
var base string
if rt, ok := n.Child.(*plan.ResolvedTable); ok {
base = rt.Name()
base = rt.Name() // TODO: toLower?
}
_, starred := parentStars[alias]
if starred {
nodeStars = append(nodeStars, base)
}
if unqualifiedStar {
starred = true
}
base = strings.ToLower(base)
for _, col := range n.Schema() {
baseCol := newTableCol(base, col.Name)
aliasCol := newTableCol(alias, col.Name)
colName := strings.ToLower(col.Name)
aliasCol := tableCol{
table: alias,
col: colName,
}
if starred || parentCols[aliasCol] > 0 {
// if the outer scope requests an aliased column
// a table lower in the tree must provide the source
baseCol := tableCol{
table: base,
col: colName,
}
cols = append(cols, baseCol)
}
}
for t := range parentStars {
if t == alias {
nodeStars = append(nodeStars, base)
}
}
return cols, nodeStars
default:
}
Expand Down