MCPcopy Index your code
hub / github.com/rilldata/rill / parseReport

Method parseReport

runtime/parser/parse_report.go:61–281  ·  view source on GitHub ↗

parseReport parses a report definition and adds the resulting resource to p.Resources.

(node *Node)

Source from the content-addressed store, hash-verified

59
60// parseReport parses a report definition and adds the resulting resource to p.Resources.
61func (p *Parser) parseReport(node *Node) error {
62 // Parse YAML
63 tmp := &ReportYAML{}
64 err := p.decodeNodeYAML(node, true, tmp)
65 if err != nil {
66 return err
67 }
68
69 // Validate SQL or connector isn't set
70 if node.SQL != "" {
71 return fmt.Errorf("reports cannot have SQL")
72 }
73 if !node.ConnectorInferred && node.Connector != "" {
74 return fmt.Errorf("reports cannot have a connector")
75 }
76
77 // Display name backwards compatibility
78 if tmp.Title != "" && tmp.DisplayName == "" {
79 tmp.DisplayName = tmp.Title
80 }
81
82 // Parse refresh schedule
83 schedule, err := p.parseScheduleYAML(tmp.Refresh, false)
84 if err != nil {
85 return err
86 }
87
88 // Parse watermark
89 watermarkInherit := false
90 if tmp.Watermark != "" {
91 switch strings.ToLower(tmp.Watermark) {
92 case "inherit":
93 watermarkInherit = true
94 case "trigger_time":
95 // Do nothing
96 default:
97 return fmt.Errorf(`invalid value %q for property "watermark"`, tmp.Watermark)
98 }
99 }
100
101 // Validate the interval duration as a standard ISO8601 duration (without Rill extensions) with only one component
102 if tmp.Intervals.Duration != "" {
103 err := duration.ValidateISO8601(tmp.Intervals.Duration, true, true)
104 if err != nil {
105 return fmt.Errorf(`invalid value %q for property "intervals.duration"`, tmp.Intervals.Duration)
106 }
107 }
108
109 // Parse timeout
110 var timeout time.Duration
111 if tmp.Timeout != "" {
112 timeout, err = parseDuration(tmp.Timeout)
113 if err != nil {
114 return err
115 }
116 }
117
118 // Determine if using new data resolver or legacy query

Callers 1

parseNodeMethod · 0.95

Calls 12

decodeNodeYAMLMethod · 0.95
parseScheduleYAMLMethod · 0.95
parseDataYAMLMethod · 0.95
insertResourceMethod · 0.95
ValidateISO8601Function · 0.92
ToSliceAnyFunction · 0.92
EncodePropsFunction · 0.92
parseDurationFunction · 0.85
parseExportFormatFunction · 0.85
ToDisplayNameFunction · 0.85
ErrorfMethod · 0.65
ValidMethod · 0.45

Tested by

no test coverage detected