001package gudusoft.gsqlparser.lineage.v2.model;
002
003import java.util.Arrays;
004import java.util.Collections;
005import java.util.List;
006import java.util.Map;
007
008/**
009 * A node of the ExplainGraph: an intermediate result set, its ROW_SET and column nodes, a function,
010 * CASE or expression node, or a TERMINAL input (Section 7.7; algorithms/fold-v1.md, Section 3).
011 * Never an endpoint identity. Generated from the schema definition ExplainNode by
012 * scripts/sqllr/gen_type_model.py; do not edit.
013 *
014 * @since 4.2.17
015 */
016public final class ExplainNode extends SqllrObject {
017
018    /** The members the schema defines, in schema order. */
019    public static final List<String> MEMBERS = Collections.unmodifiableList(Arrays.asList("ref", "kind", "role", "statementRef", "parentRef", "ownerRef", "path", "ordinal", "span", "cteName", "alias", "inputKind", "disclosure", "literal", "token", "parameterText", "parameterOrdinal", "upstreamCompleteness", "diagnosticRefs", "key", "recordId", "extensions"));
020
021    /** The members the schema requires. */
022    public static final List<String> REQUIRED = Collections.unmodifiableList(Arrays.<String>asList("ref", "kind", "statementRef", "path", "ordinal", "span"));
023
024    /** Reads a JSON object as a {@code ExplainNode}. */
025    public static final Reader<ExplainNode> READER = new Reader<ExplainNode>() {
026        @Override
027        public ExplainNode read(Object json) {
028            return fromJson(json);
029        }
030    };
031
032    private ExplainNode(Map<String, Object> members) {
033        super(members);
034    }
035
036    /** A {@code ExplainNode} with the members of a JSON object, all kept. */
037    public static ExplainNode fromJson(Object json) {
038        return new ExplainNode(members(json, "ExplainNode"));
039    }
040
041    public static Builder builder() {
042        return new Builder(null);
043    }
044
045    /** A builder holding every member of this object. */
046    public Builder toBuilder() {
047        return new Builder(toJson());
048    }
049
050    /**
051     * The member {@code ref}. A document-local reference: an integer that is unique across the
052     * whole document (one reference space for every object that carries a ref). Local references
053     * are assigned after merging and have no meaning outside the document (Sections 6.1 and 13).
054     * Null when absent; throws IllegalStateException when the member holds another JSON type.
055     */
056    public Long getRef() {
057        return integer("ref");
058    }
059
060    /**
061     * The member {@code kind}. The kind of an ExplainGraph node. Registry group 'explainNodeKinds'
062     * (Section 7.7, item 2). Null when absent; throws IllegalStateException when the member holds
063     * another JSON type.
064     */
065    public String getKind() {
066        return string("kind");
067    }
068
069    /**
070     * The member {@code role}. The role of an ExplainGraph node. Registry group 'explainNodeRoles'
071     * (Section 7.7, item 2). Null when absent; throws IllegalStateException when the member holds
072     * another JSON type.
073     */
074    public String getRole() {
075        return string("role");
076    }
077
078    /**
079     * The member {@code statementRef}. A document-local reference: an integer that is unique across
080     * the whole document (one reference space for every object that carries a ref). Local
081     * references are assigned after merging and have no meaning outside the document (Sections 6.1
082     * and 13). Null when absent; throws IllegalStateException when the member holds another JSON
083     * type.
084     */
085    public Long getStatementRef() {
086        return integer("statementRef");
087    }
088
089    /**
090     * The member {@code parentRef}. The enclosing node: the query block in which a subquery is
091     * nested, the result set whose CTE body this is (Section 7.7, item 1). A document-local
092     * reference: an integer that is unique across the whole document (one reference space for every
093     * object that carries a ref). Local references are assigned after merging and have no meaning
094     * outside the document (Sections 6.1 and 13). Null when absent; throws IllegalStateException
095     * when the member holds another JSON type.
096     */
097    public Long getParentRef() {
098        return integer("parentRef");
099    }
100
101    /**
102     * The member {@code ownerRef}. FIELD and ROW_SET nodes: the result-set node they belong to. A
103     * document-local reference: an integer that is unique across the whole document (one reference
104     * space for every object that carries a ref). Local references are assigned after merging and
105     * have no meaning outside the document (Sections 6.1 and 13). Null when absent; throws
106     * IllegalStateException when the member holds another JSON type.
107     */
108    public Long getOwnerRef() {
109        return integer("ownerRef");
110    }
111
112    /**
113     * The member {@code path}. The semantic path of the query block that owns the node; for a FIELD
114     * or ROW_SET node, the path of its result set (algorithms/identity-v1.md, Section 5.7). A
115     * semantic path. Under the path profile sqllr-path-1 it is a '/'-joined list of steps
116     * CODE[index] (registry group pathStepCodes) that follows algorithms/path-v1.md (semantic
117     * stage: SEMANTIC_PATH_PROFILE_VIOLATION); under another declared profile it is opaque and
118     * comparable only within (producer, path profile). Null when absent; throws
119     * IllegalStateException when the member holds another JSON type.
120     */
121    public String getPath() {
122        return string("path");
123    }
124
125    /**
126     * The member {@code ordinal}. For a FIELD node, the column ordinal (select-list position;
127     * positional pairing for set operations), 0..n-1 within its result set. Otherwise the rank
128     * among nodes of the same kind on the same path, by span start, the outer node first
129     * (algorithms/identity-v1.md, Section 5.7). A 0-based ordinal. Null when absent; throws
130     * IllegalStateException when the member holds another JSON type.
131     */
132    public Long getOrdinal() {
133        return integer("ordinal");
134    }
135
136    /**
137     * The member {@code span}. The fragment of the original SQL (Section 7.7, item 5); for a
138     * ROW_SET node, the fragment of the query block stage it stands for. Null when absent; throws
139     * IllegalStateException when the member holds another JSON type.
140     */
141    public Span getSpan() {
142        return typed("span", Span.READER);
143    }
144
145    /**
146     * The member {@code cteName}. Label only: the CTE name as written. Never an identity or a path
147     * step. Null when absent; throws IllegalStateException when the member holds another JSON type.
148     */
149    public String getCteName() {
150        return string("cteName");
151    }
152
153    /**
154     * The member {@code alias}. Label only: the alias as written. Null when absent; throws
155     * IllegalStateException when the member holds another JSON type.
156     */
157    public String getAlias() {
158        return string("alias");
159    }
160
161    /**
162     * The member {@code inputKind}. TERMINAL nodes: the kind of input (never FIELD_REF). The kind
163     * of an input of a TargetFieldOccurrence. Registry group 'inputKinds' (Section 4.4). Null when
164     * absent; throws IllegalStateException when the member holds another JSON type.
165     */
166    public String getInputKind() {
167        return string("inputKind");
168    }
169
170    /**
171     * The member {@code disclosure}. TERMINAL CONSTANT nodes: how the literal is carried. How the
172     * value of a CONSTANT input is carried. Registry group 'constantValueDisclosure' (Section 4.4).
173     * Null when absent; throws IllegalStateException when the member holds another JSON type.
174     */
175    public String getDisclosure() {
176        return string("disclosure");
177    }
178
179    /**
180     * The member {@code literal}. TERMINAL CONSTANT with disclosure PRESENT: the literal as
181     * written, after redaction. Null when absent; throws IllegalStateException when the member
182     * holds another JSON type.
183     */
184    public String getLiteral() {
185        return string("literal");
186    }
187
188    /**
189     * The member {@code token}. TERMINAL CONSTANT with disclosure HASHED. Null when absent; throws
190     * IllegalStateException when the member holds another JSON type.
191     */
192    public KeyedToken getToken() {
193        return typed("token", KeyedToken.READER);
194    }
195
196    /**
197     * The member {@code parameterText}. TERMINAL PARAMETER: the parameter marker or name as written
198     * (a bind, positional or host parameter the input does not declare); it becomes the
199     * parameterText of the write input (algorithms/fold-v1.md, Section 7.5). Null when absent;
200     * throws IllegalStateException when the member holds another JSON type.
201     */
202    public String getParameterText() {
203        return string("parameterText");
204    }
205
206    /**
207     * The member {@code parameterOrdinal}. TERMINAL PARAMETER with parameterText "?": the position
208     * of the anonymous marker among the statement's anonymous markers, 0-based in text order; it
209     * becomes the parameterOrdinal of the write input (algorithms/fold-v1.md, Section 7.5). A
210     * 0-based ordinal. Null when absent; throws IllegalStateException when the member holds another
211     * JSON type.
212     */
213    public Long getParameterOrdinal() {
214        return integer("parameterOrdinal");
215    }
216
217    /**
218     * The member {@code upstreamCompleteness}. Whether the inputs of this node are completely
219     * known; absent means COMPLETE (algorithms/fold-v1.md, Section 7.4). Upstream completeness of
220     * one write. Registry group 'upstreamCompleteness' (Section 4.4). Null when absent; throws
221     * IllegalStateException when the member holds another JSON type.
222     */
223    public String getUpstreamCompleteness() {
224        return string("upstreamCompleteness");
225    }
226
227    /**
228     * The member {@code diagnosticRefs}. The diagnostics that lowered upstreamCompleteness. A set
229     * of local references. Null when absent; throws IllegalStateException when the member holds
230     * another JSON type.
231     */
232    public List<Long> getDiagnosticRefs() {
233        return typed("diagnosticRefs", listOf(INTEGER));
234    }
235
236    /**
237     * The member {@code key}. The logical node key; absent when the source unit has no unitId. An
238     * id computed by ExplainNodeKeyV1: 'xnk1-' followed by 64 lowercase hexadecimal characters of a
239     * SHA-256 digest (algorithms/identity-v1.md). Null when absent; throws IllegalStateException
240     * when the member holds another JSON type.
241     */
242    public String getKey() {
243        return string("key");
244    }
245
246    /**
247     * The member {@code recordId}. The node record id; absent when key or the unit's
248     * analysisContextId is absent. An id computed by ExplainNodeRecordIdV1: 'xnr1-' followed by 64
249     * lowercase hexadecimal characters of a SHA-256 digest (algorithms/identity-v1.md). Null when
250     * absent; throws IllegalStateException when the member holds another JSON type.
251     */
252    public String getRecordId() {
253        return string("recordId");
254    }
255
256    /**
257     * The member {@code extensions}. Extension data keyed by namespace. Every core object may carry
258     * it; it never takes part in a core identity. Null when absent; throws IllegalStateException
259     * when the member holds another JSON type.
260     */
261    public Map<String, Extension> getExtensions() {
262        return typed("extensions", mapOf(Extension.READER));
263    }
264
265    /** Collects the members of a new {@code ExplainNode}. */
266    public static final class Builder extends SqllrObject.Builder<ExplainNode, Builder> {
267        private Builder(Map<String, Object> from) {
268            super(from);
269        }
270
271        /** Sets the member {@code ref}; null removes it. */
272        public Builder ref(Long value) {
273            return set("ref", value);
274        }
275
276        /** Sets the member {@code kind}; null removes it. */
277        public Builder kind(String value) {
278            return set("kind", value);
279        }
280
281        /** Sets the member {@code role}; null removes it. */
282        public Builder role(String value) {
283            return set("role", value);
284        }
285
286        /** Sets the member {@code statementRef}; null removes it. */
287        public Builder statementRef(Long value) {
288            return set("statementRef", value);
289        }
290
291        /** Sets the member {@code parentRef}; null removes it. */
292        public Builder parentRef(Long value) {
293            return set("parentRef", value);
294        }
295
296        /** Sets the member {@code ownerRef}; null removes it. */
297        public Builder ownerRef(Long value) {
298            return set("ownerRef", value);
299        }
300
301        /** Sets the member {@code path}; null removes it. */
302        public Builder path(String value) {
303            return set("path", value);
304        }
305
306        /** Sets the member {@code ordinal}; null removes it. */
307        public Builder ordinal(Long value) {
308            return set("ordinal", value);
309        }
310
311        /** Sets the member {@code span}; null removes it. */
312        public Builder span(Span value) {
313            return set("span", value);
314        }
315
316        /** Sets the member {@code cteName}; null removes it. */
317        public Builder cteName(String value) {
318            return set("cteName", value);
319        }
320
321        /** Sets the member {@code alias}; null removes it. */
322        public Builder alias(String value) {
323            return set("alias", value);
324        }
325
326        /** Sets the member {@code inputKind}; null removes it. */
327        public Builder inputKind(String value) {
328            return set("inputKind", value);
329        }
330
331        /** Sets the member {@code disclosure}; null removes it. */
332        public Builder disclosure(String value) {
333            return set("disclosure", value);
334        }
335
336        /** Sets the member {@code literal}; null removes it. */
337        public Builder literal(String value) {
338            return set("literal", value);
339        }
340
341        /** Sets the member {@code token}; null removes it. */
342        public Builder token(KeyedToken value) {
343            return set("token", value);
344        }
345
346        /** Sets the member {@code parameterText}; null removes it. */
347        public Builder parameterText(String value) {
348            return set("parameterText", value);
349        }
350
351        /** Sets the member {@code parameterOrdinal}; null removes it. */
352        public Builder parameterOrdinal(Long value) {
353            return set("parameterOrdinal", value);
354        }
355
356        /** Sets the member {@code upstreamCompleteness}; null removes it. */
357        public Builder upstreamCompleteness(String value) {
358            return set("upstreamCompleteness", value);
359        }
360
361        /** Sets the member {@code diagnosticRefs}; null removes it. */
362        public Builder diagnosticRefs(List<Long> value) {
363            return set("diagnosticRefs", value);
364        }
365
366        /** Sets the member {@code key}; null removes it. */
367        public Builder key(String value) {
368            return set("key", value);
369        }
370
371        /** Sets the member {@code recordId}; null removes it. */
372        public Builder recordId(String value) {
373            return set("recordId", value);
374        }
375
376        /** Sets the member {@code extensions}; null removes it. */
377        public Builder extensions(Map<String, Extension> value) {
378            return set("extensions", value);
379        }
380
381        @Override
382        public ExplainNode build() {
383            return new ExplainNode(frozenMembers());
384        }
385    }
386}