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

Function TestAST_ExtractAnnotations

runtime/pkg/sqlparse/annotations_test.go:9–55  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

7)
8
9func TestAST_ExtractAnnotations(t *testing.T) {
10 sqlVariations := []struct {
11 title string
12 sql string
13 annotations map[string]string
14 }{
15 {
16 "comments at the top",
17 `
18-- some random comment
19-- @materialise_v1
20-- @materialise_v2 : true
21-- @materialise_v3 : tr ue
22-- some other comment
23select * from AdBids
24`,
25 map[string]string{
26 "materialise_v1": "",
27 "materialise_v2": "true",
28 "materialise_v3": "tr ue",
29 },
30 },
31 {
32 "comments in the middle",
33 `
34select
35-- @measure: avg
36-- @measure.format: usd
37a,
38-- @dimension
39b
40from AdBids
41`,
42 map[string]string{
43 "measure": "avg",
44 "measure.format": "usd",
45 "dimension": "",
46 },
47 },
48 }
49
50 for _, tt := range sqlVariations {
51 t.Run(tt.title, func(t *testing.T) {
52 require.EqualValues(t, tt.annotations, ExtractAnnotations(tt.sql))
53 })
54 }
55}

Callers

nothing calls this directly

Calls 2

ExtractAnnotationsFunction · 0.85
RunMethod · 0.45

Tested by

no test coverage detected