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

Method parseExplore

runtime/parser/parse_explore.go:120–300  ·  view source on GitHub ↗
(node *Node)

Source from the content-addressed store, hash-verified

118}
119
120func (p *Parser) parseExplore(node *Node) error {
121 // Parse YAML
122 tmp := &ExploreYAML{}
123 err := p.decodeNodeYAML(node, true, tmp)
124 if err != nil {
125 return err
126 }
127
128 // Validate SQL or connector isn't set
129 if node.SQL != "" {
130 return fmt.Errorf("explores cannot have SQL")
131 }
132 if !node.ConnectorInferred && node.Connector != "" {
133 return fmt.Errorf("explores cannot have a connector")
134 }
135
136 // Display name backwards compatibility
137 if tmp.Title != "" && tmp.DisplayName == "" {
138 tmp.DisplayName = tmp.Title
139 }
140
141 // Set default for AllowCustomTimeRange to true if not provided
142 allowCustomTimeRange := true
143 if tmp.AllowCustomTimeRange != nil {
144 allowCustomTimeRange = *tmp.AllowCustomTimeRange
145 }
146
147 // Validate metrics_view
148 if tmp.MetricsView == "" {
149 return errors.New("metrics_view is required")
150 }
151 node.Refs = append(node.Refs, ResourceName{Kind: ResourceKindMetricsView, Name: tmp.MetricsView})
152
153 // Parse the dimensions and measures selectors
154 var dimensionsSelector *runtimev1.FieldSelector
155 dimensions, ok := tmp.Dimensions.TryResolve()
156 if !ok {
157 dimensionsSelector = tmp.Dimensions.Proto()
158 }
159 var measuresSelector *runtimev1.FieldSelector
160 measures, ok := tmp.Measures.TryResolve()
161 if !ok {
162 measuresSelector = tmp.Measures.Proto()
163 }
164
165 // Parse theme if present.
166 // If it returns a themeSpec, it will be inserted as a separate resource later in this function.
167 themeName, themeSpec, err := p.parseThemeRef(&tmp.Theme)
168 if err != nil {
169 return err
170 }
171 // Fallback to top-level theme from rill.yaml if no local theme or default theme is set
172 if themeName == "" && themeSpec == nil && p.RillYAML != nil && p.RillYAML.Theme != "" {
173 themeName = p.RillYAML.Theme
174 }
175 if themeName != "" && themeSpec == nil {
176 node.Refs = append(node.Refs, ResourceName{Kind: ResourceKindTheme, Name: themeName})
177 }

Callers 1

parseNodeMethod · 0.95

Calls 10

decodeNodeYAMLMethod · 0.95
parseThemeRefMethod · 0.95
insertResourceMethod · 0.95
ParseFunction · 0.92
ParseCompatibilityFunction · 0.92
ToDisplayNameFunction · 0.85
TryResolveMethod · 0.80
GetAccessMethod · 0.80
ErrorfMethod · 0.65
ProtoMethod · 0.45

Tested by

no test coverage detected