Skip to content

Commit

Permalink
fix sql query with nested fields/ column names joined by dot (siglens…
Browse files Browse the repository at this point in the history
…#1777)

* fix sql query with nested fields/ column names joined by dot

* address PR comments

---------

Co-authored-by: Kunal Nawale <[email protected]>
  • Loading branch information
sunitakawane and nkunal authored Oct 21, 2024
1 parent 1a8c1ce commit ca6b7f7
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion pkg/ast/sql/astsql.go
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,13 @@ func parseSelect(astNode *structs.ASTNode, aggNode *structs.QueryAggregators, cu
}
switch agg := alias.Expr.(type) {
case *sqlparser.ColName:
columsArray = append(columsArray, agg.Name.CompliantName())
// Handle nested fields by joining the qualifier (if present) with the column name
colnamePart := agg.Qualifier.Name.String()
if colnamePart != "" {
columsArray = append(columsArray, colnamePart+"."+agg.Name.CompliantName())
} else {
columsArray = append(columsArray, agg.Name.CompliantName())
}
if len(label) != 0 {
renameCols[agg.Name.CompliantName()] = label
}
Expand Down

0 comments on commit ca6b7f7

Please sign in to comment.