diff --git a/gen/go/eventschema/getters.go b/gen/go/eventschema/getters.go index 5fc350cd7d7a3..464e91ca7fba7 100644 --- a/gen/go/eventschema/getters.go +++ b/gen/go/eventschema/getters.go @@ -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, "-", "_") } @@ -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 diff --git a/lib/ai/model/tools/auditquery.go b/lib/ai/model/tools/auditquery.go index 63b8550966444..180adf466e76e 100644 --- a/lib/ai/model/tools/auditquery.go +++ b/lib/ai/model/tools/auditquery.go @@ -135,7 +135,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,