1use std::any::Any;
16
17use common_error::ext::ErrorExt;
18use common_error::status_code::StatusCode;
19use common_macro::stack_trace_debug;
20use datatypes::timestamp::TimestampNanosecond;
21use snafu::{Location, Snafu};
22use vrl::value::Kind;
23
24#[derive(Snafu)]
25#[snafu(visibility(pub))]
26#[stack_trace_debug]
27pub enum Error {
28 #[snafu(display("Empty input field"))]
29 EmptyInputField {
30 #[snafu(implicit)]
31 location: Location,
32 },
33
34 #[snafu(display("Missing input field"))]
35 MissingInputField {
36 #[snafu(implicit)]
37 location: Location,
38 },
39
40 #[snafu(display(
41 "Field renaming must be a string pair of 'key' and 'rename_to', got: {value:?}"
42 ))]
43 InvalidFieldRename {
44 value: yaml_rust::Yaml,
45 #[snafu(implicit)]
46 location: Location,
47 },
48
49 #[snafu(display("Processor must be a map"))]
50 ProcessorMustBeMap {
51 #[snafu(implicit)]
52 location: Location,
53 },
54
55 #[snafu(display("Processor {processor}: missing field: {field}"))]
56 ProcessorMissingField {
57 processor: String,
58 field: String,
59 #[snafu(implicit)]
60 location: Location,
61 },
62
63 #[snafu(display("Processor {processor}: expect string value, but got {v:?}"))]
64 ProcessorExpectString {
65 processor: String,
66 v: vrl::value::Value,
67 #[snafu(implicit)]
68 location: Location,
69 },
70
71 #[snafu(display("Processor {processor}: unsupported value {val}"))]
72 ProcessorUnsupportedValue {
73 processor: String,
74 val: String,
75 #[snafu(implicit)]
76 location: Location,
77 },
78
79 #[snafu(display("Processor key must be a string"))]
80 ProcessorKeyMustBeString {
81 #[snafu(implicit)]
82 location: Location,
83 },
84
85 #[snafu(display("Processor {kind}: failed to parse {value}"))]
86 ProcessorFailedToParseString {
87 kind: String,
88 value: String,
89 #[snafu(implicit)]
90 location: Location,
91 },
92
93 #[snafu(display("Processor must have a string key"))]
94 ProcessorMustHaveStringKey {
95 #[snafu(implicit)]
96 location: Location,
97 },
98
99 #[snafu(display("Unsupported {processor} processor"))]
100 UnsupportedProcessor {
101 processor: String,
102 #[snafu(implicit)]
103 location: Location,
104 },
105
106 #[snafu(display("Field {field} must be a {ty}"))]
107 FieldMustBeType {
108 field: String,
109 ty: String,
110 #[snafu(implicit)]
111 location: Location,
112 },
113
114 #[snafu(display("Field parse from string failed: {field}"))]
115 FailedParseFieldFromString {
116 #[snafu(source)]
117 error: Box<dyn std::error::Error + Send + Sync>,
118 field: String,
119 #[snafu(implicit)]
120 location: Location,
121 },
122
123 #[snafu(display("Failed to parse {key} as int: {value}"))]
124 FailedToParseIntKey {
125 key: String,
126 value: String,
127 #[snafu(source)]
128 error: std::num::ParseIntError,
129 #[snafu(implicit)]
130 location: Location,
131 },
132
133 #[snafu(display("Failed to parse {value} to int"))]
134 FailedToParseInt {
135 value: String,
136 #[snafu(source)]
137 error: std::num::ParseIntError,
138 #[snafu(implicit)]
139 location: Location,
140 },
141 #[snafu(display("Failed to parse {key} as float: {value}"))]
142 FailedToParseFloatKey {
143 key: String,
144 value: String,
145 #[snafu(source)]
146 error: std::num::ParseFloatError,
147 #[snafu(implicit)]
148 location: Location,
149 },
150
151 #[snafu(display("Processor {kind}: {key} not found in intermediate keys"))]
152 IntermediateKeyIndex {
153 kind: String,
154 key: String,
155 #[snafu(implicit)]
156 location: Location,
157 },
158
159 #[snafu(display("Cmcd {k} missing value in {s}"))]
160 CmcdMissingValue {
161 k: String,
162 s: String,
163 #[snafu(implicit)]
164 location: Location,
165 },
166 #[snafu(display("Part: {part} missing key in {s}"))]
167 CmcdMissingKey {
168 part: String,
169 s: String,
170 #[snafu(implicit)]
171 location: Location,
172 },
173 #[snafu(display("Key must be a string, but got {k:?}"))]
174 KeyMustBeString {
175 k: yaml_rust::Yaml,
176 #[snafu(implicit)]
177 location: Location,
178 },
179
180 #[snafu(display("Csv read error"))]
181 CsvRead {
182 #[snafu(implicit)]
183 location: Location,
184 #[snafu(source)]
185 error: csv::Error,
186 },
187 #[snafu(display("Expected at least one record from csv format, but got none"))]
188 CsvNoRecord {
189 #[snafu(implicit)]
190 location: Location,
191 },
192
193 #[snafu(display("Separator '{separator}' must be a single character, but got '{value}'"))]
194 CsvSeparatorName {
195 separator: String,
196 value: String,
197 #[snafu(implicit)]
198 location: Location,
199 },
200
201 #[snafu(display("Quote '{quote}' must be a single character, but got '{value}'"))]
202 CsvQuoteName {
203 quote: String,
204 value: String,
205 #[snafu(implicit)]
206 location: Location,
207 },
208
209 #[snafu(display("Parse date timezone error {value}"))]
210 DateParseTimezone {
211 value: String,
212 #[snafu(source)]
213 error: chrono_tz::ParseError,
214 #[snafu(implicit)]
215 location: Location,
216 },
217
218 #[snafu(display("Parse date error {value}"))]
219 DateParse {
220 value: String,
221 #[snafu(source)]
222 error: chrono::ParseError,
223 #[snafu(implicit)]
224 location: Location,
225 },
226
227 #[snafu(display("Failed to get local timezone"))]
228 DateFailedToGetLocalTimezone {
229 #[snafu(implicit)]
230 location: Location,
231 },
232
233 #[snafu(display("Invalid Pattern: '{s}'. {detail}"))]
234 DissectInvalidPattern {
235 s: String,
236 detail: String,
237 #[snafu(implicit)]
238 location: Location,
239 },
240
241 #[snafu(display("Empty pattern is not allowed"))]
242 DissectEmptyPattern {
243 #[snafu(implicit)]
244 location: Location,
245 },
246 #[snafu(display("Split: '{split}' exceeds the input"))]
247 DissectSplitExceedsInput {
248 split: String,
249 #[snafu(implicit)]
250 location: Location,
251 },
252 #[snafu(display("Split: '{split}' does not match the input '{input}'"))]
253 DissectSplitNotMatchInput {
254 split: String,
255 input: String,
256 #[snafu(implicit)]
257 location: Location,
258 },
259 #[snafu(display("Consecutive names are not allowed: '{name1}' '{name2}'"))]
260 DissectConsecutiveNames {
261 name1: String,
262 name2: String,
263 #[snafu(implicit)]
264 location: Location,
265 },
266 #[snafu(display("No matching pattern found"))]
267 DissectNoMatchingPattern {
268 #[snafu(implicit)]
269 location: Location,
270 },
271 #[snafu(display("Modifier '{m}' already set, but found {modifier}"))]
272 DissectModifierAlreadySet {
273 m: String,
274 modifier: String,
275 #[snafu(implicit)]
276 location: Location,
277 },
278
279 #[snafu(display("Append Order modifier is already set to '{n}', cannot be set to {order}"))]
280 DissectAppendOrderAlreadySet {
281 n: String,
282 order: u32,
283 #[snafu(implicit)]
284 location: Location,
285 },
286 #[snafu(display("Order can only be set to Append Modifier, current modifier is {m}"))]
287 DissectOrderOnlyAppend {
288 m: String,
289 #[snafu(implicit)]
290 location: Location,
291 },
292
293 #[snafu(display("Order can only be set to Append Modifier"))]
294 DissectOrderOnlyAppendModifier {
295 #[snafu(implicit)]
296 location: Location,
297 },
298
299 #[snafu(display("End modifier already set: '{m}'"))]
300 DissectEndModifierAlreadySet {
301 m: String,
302 #[snafu(implicit)]
303 location: Location,
304 },
305 #[snafu(display("Invalid resolution: {resolution}"))]
306 EpochInvalidResolution {
307 resolution: String,
308 #[snafu(implicit)]
309 location: Location,
310 },
311 #[snafu(display("Pattern is required"))]
312 GsubPatternRequired {
313 #[snafu(implicit)]
314 location: Location,
315 },
316 #[snafu(display("Replacement is required"))]
317 GsubReplacementRequired {
318 #[snafu(implicit)]
319 location: Location,
320 },
321 #[snafu(display("Invalid regex pattern: {pattern}"))]
322 Regex {
323 #[snafu(source)]
324 error: regex::Error,
325 pattern: String,
326 #[snafu(implicit)]
327 location: Location,
328 },
329 #[snafu(display("Separator is required"))]
330 JoinSeparatorRequired {
331 #[snafu(implicit)]
332 location: Location,
333 },
334 #[snafu(display("Invalid method: {method}"))]
335 LetterInvalidMethod {
336 method: String,
337 #[snafu(implicit)]
338 location: Location,
339 },
340 #[snafu(display("No named group found in regex {origin}"))]
341 RegexNamedGroupNotFound {
342 origin: String,
343 #[snafu(implicit)]
344 location: Location,
345 },
346 #[snafu(display("No valid field found in {processor} processor"))]
347 RegexNoValidField {
348 processor: String,
349 #[snafu(implicit)]
350 location: Location,
351 },
352 #[snafu(display("No valid pattern found in {processor} processor"))]
353 RegexNoValidPattern {
354 processor: String,
355 #[snafu(implicit)]
356 location: Location,
357 },
358 #[snafu(display("Invalid method: {s}"))]
359 UrlEncodingInvalidMethod {
360 s: String,
361 #[snafu(implicit)]
362 location: Location,
363 },
364 #[snafu(display("Wrong digest pattern: {pattern}"))]
365 DigestPatternInvalid {
366 pattern: String,
367 #[snafu(implicit)]
368 location: Location,
369 },
370 #[snafu(display("Invalid transform on_failure value: {value}"))]
371 TransformOnFailureInvalidValue {
372 value: String,
373 #[snafu(implicit)]
374 location: Location,
375 },
376 #[snafu(display("Transform element must be a map"))]
377 TransformElementMustBeMap {
378 #[snafu(implicit)]
379 location: Location,
380 },
381 #[snafu(display("Transform fields must be set."))]
382 TransformFieldMustBeSet {
383 #[snafu(implicit)]
384 location: Location,
385 },
386 #[snafu(display("Transform {fields:?} type MUST BE set."))]
387 TransformTypeMustBeSet {
388 fields: String,
389 #[snafu(implicit)]
390 location: Location,
391 },
392 #[snafu(display("Transform index `type` must be set."))]
393 TransformIndexTypeMustBeSet {
394 #[snafu(implicit)]
395 location: Location,
396 },
397 #[snafu(display("Unsupported field in transform index config: {field}"))]
398 TransformIndexUnsupportedField {
399 field: String,
400 #[snafu(implicit)]
401 location: Location,
402 },
403 #[snafu(display(
404 "Transform index option `{field}` must be a string, boolean, integer, or real scalar"
405 ))]
406 TransformIndexOptionMustBeScalar {
407 field: String,
408 #[snafu(implicit)]
409 location: Location,
410 },
411 #[snafu(display("Index type `{index}` does not support options in pipeline config"))]
412 TransformIndexOptionsUnsupported {
413 index: String,
414 #[snafu(implicit)]
415 location: Location,
416 },
417 #[snafu(display("Unsupported option `{key}` for `{index}` index"))]
418 TransformIndexOptionUnsupported {
419 index: String,
420 key: String,
421 #[snafu(implicit)]
422 location: Location,
423 },
424 #[snafu(display("Index `{index}` only supports {expected} columns, but got {actual}"))]
425 TransformIndexTypeMismatch {
426 index: String,
427 expected: String,
428 actual: String,
429 #[snafu(implicit)]
430 location: Location,
431 },
432 #[snafu(display("Invalid options for `{index}` index"))]
433 TransformIndexOption {
434 index: String,
435 #[snafu(source)]
436 source: datatypes::error::Error,
437 #[snafu(implicit)]
438 location: Location,
439 },
440 #[snafu(display("Transform index `{index}` does not match options declared for `{options}`"))]
441 TransformIndexStateMismatch {
442 index: String,
443 options: String,
444 #[snafu(implicit)]
445 location: Location,
446 },
447 #[snafu(display("Column name must be unique, but got duplicated: {duplicates}"))]
448 TransformColumnNameMustBeUnique {
449 duplicates: String,
450 #[snafu(implicit)]
451 location: Location,
452 },
453 #[snafu(display(
454 "Illegal to set multiple timestamp Index columns, please set only one: {columns}"
455 ))]
456 TransformMultipleTimestampIndex {
457 columns: String,
458 #[snafu(implicit)]
459 location: Location,
460 },
461 #[snafu(display(
462 "Transform must have exactly one field specified as timestamp Index, but got {count}: {columns}"
463 ))]
464 TransformTimestampIndexCount {
465 count: usize,
466 columns: String,
467 #[snafu(implicit)]
468 location: Location,
469 },
470 #[snafu(display(
471 "Exactly one time-related processor and one timestamp value is required to use auto transform. `ignore_missing` can not be set to true."
472 ))]
473 AutoTransformOneTimestamp {
474 #[snafu(implicit)]
475 location: Location,
476 },
477 #[snafu(display("Invalid Pipeline doc version number: {}", version))]
478 InvalidVersionNumber {
479 version: String,
480 #[snafu(implicit)]
481 location: Location,
482 },
483 #[snafu(display("Type: {ty} value not supported for Epoch"))]
484 CoerceUnsupportedEpochType {
485 ty: String,
486 #[snafu(implicit)]
487 location: Location,
488 },
489 #[snafu(display("Failed to coerce string value '{s}' to type '{ty}'"))]
490 CoerceStringToType {
491 s: String,
492 ty: String,
493 #[snafu(implicit)]
494 location: Location,
495 },
496 #[snafu(display("Can not coerce json type to {ty}"))]
497 CoerceJsonTypeTo {
498 ty: String,
499 #[snafu(implicit)]
500 location: Location,
501 },
502 #[snafu(display(
503 "Can not coerce {ty} to json type. we only consider object and array to be json types."
504 ))]
505 CoerceTypeToJson {
506 ty: String,
507 #[snafu(implicit)]
508 location: Location,
509 },
510 #[snafu(display("Failed to coerce value: {msg}"))]
511 CoerceIncompatibleTypes {
512 msg: String,
513 #[snafu(implicit)]
514 location: Location,
515 },
516 #[snafu(display(
517 "Invalid resolution: '{resolution}'. Available resolutions: {valid_resolution}"
518 ))]
519 ValueInvalidResolution {
520 resolution: String,
521 valid_resolution: String,
522 #[snafu(implicit)]
523 location: Location,
524 },
525
526 #[snafu(display("Failed to parse type: '{t}'"))]
527 ValueParseType {
528 t: String,
529 #[snafu(implicit)]
530 location: Location,
531 },
532
533 #[snafu(display("Failed to parse {ty}: {v}"))]
534 ValueParseInt {
535 ty: String,
536 v: String,
537 #[snafu(source)]
538 error: std::num::ParseIntError,
539 #[snafu(implicit)]
540 location: Location,
541 },
542
543 #[snafu(display("Failed to parse {ty}: {v}"))]
544 ValueParseFloat {
545 ty: String,
546 v: String,
547 #[snafu(source)]
548 error: std::num::ParseFloatError,
549 #[snafu(implicit)]
550 location: Location,
551 },
552
553 #[snafu(display("Failed to parse {ty}: {v}"))]
554 ValueParseBoolean {
555 ty: String,
556 v: String,
557 #[snafu(source)]
558 error: std::str::ParseBoolError,
559 #[snafu(implicit)]
560 location: Location,
561 },
562 #[snafu(display("Default value not unsupported for type {value}"))]
563 ValueDefaultValueUnsupported {
564 value: String,
565 #[snafu(implicit)]
566 location: Location,
567 },
568
569 #[snafu(display("Unsupported yaml type: {value:?}"))]
570 ValueUnsupportedYamlType {
571 value: yaml_rust::Yaml,
572 #[snafu(implicit)]
573 location: Location,
574 },
575
576 #[snafu(display("key in Hash must be a string, but got {value:?}"))]
577 ValueYamlKeyMustBeString {
578 value: yaml_rust::Yaml,
579 #[snafu(implicit)]
580 location: Location,
581 },
582
583 #[snafu(display("Yaml load error."))]
584 YamlLoad {
585 #[snafu(source)]
586 error: yaml_rust::ScanError,
587 #[snafu(implicit)]
588 location: Location,
589 },
590 #[snafu(display("Yaml parse error."))]
591 YamlParse {
592 #[snafu(implicit)]
593 location: Location,
594 },
595 #[snafu(display("Column options error"))]
596 ColumnOptions {
597 #[snafu(source)]
598 source: api::error::Error,
599 #[snafu(implicit)]
600 location: Location,
601 },
602 #[snafu(display("Unsupported index type: {value}"))]
603 UnsupportedIndexType {
604 value: String,
605 #[snafu(implicit)]
606 location: Location,
607 },
608 #[snafu(display("Failed to parse json"))]
609 JsonParse {
610 #[snafu(source)]
611 error: serde_json::Error,
612 #[snafu(implicit)]
613 location: Location,
614 },
615 #[snafu(display(
616 "Column datatype mismatch. For column: {column}, expected datatype: {expected}, actual datatype: {actual}"
617 ))]
618 IdentifyPipelineColumnTypeMismatch {
619 column: String,
620 expected: String,
621 actual: String,
622 #[snafu(implicit)]
623 location: Location,
624 },
625 #[snafu(display("Parse json path error"))]
626 JsonPathParse {
627 #[snafu(implicit)]
628 location: Location,
629 #[snafu(source)]
630 error: jsonpath_rust::JsonPathParserError,
631 },
632 #[snafu(display("Json path result index not number"))]
633 JsonPathParseResultIndex {
634 #[snafu(implicit)]
635 location: Location,
636 },
637 #[snafu(display("Field is required for dispatcher"))]
638 FieldRequiredForDispatcher,
639 #[snafu(display("Table_suffix is required for dispatcher rule"))]
640 TableSuffixRequiredForDispatcherRule,
641 #[snafu(display("Value is required for dispatcher rule"))]
642 ValueRequiredForDispatcherRule,
643
644 #[snafu(display("Pipeline table not found"))]
645 PipelineTableNotFound {
646 #[snafu(implicit)]
647 location: Location,
648 },
649
650 #[snafu(display("Failed to insert pipeline to pipelines table"))]
651 InsertPipeline {
652 #[snafu(source)]
653 source: operator::error::Error,
654 #[snafu(implicit)]
655 location: Location,
656 },
657
658 #[snafu(display("Pipeline not found, name: {}, version: {}", name, version.map(|ts| ts.0.to_iso8601_string()).unwrap_or("latest".to_string())))]
659 PipelineNotFound {
660 name: String,
661 version: Option<TimestampNanosecond>,
662 #[snafu(implicit)]
663 location: Location,
664 },
665
666 #[snafu(display(
667 "Multiple pipelines with different schemas found, but none under current schema. Please replicate one of them or delete until only one schema left. name: {}, current_schema: {}, schemas: {}",
668 name,
669 current_schema,
670 schemas,
671 ))]
672 MultiPipelineWithDiffSchema {
673 name: String,
674 current_schema: String,
675 schemas: String,
676 #[snafu(implicit)]
677 location: Location,
678 },
679
680 #[snafu(display(
681 "The return value's length of the record batch does not match, see debug log for details"
682 ))]
683 RecordBatchLenNotMatch {
684 #[snafu(implicit)]
685 location: Location,
686 },
687
688 #[snafu(display("Failed to collect record batch"))]
689 CollectRecords {
690 #[snafu(implicit)]
691 location: Location,
692 #[snafu(source)]
693 source: common_recordbatch::error::Error,
694 },
695
696 #[snafu(display("A valid table suffix template is required for tablesuffix section"))]
697 RequiredTableSuffixTemplate,
698
699 #[snafu(display("Invalid table suffix template, input: {}", input))]
700 InvalidTableSuffixTemplate {
701 input: String,
702 #[snafu(implicit)]
703 location: Location,
704 },
705
706 #[snafu(display("Failed to compile VRL, {}", msg))]
707 CompileVrl {
708 msg: String,
709 #[snafu(implicit)]
710 location: Location,
711 },
712
713 #[snafu(display("Failed to execute VRL, {}", msg))]
714 ExecuteVrl {
715 msg: String,
716 #[snafu(implicit)]
717 location: Location,
718 },
719 #[snafu(display("Invalid timestamp value: {}", input))]
720 InvalidTimestamp {
721 input: String,
722 #[snafu(implicit)]
723 location: Location,
724 },
725
726 #[snafu(display("Invalid epoch value '{}' for resolution '{}'", value, resolution))]
727 InvalidEpochForResolution {
728 value: i64,
729 resolution: String,
730 #[snafu(implicit)]
731 location: Location,
732 },
733 #[snafu(display("Please don't use regex in Vrl script"))]
734 VrlRegexValue {
735 #[snafu(implicit)]
736 location: Location,
737 },
738
739 #[snafu(display(
740 "Vrl script should return object or array in the end, got `{:?}`",
741 result_kind
742 ))]
743 VrlReturnValue {
744 result_kind: Kind,
745 #[snafu(implicit)]
746 location: Location,
747 },
748
749 #[snafu(display("Failed to cast type, msg: {}", msg))]
750 CastType {
751 msg: String,
752 #[snafu(implicit)]
753 location: Location,
754 },
755
756 #[snafu(display("Top level value must be map"))]
757 ValueMustBeMap {
758 #[snafu(implicit)]
759 location: Location,
760 },
761
762 #[snafu(display(
763 "Array element at index {index} must be an object for one-to-many transformation, got {actual_type}"
764 ))]
765 ArrayElementMustBeObject {
766 index: usize,
767 actual_type: String,
768 #[snafu(implicit)]
769 location: Location,
770 },
771
772 #[snafu(display("Failed to transform array element at index {index}: {source}"))]
773 TransformArrayElement {
774 index: usize,
775 #[snafu(source)]
776 source: Box<Error>,
777 #[snafu(implicit)]
778 location: Location,
779 },
780
781 #[snafu(display("Failed to build DataFusion logical plan"))]
782 BuildDfLogicalPlan {
783 #[snafu(source)]
784 error: datafusion_common::DataFusionError,
785 #[snafu(implicit)]
786 location: Location,
787 },
788
789 #[snafu(display("Failed to execute internal statement"))]
790 ExecuteInternalStatement {
791 #[snafu(source)]
792 source: query::error::Error,
793 #[snafu(implicit)]
794 location: Location,
795 },
796
797 #[snafu(display("Failed to create dataframe"))]
798 DataFrame {
799 #[snafu(source)]
800 source: query::error::Error,
801 #[snafu(implicit)]
802 location: Location,
803 },
804
805 #[snafu(display("General catalog error"))]
806 Catalog {
807 #[snafu(source)]
808 source: catalog::error::Error,
809 #[snafu(implicit)]
810 location: Location,
811 },
812
813 #[snafu(display("Failed to create table"))]
814 CreateTable {
815 #[snafu(source)]
816 source: operator::error::Error,
817 #[snafu(implicit)]
818 location: Location,
819 },
820
821 #[snafu(display("Invalid pipeline version format: {}", version))]
822 InvalidPipelineVersion {
823 version: String,
824 #[snafu(implicit)]
825 location: Location,
826 },
827
828 #[snafu(display("Invalid custom time index config: {}, reason: {}", config, reason))]
829 InvalidCustomTimeIndex {
830 config: String,
831 reason: String,
832 #[snafu(implicit)]
833 location: Location,
834 },
835
836 #[snafu(display("Pipeline is required for this API."))]
837 PipelineMissing {
838 #[snafu(implicit)]
839 location: Location,
840 },
841
842 #[snafu(display("Time index must be non null."))]
843 TimeIndexMustBeNonNull {
844 #[snafu(implicit)]
845 location: Location,
846 },
847
848 #[snafu(display("Float is NaN"))]
849 FloatIsNan {
850 #[snafu(source)]
851 error: ordered_float::FloatIsNan,
852 #[snafu(implicit)]
853 location: Location,
854 },
855
856 #[snafu(display("Unsupported type in pipeline: {}", ty))]
857 UnsupportedTypeInPipeline {
858 ty: String,
859 #[snafu(implicit)]
860 location: Location,
861 },
862
863 #[snafu(transparent)]
864 GreptimeProto {
865 source: api::error::Error,
866 #[snafu(implicit)]
867 location: Location,
868 },
869
870 #[snafu(transparent)]
871 Datatypes {
872 source: datatypes::error::Error,
873 #[snafu(implicit)]
874 location: Location,
875 },
876}
877
878pub type Result<T> = std::result::Result<T, Error>;
879
880impl ErrorExt for Error {
881 fn status_code(&self) -> StatusCode {
882 use Error::*;
883 match self {
884 CastType { .. } => StatusCode::Unexpected,
885 PipelineTableNotFound { .. } => StatusCode::TableNotFound,
886 InsertPipeline { source, .. } => source.status_code(),
887 CollectRecords { source, .. } => source.status_code(),
888 PipelineNotFound { .. }
889 | InvalidPipelineVersion { .. }
890 | InvalidCustomTimeIndex { .. }
891 | TimeIndexMustBeNonNull { .. } => StatusCode::InvalidArguments,
892 MultiPipelineWithDiffSchema { .. }
893 | ValueMustBeMap { .. }
894 | ArrayElementMustBeObject { .. } => StatusCode::IllegalState,
895 TransformArrayElement { source, .. } => source.status_code(),
896 BuildDfLogicalPlan { .. } | RecordBatchLenNotMatch { .. } => StatusCode::Internal,
897 ExecuteInternalStatement { source, .. } => source.status_code(),
898 DataFrame { source, .. } => source.status_code(),
899 Catalog { source, .. } => source.status_code(),
900 CreateTable { source, .. } => source.status_code(),
901
902 EmptyInputField { .. }
903 | MissingInputField { .. }
904 | InvalidFieldRename { .. }
905 | ProcessorMustBeMap { .. }
906 | ProcessorMissingField { .. }
907 | ProcessorExpectString { .. }
908 | ProcessorUnsupportedValue { .. }
909 | ProcessorKeyMustBeString { .. }
910 | ProcessorFailedToParseString { .. }
911 | ProcessorMustHaveStringKey { .. }
912 | UnsupportedProcessor { .. }
913 | FieldMustBeType { .. }
914 | FailedParseFieldFromString { .. }
915 | FailedToParseIntKey { .. }
916 | FailedToParseInt { .. }
917 | FailedToParseFloatKey { .. }
918 | IntermediateKeyIndex { .. }
919 | CmcdMissingValue { .. }
920 | CmcdMissingKey { .. }
921 | KeyMustBeString { .. }
922 | CsvRead { .. }
923 | CsvNoRecord { .. }
924 | CsvSeparatorName { .. }
925 | CsvQuoteName { .. }
926 | DateParseTimezone { .. }
927 | DateParse { .. }
928 | DateFailedToGetLocalTimezone { .. }
929 | DissectInvalidPattern { .. }
930 | DissectEmptyPattern { .. }
931 | DissectSplitExceedsInput { .. }
932 | DissectSplitNotMatchInput { .. }
933 | DissectConsecutiveNames { .. }
934 | DissectNoMatchingPattern { .. }
935 | DissectModifierAlreadySet { .. }
936 | DissectAppendOrderAlreadySet { .. }
937 | DissectOrderOnlyAppend { .. }
938 | DissectOrderOnlyAppendModifier { .. }
939 | DissectEndModifierAlreadySet { .. }
940 | EpochInvalidResolution { .. }
941 | GsubPatternRequired { .. }
942 | GsubReplacementRequired { .. }
943 | Regex { .. }
944 | JoinSeparatorRequired { .. }
945 | LetterInvalidMethod { .. }
946 | RegexNamedGroupNotFound { .. }
947 | RegexNoValidField { .. }
948 | RegexNoValidPattern { .. }
949 | UrlEncodingInvalidMethod { .. }
950 | DigestPatternInvalid { .. }
951 | TransformOnFailureInvalidValue { .. }
952 | TransformElementMustBeMap { .. }
953 | TransformFieldMustBeSet { .. }
954 | TransformTypeMustBeSet { .. }
955 | TransformIndexTypeMustBeSet { .. }
956 | TransformIndexUnsupportedField { .. }
957 | TransformIndexOptionMustBeScalar { .. }
958 | TransformIndexOptionsUnsupported { .. }
959 | TransformIndexOptionUnsupported { .. }
960 | TransformIndexTypeMismatch { .. }
961 | TransformIndexOption { .. }
962 | TransformIndexStateMismatch { .. }
963 | TransformColumnNameMustBeUnique { .. }
964 | TransformMultipleTimestampIndex { .. }
965 | TransformTimestampIndexCount { .. }
966 | AutoTransformOneTimestamp { .. }
967 | InvalidVersionNumber { .. }
968 | CoerceUnsupportedEpochType { .. }
969 | CoerceStringToType { .. }
970 | CoerceJsonTypeTo { .. }
971 | CoerceTypeToJson { .. }
972 | CoerceIncompatibleTypes { .. }
973 | ValueInvalidResolution { .. }
974 | ValueParseType { .. }
975 | ValueParseInt { .. }
976 | ValueParseFloat { .. }
977 | ValueParseBoolean { .. }
978 | ValueDefaultValueUnsupported { .. }
979 | ValueUnsupportedYamlType { .. }
980 | ValueYamlKeyMustBeString { .. }
981 | YamlLoad { .. }
982 | YamlParse { .. }
983 | ColumnOptions { .. }
984 | UnsupportedIndexType { .. }
985 | IdentifyPipelineColumnTypeMismatch { .. }
986 | JsonParse { .. }
987 | JsonPathParse { .. }
988 | JsonPathParseResultIndex { .. }
989 | FieldRequiredForDispatcher
990 | TableSuffixRequiredForDispatcherRule
991 | ValueRequiredForDispatcherRule
992 | RequiredTableSuffixTemplate
993 | InvalidTableSuffixTemplate { .. }
994 | CompileVrl { .. }
995 | ExecuteVrl { .. }
996 | InvalidTimestamp { .. }
997 | VrlRegexValue { .. }
998 | VrlReturnValue { .. }
999 | PipelineMissing { .. } => StatusCode::InvalidArguments,
1000
1001 FloatIsNan { .. }
1002 | InvalidEpochForResolution { .. }
1003 | UnsupportedTypeInPipeline { .. } => StatusCode::InvalidArguments,
1004
1005 GreptimeProto { source, .. } => source.status_code(),
1006 Datatypes { source, .. } => source.status_code(),
1007 }
1008 }
1009
1010 fn as_any(&self) -> &dyn Any {
1011 self
1012 }
1013}