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("Invalid JSON2 type hint: {reason}"))]
393 InvalidJson2TypeHint {
394 reason: String,
395 #[snafu(implicit)]
396 location: Location,
397 },
398 #[snafu(display("Invalid JSON2 type hint path '{path}'"))]
399 ParseJson2TypeHintPath {
400 path: String,
401 #[snafu(source)]
402 source: sql::error::Error,
403 #[snafu(implicit)]
404 location: Location,
405 },
406 #[snafu(display("Transform index `type` must be set."))]
407 TransformIndexTypeMustBeSet {
408 #[snafu(implicit)]
409 location: Location,
410 },
411 #[snafu(display("Unsupported field in transform index config: {field}"))]
412 TransformIndexUnsupportedField {
413 field: String,
414 #[snafu(implicit)]
415 location: Location,
416 },
417 #[snafu(display(
418 "Transform index option `{field}` must be a string, boolean, integer, or real scalar"
419 ))]
420 TransformIndexOptionMustBeScalar {
421 field: String,
422 #[snafu(implicit)]
423 location: Location,
424 },
425 #[snafu(display("Index type `{index}` does not support options in pipeline config"))]
426 TransformIndexOptionsUnsupported {
427 index: String,
428 #[snafu(implicit)]
429 location: Location,
430 },
431 #[snafu(display("Unsupported option `{key}` for `{index}` index"))]
432 TransformIndexOptionUnsupported {
433 index: String,
434 key: String,
435 #[snafu(implicit)]
436 location: Location,
437 },
438 #[snafu(display("Index `{index}` only supports {expected} columns, but got {actual}"))]
439 TransformIndexTypeMismatch {
440 index: String,
441 expected: String,
442 actual: String,
443 #[snafu(implicit)]
444 location: Location,
445 },
446 #[snafu(display("Invalid options for `{index}` index"))]
447 TransformIndexOption {
448 index: String,
449 #[snafu(source)]
450 source: datatypes::error::Error,
451 #[snafu(implicit)]
452 location: Location,
453 },
454 #[snafu(display("Transform index `{index}` does not match options declared for `{options}`"))]
455 TransformIndexStateMismatch {
456 index: String,
457 options: String,
458 #[snafu(implicit)]
459 location: Location,
460 },
461 #[snafu(display("Column name must be unique, but got duplicated: {duplicates}"))]
462 TransformColumnNameMustBeUnique {
463 duplicates: String,
464 #[snafu(implicit)]
465 location: Location,
466 },
467 #[snafu(display(
468 "Illegal to set multiple timestamp Index columns, please set only one: {columns}"
469 ))]
470 TransformMultipleTimestampIndex {
471 columns: String,
472 #[snafu(implicit)]
473 location: Location,
474 },
475 #[snafu(display(
476 "Transform must have exactly one field specified as timestamp Index, but got {count}: {columns}"
477 ))]
478 TransformTimestampIndexCount {
479 count: usize,
480 columns: String,
481 #[snafu(implicit)]
482 location: Location,
483 },
484 #[snafu(display(
485 "Exactly one time-related processor and one timestamp value is required to use auto transform. `ignore_missing` can not be set to true."
486 ))]
487 AutoTransformOneTimestamp {
488 #[snafu(implicit)]
489 location: Location,
490 },
491 #[snafu(display("Invalid Pipeline doc version number: {}", version))]
492 InvalidVersionNumber {
493 version: String,
494 #[snafu(implicit)]
495 location: Location,
496 },
497 #[snafu(display("Type: {ty} value not supported for Epoch"))]
498 CoerceUnsupportedEpochType {
499 ty: String,
500 #[snafu(implicit)]
501 location: Location,
502 },
503 #[snafu(display("Failed to coerce string value '{s}' to type '{ty}'"))]
504 CoerceStringToType {
505 s: String,
506 ty: String,
507 #[snafu(implicit)]
508 location: Location,
509 },
510 #[snafu(display("Can not coerce json type to {ty}"))]
511 CoerceJsonTypeTo {
512 ty: String,
513 #[snafu(implicit)]
514 location: Location,
515 },
516 #[snafu(display(
517 "Can not coerce {ty} to json type. we only consider object and array to be json types."
518 ))]
519 CoerceTypeToJson {
520 ty: String,
521 #[snafu(implicit)]
522 location: Location,
523 },
524 #[snafu(display("Failed to coerce value: {msg}"))]
525 CoerceIncompatibleTypes {
526 msg: String,
527 #[snafu(implicit)]
528 location: Location,
529 },
530 #[snafu(display(
531 "Invalid resolution: '{resolution}'. Available resolutions: {valid_resolution}"
532 ))]
533 ValueInvalidResolution {
534 resolution: String,
535 valid_resolution: String,
536 #[snafu(implicit)]
537 location: Location,
538 },
539
540 #[snafu(display("Failed to parse type: '{t}'"))]
541 ValueParseType {
542 t: String,
543 #[snafu(implicit)]
544 location: Location,
545 },
546
547 #[snafu(display("Failed to parse {ty}: {v}"))]
548 ValueParseInt {
549 ty: String,
550 v: String,
551 #[snafu(source)]
552 error: std::num::ParseIntError,
553 #[snafu(implicit)]
554 location: Location,
555 },
556
557 #[snafu(display("Failed to parse {ty}: {v}"))]
558 ValueParseFloat {
559 ty: String,
560 v: String,
561 #[snafu(source)]
562 error: std::num::ParseFloatError,
563 #[snafu(implicit)]
564 location: Location,
565 },
566
567 #[snafu(display("Failed to parse {ty}: {v}"))]
568 ValueParseBoolean {
569 ty: String,
570 v: String,
571 #[snafu(source)]
572 error: std::str::ParseBoolError,
573 #[snafu(implicit)]
574 location: Location,
575 },
576 #[snafu(display("Default value not unsupported for type {value}"))]
577 ValueDefaultValueUnsupported {
578 value: String,
579 #[snafu(implicit)]
580 location: Location,
581 },
582
583 #[snafu(display("Unsupported yaml type: {value:?}"))]
584 ValueUnsupportedYamlType {
585 value: yaml_rust::Yaml,
586 #[snafu(implicit)]
587 location: Location,
588 },
589
590 #[snafu(display("key in Hash must be a string, but got {value:?}"))]
591 ValueYamlKeyMustBeString {
592 value: yaml_rust::Yaml,
593 #[snafu(implicit)]
594 location: Location,
595 },
596
597 #[snafu(display("Yaml load error."))]
598 YamlLoad {
599 #[snafu(source)]
600 error: yaml_rust::ScanError,
601 #[snafu(implicit)]
602 location: Location,
603 },
604 #[snafu(display("Yaml parse error."))]
605 YamlParse {
606 #[snafu(implicit)]
607 location: Location,
608 },
609 #[snafu(display("Column options error"))]
610 ColumnOptions {
611 #[snafu(source)]
612 source: api::error::Error,
613 #[snafu(implicit)]
614 location: Location,
615 },
616 #[snafu(display("Unsupported index type: {value}"))]
617 UnsupportedIndexType {
618 value: String,
619 #[snafu(implicit)]
620 location: Location,
621 },
622 #[snafu(display("Failed to parse json"))]
623 JsonParse {
624 #[snafu(source)]
625 error: serde_json::Error,
626 #[snafu(implicit)]
627 location: Location,
628 },
629 #[snafu(display(
630 "Column datatype mismatch. For column: {column}, expected datatype: {expected}, actual datatype: {actual}"
631 ))]
632 IdentifyPipelineColumnTypeMismatch {
633 column: String,
634 expected: String,
635 actual: String,
636 #[snafu(implicit)]
637 location: Location,
638 },
639 #[snafu(display("Parse json path error"))]
640 JsonPathParse {
641 #[snafu(implicit)]
642 location: Location,
643 #[snafu(source)]
644 error: jsonpath_rust::JsonPathParserError,
645 },
646 #[snafu(display("Json path result index not number"))]
647 JsonPathParseResultIndex {
648 #[snafu(implicit)]
649 location: Location,
650 },
651 #[snafu(display("Field is required for dispatcher"))]
652 FieldRequiredForDispatcher,
653 #[snafu(display("Table_suffix is required for dispatcher rule"))]
654 TableSuffixRequiredForDispatcherRule,
655 #[snafu(display("Value is required for dispatcher rule"))]
656 ValueRequiredForDispatcherRule,
657
658 #[snafu(display("Pipeline table not found"))]
659 PipelineTableNotFound {
660 #[snafu(implicit)]
661 location: Location,
662 },
663
664 #[snafu(display("Failed to insert pipeline to pipelines table"))]
665 InsertPipeline {
666 #[snafu(source)]
667 source: operator::error::Error,
668 #[snafu(implicit)]
669 location: Location,
670 },
671
672 #[snafu(display("Pipeline not found, name: {}, version: {}", name, version.map(|ts| ts.0.to_iso8601_string()).unwrap_or("latest".to_string())))]
673 PipelineNotFound {
674 name: String,
675 version: Option<TimestampNanosecond>,
676 #[snafu(implicit)]
677 location: Location,
678 },
679
680 #[snafu(display(
681 "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: {}",
682 name,
683 current_schema,
684 schemas,
685 ))]
686 MultiPipelineWithDiffSchema {
687 name: String,
688 current_schema: String,
689 schemas: String,
690 #[snafu(implicit)]
691 location: Location,
692 },
693
694 #[snafu(display(
695 "The return value's length of the record batch does not match, see debug log for details"
696 ))]
697 RecordBatchLenNotMatch {
698 #[snafu(implicit)]
699 location: Location,
700 },
701
702 #[snafu(display("Failed to load pipeline into cache: {}", error))]
705 CacheLoad {
706 error: std::sync::Arc<Error>,
707 #[snafu(implicit)]
708 location: Location,
709 },
710
711 #[snafu(display("Failed to collect record batch"))]
712 CollectRecords {
713 #[snafu(implicit)]
714 location: Location,
715 #[snafu(source)]
716 source: common_recordbatch::error::Error,
717 },
718
719 #[snafu(display("A valid table suffix template is required for tablesuffix section"))]
720 RequiredTableSuffixTemplate,
721
722 #[snafu(display("Invalid table suffix template, input: {}", input))]
723 InvalidTableSuffixTemplate {
724 input: String,
725 #[snafu(implicit)]
726 location: Location,
727 },
728
729 #[snafu(display("Failed to compile VRL, {}", msg))]
730 CompileVrl {
731 msg: String,
732 #[snafu(implicit)]
733 location: Location,
734 },
735
736 #[snafu(display("Failed to execute VRL, {}", msg))]
737 ExecuteVrl {
738 msg: String,
739 #[snafu(implicit)]
740 location: Location,
741 },
742 #[snafu(display("Invalid timestamp value: {}", input))]
743 InvalidTimestamp {
744 input: String,
745 #[snafu(implicit)]
746 location: Location,
747 },
748
749 #[snafu(display("Invalid epoch value '{}' for resolution '{}'", value, resolution))]
750 InvalidEpochForResolution {
751 value: i64,
752 resolution: String,
753 #[snafu(implicit)]
754 location: Location,
755 },
756 #[snafu(display("Please don't use regex in Vrl script"))]
757 VrlRegexValue {
758 #[snafu(implicit)]
759 location: Location,
760 },
761
762 #[snafu(display(
763 "Vrl script should return object or array in the end, got `{:?}`",
764 result_kind
765 ))]
766 VrlReturnValue {
767 result_kind: Kind,
768 #[snafu(implicit)]
769 location: Location,
770 },
771
772 #[snafu(display("Failed to cast type, msg: {}", msg))]
773 CastType {
774 msg: String,
775 #[snafu(implicit)]
776 location: Location,
777 },
778
779 #[snafu(display("Top level value must be map"))]
780 ValueMustBeMap {
781 #[snafu(implicit)]
782 location: Location,
783 },
784
785 #[snafu(display(
786 "Array element at index {index} must be an object for one-to-many transformation, got {actual_type}"
787 ))]
788 ArrayElementMustBeObject {
789 index: usize,
790 actual_type: String,
791 #[snafu(implicit)]
792 location: Location,
793 },
794
795 #[snafu(display("Failed to transform array element at index {index}: {source}"))]
796 TransformArrayElement {
797 index: usize,
798 #[snafu(source)]
799 source: Box<Error>,
800 #[snafu(implicit)]
801 location: Location,
802 },
803
804 #[snafu(display("Failed to build DataFusion logical plan"))]
805 BuildDfLogicalPlan {
806 #[snafu(source)]
807 error: datafusion_common::DataFusionError,
808 #[snafu(implicit)]
809 location: Location,
810 },
811
812 #[snafu(display("Failed to execute internal statement"))]
813 ExecuteInternalStatement {
814 #[snafu(source)]
815 source: query::error::Error,
816 #[snafu(implicit)]
817 location: Location,
818 },
819
820 #[snafu(display("Failed to create dataframe"))]
821 DataFrame {
822 #[snafu(source)]
823 source: query::error::Error,
824 #[snafu(implicit)]
825 location: Location,
826 },
827
828 #[snafu(display("General catalog error"))]
829 Catalog {
830 #[snafu(source)]
831 source: catalog::error::Error,
832 #[snafu(implicit)]
833 location: Location,
834 },
835
836 #[snafu(display("Failed to create table"))]
837 CreateTable {
838 #[snafu(source)]
839 source: operator::error::Error,
840 #[snafu(implicit)]
841 location: Location,
842 },
843
844 #[snafu(display("Invalid pipeline version format: {}", version))]
845 InvalidPipelineVersion {
846 version: String,
847 #[snafu(implicit)]
848 location: Location,
849 },
850
851 #[snafu(display("Invalid custom time index config: {}, reason: {}", config, reason))]
852 InvalidCustomTimeIndex {
853 config: String,
854 reason: String,
855 #[snafu(implicit)]
856 location: Location,
857 },
858
859 #[snafu(display("Pipeline is required for this API."))]
860 PipelineMissing {
861 #[snafu(implicit)]
862 location: Location,
863 },
864
865 #[snafu(display("Time index must be non null."))]
866 TimeIndexMustBeNonNull {
867 #[snafu(implicit)]
868 location: Location,
869 },
870
871 #[snafu(display("Float is NaN"))]
872 FloatIsNan {
873 #[snafu(source)]
874 error: ordered_float::FloatIsNan,
875 #[snafu(implicit)]
876 location: Location,
877 },
878
879 #[snafu(display("Unsupported type in pipeline: {}", ty))]
880 UnsupportedTypeInPipeline {
881 ty: String,
882 #[snafu(implicit)]
883 location: Location,
884 },
885
886 #[snafu(transparent)]
887 GreptimeProto {
888 source: api::error::Error,
889 #[snafu(implicit)]
890 location: Location,
891 },
892
893 #[snafu(transparent)]
894 Datatypes {
895 source: datatypes::error::Error,
896 #[snafu(implicit)]
897 location: Location,
898 },
899}
900
901pub type Result<T> = std::result::Result<T, Error>;
902
903impl ErrorExt for Error {
904 fn status_code(&self) -> StatusCode {
905 use Error::*;
906 match self {
907 CacheLoad { error, .. } => error.status_code(),
908 CastType { .. } => StatusCode::Unexpected,
909 PipelineTableNotFound { .. } => StatusCode::TableNotFound,
910 InsertPipeline { source, .. } => source.status_code(),
911 CollectRecords { source, .. } => source.status_code(),
912 PipelineNotFound { .. }
913 | InvalidPipelineVersion { .. }
914 | InvalidCustomTimeIndex { .. }
915 | TimeIndexMustBeNonNull { .. } => StatusCode::InvalidArguments,
916 MultiPipelineWithDiffSchema { .. }
917 | ValueMustBeMap { .. }
918 | ArrayElementMustBeObject { .. } => StatusCode::IllegalState,
919 TransformArrayElement { source, .. } => source.status_code(),
920 BuildDfLogicalPlan { .. } | RecordBatchLenNotMatch { .. } => StatusCode::Internal,
921 ExecuteInternalStatement { source, .. } => source.status_code(),
922 DataFrame { source, .. } => source.status_code(),
923 Catalog { source, .. } => source.status_code(),
924 CreateTable { source, .. } => source.status_code(),
925
926 EmptyInputField { .. }
927 | MissingInputField { .. }
928 | InvalidFieldRename { .. }
929 | ProcessorMustBeMap { .. }
930 | ProcessorMissingField { .. }
931 | ProcessorExpectString { .. }
932 | ProcessorUnsupportedValue { .. }
933 | ProcessorKeyMustBeString { .. }
934 | ProcessorFailedToParseString { .. }
935 | ProcessorMustHaveStringKey { .. }
936 | UnsupportedProcessor { .. }
937 | FieldMustBeType { .. }
938 | FailedParseFieldFromString { .. }
939 | FailedToParseIntKey { .. }
940 | FailedToParseInt { .. }
941 | FailedToParseFloatKey { .. }
942 | IntermediateKeyIndex { .. }
943 | CmcdMissingValue { .. }
944 | CmcdMissingKey { .. }
945 | KeyMustBeString { .. }
946 | CsvRead { .. }
947 | CsvNoRecord { .. }
948 | CsvSeparatorName { .. }
949 | CsvQuoteName { .. }
950 | DateParseTimezone { .. }
951 | DateParse { .. }
952 | DateFailedToGetLocalTimezone { .. }
953 | DissectInvalidPattern { .. }
954 | DissectEmptyPattern { .. }
955 | DissectSplitExceedsInput { .. }
956 | DissectSplitNotMatchInput { .. }
957 | DissectConsecutiveNames { .. }
958 | DissectNoMatchingPattern { .. }
959 | DissectModifierAlreadySet { .. }
960 | DissectAppendOrderAlreadySet { .. }
961 | DissectOrderOnlyAppend { .. }
962 | DissectOrderOnlyAppendModifier { .. }
963 | DissectEndModifierAlreadySet { .. }
964 | EpochInvalidResolution { .. }
965 | GsubPatternRequired { .. }
966 | GsubReplacementRequired { .. }
967 | Regex { .. }
968 | JoinSeparatorRequired { .. }
969 | LetterInvalidMethod { .. }
970 | RegexNamedGroupNotFound { .. }
971 | RegexNoValidField { .. }
972 | RegexNoValidPattern { .. }
973 | UrlEncodingInvalidMethod { .. }
974 | DigestPatternInvalid { .. }
975 | TransformOnFailureInvalidValue { .. }
976 | TransformElementMustBeMap { .. }
977 | TransformFieldMustBeSet { .. }
978 | TransformTypeMustBeSet { .. }
979 | InvalidJson2TypeHint { .. }
980 | ParseJson2TypeHintPath { .. }
981 | TransformIndexTypeMustBeSet { .. }
982 | TransformIndexUnsupportedField { .. }
983 | TransformIndexOptionMustBeScalar { .. }
984 | TransformIndexOptionsUnsupported { .. }
985 | TransformIndexOptionUnsupported { .. }
986 | TransformIndexTypeMismatch { .. }
987 | TransformIndexOption { .. }
988 | TransformIndexStateMismatch { .. }
989 | TransformColumnNameMustBeUnique { .. }
990 | TransformMultipleTimestampIndex { .. }
991 | TransformTimestampIndexCount { .. }
992 | AutoTransformOneTimestamp { .. }
993 | InvalidVersionNumber { .. }
994 | CoerceUnsupportedEpochType { .. }
995 | CoerceStringToType { .. }
996 | CoerceJsonTypeTo { .. }
997 | CoerceTypeToJson { .. }
998 | CoerceIncompatibleTypes { .. }
999 | ValueInvalidResolution { .. }
1000 | ValueParseType { .. }
1001 | ValueParseInt { .. }
1002 | ValueParseFloat { .. }
1003 | ValueParseBoolean { .. }
1004 | ValueDefaultValueUnsupported { .. }
1005 | ValueUnsupportedYamlType { .. }
1006 | ValueYamlKeyMustBeString { .. }
1007 | YamlLoad { .. }
1008 | YamlParse { .. }
1009 | ColumnOptions { .. }
1010 | UnsupportedIndexType { .. }
1011 | IdentifyPipelineColumnTypeMismatch { .. }
1012 | JsonParse { .. }
1013 | JsonPathParse { .. }
1014 | JsonPathParseResultIndex { .. }
1015 | FieldRequiredForDispatcher
1016 | TableSuffixRequiredForDispatcherRule
1017 | ValueRequiredForDispatcherRule
1018 | RequiredTableSuffixTemplate
1019 | InvalidTableSuffixTemplate { .. }
1020 | CompileVrl { .. }
1021 | ExecuteVrl { .. }
1022 | InvalidTimestamp { .. }
1023 | VrlRegexValue { .. }
1024 | VrlReturnValue { .. }
1025 | PipelineMissing { .. } => StatusCode::InvalidArguments,
1026
1027 FloatIsNan { .. }
1028 | InvalidEpochForResolution { .. }
1029 | UnsupportedTypeInPipeline { .. } => StatusCode::InvalidArguments,
1030
1031 GreptimeProto { source, .. } => source.status_code(),
1032 Datatypes { source, .. } => source.status_code(),
1033 }
1034 }
1035
1036 fn as_any(&self) -> &dyn Any {
1037 self
1038 }
1039}