MCPcopy Create free account
hub / github.com/rilldata/rill / ExtractAnnotations

Function ExtractAnnotations

runtime/pkg/sqlparse/annotations.go:11–23  ·  view source on GitHub ↗

ExtractAnnotations extracts annotations from comments prefixed with '@', and optionally a value after a ':'. Examples: "-- @materialize" and "-- @materialize: true".

(sql string)

Source from the content-addressed store, hash-verified

9// ExtractAnnotations extracts annotations from comments prefixed with '@', and optionally a value after a ':'.
10// Examples: "-- @materialize" and "-- @materialize: true".
11func ExtractAnnotations(sql string) map[string]string {
12 annotations := map[string]string{}
13 subMatches := annotationsRegex.FindAllStringSubmatch(sql, -1)
14 for _, subMatch := range subMatches {
15 k := subMatch[1]
16 v := ""
17 if len(subMatch) > 2 {
18 v = subMatch[2]
19 }
20 annotations[k] = v
21 }
22 return annotations
23}

Callers 2

parseStemMethod · 0.92

Calls

no outgoing calls

Tested by 1