MCPcopy Create free account
hub / github.com/bytebase/bytebase / classifyOmniParseError

Function classifyOmniParseError

backend/plugin/parser/tidb/metrics.go:63–74  ·  view source on GitHub ↗

classifyOmniParseError maps an omni parse error + the input SQL into a counter label. The input SQL is required because the omni error string does not always echo the offending keyword (notably for CREATE SEQUENCE). Returns "unknown" for nil error or any error+sql whose haystack contains no known Ti

(err error, sql string)

Source from the content-addressed store, hash-verified

61// Returns "unknown" for nil error or any error+sql whose haystack contains
62// no known Tier-4 keyword.
63func classifyOmniParseError(err error, sql string) string {
64 if err == nil {
65 return "unknown"
66 }
67 haystack := strings.ToUpper(err.Error() + " " + sql)
68 for _, p := range omniFallbackReasonPatterns {
69 if strings.Contains(haystack, p.pattern) {
70 return p.reason
71 }
72 }
73 return "unknown"
74}

Calls 1

ErrorMethod · 0.45