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
7 changes: 5 additions & 2 deletions gen/go/eventschema/getters.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,10 @@ func (d *TableSchemaDetails) CreateView() string {
return sb.String()
}

func sqlViewNameForEvent(eventName string) string {
// SQLViewNameForEvent returns a SQL compatible view name for a given event.
// [event code] -> [athena view name]
// session.start -> session_start
func SQLViewNameForEvent(eventName string) string {
viewName := strings.ReplaceAll(eventName, ".", "_")
return strings.ReplaceAll(viewName, "-", "_")
}
Expand Down Expand Up @@ -152,7 +155,7 @@ func GetViewsDetails() ([]*TableSchemaDetails, error) {
return nil, trace.Wrap(err)
}
tb.Name = eventName
tb.SQLViewName = sqlViewNameForEvent(eventName)
tb.SQLViewName = SQLViewNameForEvent(eventName)
out = append(out, tb)
}
return out, nil
Expand Down
2 changes: 1 addition & 1 deletion lib/ai/model/tools/auditquery.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ Today's date is DATE('%s')`, time.Now().Format("2006-01-02")),
},
{
Role: openai.ChatMessageRoleUser,
Content: fmt.Sprintf("The schema of the table `%s` is:\n\n%s", eventType, tableSchema),
Content: fmt.Sprintf("The schema of the table `%s` is:\n\n%s", eventschema.SQLViewNameForEvent(eventType), tableSchema),
},
{
Role: openai.ChatMessageRoleUser,
Expand Down