1use std::any::Any;
16
17use common_datasource::file_format::Format;
18use common_error::define_into_tonic_status;
19use common_error::ext::{BoxedError, ErrorExt};
20use common_error::status_code::StatusCode;
21use common_macro::stack_trace_debug;
22use datafusion::parquet;
23use datatypes::arrow::error::ArrowError;
24use snafu::{Location, Snafu};
25use table::metadata::TableType;
26
27#[derive(Snafu)]
28#[snafu(visibility(pub))]
29#[stack_trace_debug]
30pub enum Error {
31 #[snafu(display("Table already exists: `{}`", table))]
32 TableAlreadyExists {
33 table: String,
34 #[snafu(implicit)]
35 location: Location,
36 },
37
38 #[snafu(display("View already exists: `{name}`"))]
39 ViewAlreadyExists {
40 name: String,
41 #[snafu(implicit)]
42 location: Location,
43 },
44
45 #[snafu(display("Failed to execute admin function"))]
46 ExecuteAdminFunction {
47 #[snafu(implicit)]
48 location: Location,
49 source: common_query::error::Error,
50 },
51
52 #[snafu(display("Failed to build admin function args: {msg}"))]
53 BuildAdminFunctionArgs { msg: String },
54
55 #[snafu(display("Expected {expected} args, but actual {actual}"))]
56 FunctionArityMismatch { expected: usize, actual: usize },
57
58 #[snafu(display("Failed to invalidate table cache"))]
59 InvalidateTableCache {
60 #[snafu(implicit)]
61 location: Location,
62 source: common_meta::error::Error,
63 },
64
65 #[snafu(display("Failed to execute ddl"))]
66 ExecuteDdl {
67 #[snafu(implicit)]
68 location: Location,
69 source: common_meta::error::Error,
70 },
71
72 #[snafu(display("Unexpected, violated: {}", violated))]
73 Unexpected {
74 violated: String,
75 #[snafu(implicit)]
76 location: Location,
77 },
78
79 #[snafu(display("external error"))]
80 External {
81 #[snafu(implicit)]
82 location: Location,
83 source: BoxedError,
84 },
85
86 #[snafu(display("Failed to insert data"))]
87 RequestInserts {
88 #[snafu(implicit)]
89 location: Location,
90 source: common_meta::error::Error,
91 },
92
93 #[snafu(display("Failed to delete data"))]
94 RequestDeletes {
95 #[snafu(implicit)]
96 location: Location,
97 source: common_meta::error::Error,
98 },
99
100 #[snafu(display("Failed to send request to region"))]
101 RequestRegion {
102 #[snafu(implicit)]
103 location: Location,
104 source: common_meta::error::Error,
105 },
106
107 #[snafu(display("Unsupported region request"))]
108 UnsupportedRegionRequest {
109 #[snafu(implicit)]
110 location: Location,
111 },
112
113 #[snafu(display("Failed to parse SQL"))]
114 ParseSql {
115 #[snafu(implicit)]
116 location: Location,
117 source: sql::error::Error,
118 },
119
120 #[snafu(display("Failed to convert identifier: {}", ident))]
121 ConvertIdentifier {
122 ident: String,
123 #[snafu(implicit)]
124 location: Location,
125 #[snafu(source)]
126 error: datafusion::error::DataFusionError,
127 },
128
129 #[snafu(display("Failed to extract table names"))]
130 ExtractTableNames {
131 #[snafu(implicit)]
132 location: Location,
133 source: query::error::Error,
134 },
135
136 #[snafu(display("Column datatype error"))]
137 ColumnDataType {
138 #[snafu(implicit)]
139 location: Location,
140 source: api::error::Error,
141 },
142
143 #[snafu(display("Invalid column proto definition, column: {}", column))]
144 InvalidColumnDef {
145 column: String,
146 #[snafu(implicit)]
147 location: Location,
148 source: api::error::Error,
149 },
150
151 #[snafu(display("Invalid statement to create view"))]
152 InvalidViewStmt {
153 #[snafu(implicit)]
154 location: Location,
155 },
156
157 #[snafu(display("Expect {expected} columns for view {view_name}, but found {actual}"))]
158 ViewColumnsMismatch {
159 view_name: String,
160 expected: usize,
161 actual: usize,
162 },
163
164 #[snafu(display("Invalid view \"{view_name}\": {msg}"))]
165 InvalidView {
166 msg: String,
167 view_name: String,
168 #[snafu(implicit)]
169 location: Location,
170 },
171
172 #[snafu(display("Failed to convert column default constraint, column: {}", column_name))]
173 ConvertColumnDefaultConstraint {
174 column_name: String,
175 #[snafu(implicit)]
176 location: Location,
177 source: datatypes::error::Error,
178 },
179
180 #[snafu(display("Failed to convert datafusion schema"))]
181 ConvertSchema {
182 source: datatypes::error::Error,
183 #[snafu(implicit)]
184 location: Location,
185 },
186
187 #[snafu(display("Failed to convert expr to struct"))]
188 InvalidExpr {
189 #[snafu(implicit)]
190 location: Location,
191 source: common_meta::error::Error,
192 },
193
194 #[snafu(display("Invalid partition"))]
195 InvalidPartition {
196 #[snafu(implicit)]
197 location: Location,
198 source: partition::error::Error,
199 },
200
201 #[snafu(display("Invalid SQL, error: {}", err_msg))]
202 InvalidSql {
203 err_msg: String,
204 #[snafu(implicit)]
205 location: Location,
206 },
207
208 #[snafu(display("Invalid InsertRequest, reason: {}", reason))]
209 InvalidInsertRequest {
210 reason: String,
211 #[snafu(implicit)]
212 location: Location,
213 },
214
215 #[snafu(display("Invalid DeleteRequest, reason: {}", reason))]
216 InvalidDeleteRequest {
217 reason: String,
218 #[snafu(implicit)]
219 location: Location,
220 },
221
222 #[snafu(display("Table not found: {}", table_name))]
223 TableNotFound { table_name: String },
224
225 #[snafu(display("Admin function not found: {}", name))]
226 AdminFunctionNotFound { name: String },
227
228 #[snafu(display("Flow not found: {}", flow_name))]
229 FlowNotFound { flow_name: String },
230
231 #[snafu(display("Failed to join task"))]
232 JoinTask {
233 #[snafu(source)]
234 error: common_runtime::JoinError,
235 #[snafu(implicit)]
236 location: Location,
237 },
238
239 #[snafu(display("General catalog error"))]
240 Catalog {
241 #[snafu(implicit)]
242 location: Location,
243 source: catalog::error::Error,
244 },
245
246 #[snafu(display("Failed to find view info for: {}", view_name))]
247 FindViewInfo {
248 view_name: String,
249 #[snafu(implicit)]
250 location: Location,
251 source: common_meta::error::Error,
252 },
253
254 #[snafu(display("View info not found: {}", view_name))]
255 ViewInfoNotFound {
256 view_name: String,
257 #[snafu(implicit)]
258 location: Location,
259 },
260
261 #[snafu(display("View not found: {}", view_name))]
262 ViewNotFound {
263 view_name: String,
264 #[snafu(implicit)]
265 location: Location,
266 },
267
268 #[snafu(display("Failed to find table partition rule for table {}", table_name))]
269 FindTablePartitionRule {
270 table_name: String,
271 #[snafu(implicit)]
272 location: Location,
273 source: partition::error::Error,
274 },
275
276 #[snafu(display("Failed to split insert request"))]
277 SplitInsert {
278 source: partition::error::Error,
279 #[snafu(implicit)]
280 location: Location,
281 },
282
283 #[snafu(display("Failed to split delete request"))]
284 SplitDelete {
285 source: partition::error::Error,
286 #[snafu(implicit)]
287 location: Location,
288 },
289
290 #[snafu(display("Failed to find leader for region"))]
291 FindRegionLeader {
292 source: partition::error::Error,
293 #[snafu(implicit)]
294 location: Location,
295 },
296
297 #[snafu(display("Failed to create table info"))]
298 CreateTableInfo {
299 #[snafu(implicit)]
300 location: Location,
301 source: datatypes::error::Error,
302 },
303
304 #[snafu(display("Failed to build CreateExpr on insertion"))]
305 BuildCreateExprOnInsertion {
306 #[snafu(implicit)]
307 location: Location,
308 source: common_grpc_expr::error::Error,
309 },
310
311 #[snafu(display("Failed to find schema, schema info: {}", schema_info))]
312 SchemaNotFound {
313 schema_info: String,
314 #[snafu(implicit)]
315 location: Location,
316 },
317
318 #[snafu(display("Schema {} already exists", name))]
319 SchemaExists {
320 name: String,
321 #[snafu(implicit)]
322 location: Location,
323 },
324
325 #[snafu(display("Schema `{name}` is in use"))]
326 SchemaInUse {
327 name: String,
328 #[snafu(implicit)]
329 location: Location,
330 },
331
332 #[snafu(display("Schema `{name}` is read-only"))]
333 SchemaReadOnly {
334 name: String,
335 #[snafu(implicit)]
336 location: Location,
337 },
338
339 #[snafu(display("Table occurs error"))]
340 Table {
341 #[snafu(implicit)]
342 location: Location,
343 source: table::error::Error,
344 },
345
346 #[snafu(display("Cannot find column by name: {}", msg))]
347 ColumnNotFound {
348 msg: String,
349 #[snafu(implicit)]
350 location: Location,
351 },
352
353 #[snafu(display("Failed to execute statement"))]
354 ExecuteStatement {
355 #[snafu(implicit)]
356 location: Location,
357 source: query::error::Error,
358 },
359
360 #[snafu(display("Failed to plan statement"))]
361 PlanStatement {
362 #[snafu(implicit)]
363 location: Location,
364 source: query::error::Error,
365 },
366
367 #[snafu(display("Failed to parse query"))]
368 ParseQuery {
369 #[snafu(implicit)]
370 location: Location,
371 source: query::error::Error,
372 },
373
374 #[snafu(display("Failed to execute logical plan"))]
375 ExecLogicalPlan {
376 #[snafu(implicit)]
377 location: Location,
378 source: query::error::Error,
379 },
380
381 #[snafu(display("Failed to build DataFusion logical plan"))]
382 BuildDfLogicalPlan {
383 #[snafu(source)]
384 error: datafusion_common::DataFusionError,
385 #[snafu(implicit)]
386 location: Location,
387 },
388
389 #[snafu(display("Failed to convert AlterExpr to AlterRequest"))]
390 AlterExprToRequest {
391 #[snafu(implicit)]
392 location: Location,
393 source: common_grpc_expr::error::Error,
394 },
395
396 #[snafu(display("Failed to build table meta for table: {}", table_name))]
397 BuildTableMeta {
398 table_name: String,
399 #[snafu(source)]
400 error: table::metadata::TableMetaBuilderError,
401 #[snafu(implicit)]
402 location: Location,
403 },
404
405 #[snafu(display("Not supported: {}", feat))]
406 NotSupported { feat: String },
407
408 #[snafu(display("Failed to find new columns on insertion"))]
409 FindNewColumnsOnInsertion {
410 #[snafu(implicit)]
411 location: Location,
412 source: common_grpc_expr::error::Error,
413 },
414
415 #[snafu(display("Failed to convert into vectors"))]
416 IntoVectors {
417 #[snafu(implicit)]
418 location: Location,
419 source: datatypes::error::Error,
420 },
421
422 #[snafu(display("Failed to describe schema for given statement"))]
423 DescribeStatement {
424 #[snafu(implicit)]
425 location: Location,
426 source: query::error::Error,
427 },
428
429 #[snafu(display("Illegal primary keys definition: {}", msg))]
430 IllegalPrimaryKeysDef {
431 msg: String,
432 #[snafu(implicit)]
433 location: Location,
434 },
435
436 #[snafu(display("Unrecognized table option"))]
437 UnrecognizedTableOption {
438 #[snafu(implicit)]
439 location: Location,
440 source: table::error::Error,
441 },
442
443 #[snafu(display("Missing time index column"))]
444 MissingTimeIndexColumn {
445 #[snafu(implicit)]
446 location: Location,
447 source: table::error::Error,
448 },
449
450 #[snafu(display("Failed to build regex"))]
451 BuildRegex {
452 #[snafu(implicit)]
453 location: Location,
454 #[snafu(source)]
455 error: regex::Error,
456 },
457
458 #[snafu(display("Failed to insert value into table: {}", table_name))]
459 Insert {
460 table_name: String,
461 #[snafu(implicit)]
462 location: Location,
463 source: table::error::Error,
464 },
465
466 #[snafu(display("Failed to parse data source url"))]
467 ParseUrl {
468 #[snafu(implicit)]
469 location: Location,
470 source: common_datasource::error::Error,
471 },
472
473 #[snafu(display("Unsupported format: {:?}", format))]
474 UnsupportedFormat {
475 #[snafu(implicit)]
476 location: Location,
477 format: Format,
478 },
479
480 #[snafu(display("Failed to parse file format"))]
481 ParseFileFormat {
482 #[snafu(implicit)]
483 location: Location,
484 source: common_datasource::error::Error,
485 },
486
487 #[snafu(display("Failed to build data source backend"))]
488 BuildBackend {
489 #[snafu(implicit)]
490 location: Location,
491 source: common_datasource::error::Error,
492 },
493
494 #[snafu(display("Failed to list objects"))]
495 ListObjects {
496 #[snafu(implicit)]
497 location: Location,
498 source: common_datasource::error::Error,
499 },
500
501 #[snafu(display("Failed to infer schema from path: {}", path))]
502 InferSchema {
503 path: String,
504 #[snafu(implicit)]
505 location: Location,
506 source: common_datasource::error::Error,
507 },
508
509 #[snafu(display("Failed to write stream to path: {}", path))]
510 WriteStreamToFile {
511 path: String,
512 #[snafu(implicit)]
513 location: Location,
514 source: common_datasource::error::Error,
515 },
516
517 #[snafu(display("Failed to read object in path: {}", path))]
518 ReadObject {
519 path: String,
520 #[snafu(implicit)]
521 location: Location,
522 #[snafu(source)]
523 error: object_store::Error,
524 },
525
526 #[snafu(display("Failed to read record batch"))]
527 ReadDfRecordBatch {
528 #[snafu(source)]
529 error: datafusion::error::DataFusionError,
530 #[snafu(implicit)]
531 location: Location,
532 },
533
534 #[snafu(display("Failed to read parquet file metadata"))]
535 ReadParquetMetadata {
536 #[snafu(source)]
537 error: parquet::errors::ParquetError,
538 #[snafu(implicit)]
539 location: Location,
540 },
541
542 #[snafu(display("Failed to build record batch"))]
543 BuildRecordBatch {
544 #[snafu(implicit)]
545 location: Location,
546 source: common_recordbatch::error::Error,
547 },
548
549 #[snafu(display("Failed to read orc schema"))]
550 ReadOrc {
551 source: common_datasource::error::Error,
552 #[snafu(implicit)]
553 location: Location,
554 },
555
556 #[snafu(display("Failed to build parquet record batch stream"))]
557 BuildParquetRecordBatchStream {
558 #[snafu(implicit)]
559 location: Location,
560 #[snafu(source)]
561 error: parquet::errors::ParquetError,
562 },
563
564 #[snafu(display("Failed to build file stream"))]
565 BuildFileStream {
566 #[snafu(implicit)]
567 location: Location,
568 #[snafu(source)]
569 error: datafusion::error::DataFusionError,
570 },
571
572 #[snafu(display(
573 "Schema datatypes not match at index {}, expected table schema: {}, actual file schema: {}",
574 index,
575 table_schema,
576 file_schema
577 ))]
578 InvalidSchema {
579 index: usize,
580 table_schema: String,
581 file_schema: String,
582 #[snafu(implicit)]
583 location: Location,
584 },
585
586 #[snafu(display("Failed to project schema"))]
587 ProjectSchema {
588 #[snafu(source)]
589 error: ArrowError,
590 #[snafu(implicit)]
591 location: Location,
592 },
593
594 #[snafu(display("Failed to encode object into json"))]
595 EncodeJson {
596 #[snafu(source)]
597 error: serde_json::error::Error,
598 #[snafu(implicit)]
599 location: Location,
600 },
601
602 #[snafu(display("Invalid COPY parameter, key: {}, value: {}", key, value))]
603 InvalidCopyParameter {
604 key: String,
605 value: String,
606 #[snafu(implicit)]
607 location: Location,
608 },
609
610 #[snafu(display("Invalid COPY DATABASE location, must end with '/': {}", value))]
611 InvalidCopyDatabasePath {
612 value: String,
613 #[snafu(implicit)]
614 location: Location,
615 },
616
617 #[snafu(display("Table metadata manager error"))]
618 TableMetadataManager {
619 source: common_meta::error::Error,
620 #[snafu(implicit)]
621 location: Location,
622 },
623
624 #[snafu(display("Missing insert body"))]
625 MissingInsertBody {
626 source: sql::error::Error,
627 #[snafu(implicit)]
628 location: Location,
629 },
630
631 #[snafu(display("Failed to parse sql value"))]
632 ParseSqlValue {
633 source: sql::error::Error,
634 #[snafu(implicit)]
635 location: Location,
636 },
637
638 #[snafu(display("Failed to build default value, column: {}", column))]
639 ColumnDefaultValue {
640 column: String,
641 #[snafu(implicit)]
642 location: Location,
643 source: datatypes::error::Error,
644 },
645
646 #[snafu(display(
647 "No valid default value can be built automatically, column: {}",
648 column,
649 ))]
650 ColumnNoneDefaultValue {
651 column: String,
652 #[snafu(implicit)]
653 location: Location,
654 },
655
656 #[snafu(display("Failed to prepare file table"))]
657 PrepareFileTable {
658 #[snafu(implicit)]
659 location: Location,
660 source: query::error::Error,
661 },
662
663 #[snafu(display("Failed to infer file table schema"))]
664 InferFileTableSchema {
665 #[snafu(implicit)]
666 location: Location,
667 source: query::error::Error,
668 },
669
670 #[snafu(display("The schema of the file table is incompatible with the table schema"))]
671 SchemaIncompatible {
672 #[snafu(implicit)]
673 location: Location,
674 source: query::error::Error,
675 },
676
677 #[snafu(display("Invalid table name: {}", table_name))]
678 InvalidTableName {
679 table_name: String,
680 #[snafu(implicit)]
681 location: Location,
682 },
683
684 #[snafu(display("Invalid view name: {name}"))]
685 InvalidViewName {
686 name: String,
687 #[snafu(implicit)]
688 location: Location,
689 },
690
691 #[snafu(display("Invalid flow name: {name}"))]
692 InvalidFlowName {
693 name: String,
694 #[snafu(implicit)]
695 location: Location,
696 },
697
698 #[cfg(feature = "enterprise")]
699 #[snafu(display("Invalid trigger name: {name}"))]
700 InvalidTriggerName {
701 name: String,
702 #[snafu(implicit)]
703 location: Location,
704 },
705
706 #[snafu(display("Empty {} expr", name))]
707 EmptyDdlExpr {
708 name: String,
709 #[snafu(implicit)]
710 location: Location,
711 },
712
713 #[snafu(display("Failed to create logical tables: {}", reason))]
714 CreateLogicalTables {
715 reason: String,
716 #[snafu(implicit)]
717 location: Location,
718 },
719
720 #[snafu(display("Invalid partition rule: {}", reason))]
721 InvalidPartitionRule {
722 reason: String,
723 #[snafu(implicit)]
724 location: Location,
725 },
726
727 #[snafu(display("Invalid configuration value."))]
728 InvalidConfigValue {
729 source: session::session_config::Error,
730 #[snafu(implicit)]
731 location: Location,
732 },
733
734 #[snafu(display("Invalid timestamp range, start: `{}`, end: `{}`", start, end))]
735 InvalidTimestampRange {
736 start: String,
737 end: String,
738 #[snafu(implicit)]
739 location: Location,
740 },
741
742 #[snafu(display("Failed to convert between logical plan and substrait plan"))]
743 SubstraitCodec {
744 #[snafu(implicit)]
745 location: Location,
746 source: substrait::error::Error,
747 },
748
749 #[snafu(display(
750 "Show create table only for base table. {} is {}",
751 table_name,
752 table_type
753 ))]
754 ShowCreateTableBaseOnly {
755 table_name: String,
756 table_type: TableType,
757 #[snafu(implicit)]
758 location: Location,
759 },
760 #[snafu(display("Create physical expr error"))]
761 PhysicalExpr {
762 #[snafu(source)]
763 error: common_recordbatch::error::Error,
764 #[snafu(implicit)]
765 location: Location,
766 },
767
768 #[snafu(display("Failed to upgrade catalog manager reference"))]
769 UpgradeCatalogManagerRef {
770 #[snafu(implicit)]
771 location: Location,
772 },
773
774 #[snafu(display("Invalid json text: {}", json))]
775 InvalidJsonFormat {
776 #[snafu(implicit)]
777 location: Location,
778 json: String,
779 },
780
781 #[snafu(display("Cursor {name} is not found"))]
782 CursorNotFound { name: String },
783
784 #[snafu(display("A cursor named {name} already exists"))]
785 CursorExists { name: String },
786
787 #[snafu(display("Column options error"))]
788 ColumnOptions {
789 #[snafu(source)]
790 source: api::error::Error,
791 #[snafu(implicit)]
792 location: Location,
793 },
794
795 #[snafu(display("Failed to create partition rules"))]
796 CreatePartitionRules {
797 #[snafu(source)]
798 source: sql::error::Error,
799 #[snafu(implicit)]
800 location: Location,
801 },
802
803 #[snafu(display("Failed to decode arrow flight data"))]
804 DecodeFlightData {
805 source: common_grpc::error::Error,
806 #[snafu(implicit)]
807 location: Location,
808 },
809
810 #[snafu(display("Failed to perform arrow compute"))]
811 ComputeArrow {
812 #[snafu(source)]
813 error: ArrowError,
814 #[snafu(implicit)]
815 location: Location,
816 },
817
818 #[snafu(display("Path not found: {path}"))]
819 PathNotFound {
820 path: String,
821 #[snafu(implicit)]
822 location: Location,
823 },
824
825 #[snafu(display("Invalid time index type: {}", ty))]
826 InvalidTimeIndexType {
827 ty: arrow::datatypes::DataType,
828 #[snafu(implicit)]
829 location: Location,
830 },
831
832 #[snafu(display("Invalid process id: {}", id))]
833 InvalidProcessId { id: String },
834
835 #[snafu(display("ProcessManager is not present, this can be caused by misconfiguration."))]
836 ProcessManagerMissing {
837 #[snafu(implicit)]
838 location: Location,
839 },
840
841 #[snafu(display("Sql common error"))]
842 SqlCommon {
843 source: common_sql::error::Error,
844 #[snafu(implicit)]
845 location: Location,
846 },
847
848 #[snafu(display("Failed to convert partition expression to protobuf"))]
849 PartitionExprToPb {
850 source: partition::error::Error,
851 #[snafu(implicit)]
852 location: Location,
853 },
854}
855
856pub type Result<T> = std::result::Result<T, Error>;
857
858impl ErrorExt for Error {
859 fn status_code(&self) -> StatusCode {
860 match self {
861 Error::InvalidSql { .. }
862 | Error::InvalidConfigValue { .. }
863 | Error::InvalidInsertRequest { .. }
864 | Error::InvalidDeleteRequest { .. }
865 | Error::IllegalPrimaryKeysDef { .. }
866 | Error::SchemaNotFound { .. }
867 | Error::SchemaExists { .. }
868 | Error::SchemaInUse { .. }
869 | Error::ColumnNotFound { .. }
870 | Error::BuildRegex { .. }
871 | Error::InvalidSchema { .. }
872 | Error::ProjectSchema { .. }
873 | Error::UnsupportedFormat { .. }
874 | Error::ColumnNoneDefaultValue { .. }
875 | Error::PrepareFileTable { .. }
876 | Error::InferFileTableSchema { .. }
877 | Error::SchemaIncompatible { .. }
878 | Error::ConvertSchema { .. }
879 | Error::UnsupportedRegionRequest { .. }
880 | Error::InvalidTableName { .. }
881 | Error::InvalidViewName { .. }
882 | Error::InvalidFlowName { .. }
883 | Error::InvalidView { .. }
884 | Error::InvalidExpr { .. }
885 | Error::AdminFunctionNotFound { .. }
886 | Error::ViewColumnsMismatch { .. }
887 | Error::InvalidViewStmt { .. }
888 | Error::ConvertIdentifier { .. }
889 | Error::BuildAdminFunctionArgs { .. }
890 | Error::FunctionArityMismatch { .. }
891 | Error::InvalidPartition { .. }
892 | Error::PhysicalExpr { .. }
893 | Error::InvalidJsonFormat { .. }
894 | Error::PartitionExprToPb { .. }
895 | Error::CursorNotFound { .. }
896 | Error::CursorExists { .. }
897 | Error::CreatePartitionRules { .. } => StatusCode::InvalidArguments,
898 #[cfg(feature = "enterprise")]
899 Error::InvalidTriggerName { .. } => StatusCode::InvalidArguments,
900 Error::TableAlreadyExists { .. } | Error::ViewAlreadyExists { .. } => {
901 StatusCode::TableAlreadyExists
902 }
903 Error::NotSupported { .. }
904 | Error::ShowCreateTableBaseOnly { .. }
905 | Error::SchemaReadOnly { .. } => StatusCode::Unsupported,
906 Error::TableMetadataManager { source, .. } => source.status_code(),
907 Error::ParseSql { source, .. } => source.status_code(),
908 Error::InvalidateTableCache { source, .. } => source.status_code(),
909 Error::ParseFileFormat { source, .. } | Error::InferSchema { source, .. } => {
910 source.status_code()
911 }
912 Error::Table { source, .. } | Error::Insert { source, .. } => source.status_code(),
913 Error::ConvertColumnDefaultConstraint { source, .. }
914 | Error::CreateTableInfo { source, .. }
915 | Error::IntoVectors { source, .. } => source.status_code(),
916 Error::RequestInserts { source, .. } | Error::FindViewInfo { source, .. } => {
917 source.status_code()
918 }
919 Error::RequestRegion { source, .. } => source.status_code(),
920 Error::RequestDeletes { source, .. } => source.status_code(),
921 Error::SubstraitCodec { source, .. } => source.status_code(),
922 Error::ColumnDataType { source, .. } | Error::InvalidColumnDef { source, .. } => {
923 source.status_code()
924 }
925 Error::MissingTimeIndexColumn { source, .. } => source.status_code(),
926 Error::BuildDfLogicalPlan { .. }
927 | Error::BuildTableMeta { .. }
928 | Error::MissingInsertBody { .. } => StatusCode::Internal,
929 Error::EncodeJson { .. } => StatusCode::Unexpected,
930 Error::ViewNotFound { .. }
931 | Error::ViewInfoNotFound { .. }
932 | Error::TableNotFound { .. } => StatusCode::TableNotFound,
933 Error::FlowNotFound { .. } => StatusCode::FlowNotFound,
934 Error::JoinTask { .. } => StatusCode::Internal,
935 Error::BuildParquetRecordBatchStream { .. }
936 | Error::BuildFileStream { .. }
937 | Error::WriteStreamToFile { .. }
938 | Error::ReadDfRecordBatch { .. }
939 | Error::Unexpected { .. } => StatusCode::Unexpected,
940 Error::Catalog { source, .. } => source.status_code(),
941 Error::BuildCreateExprOnInsertion { source, .. }
942 | Error::FindNewColumnsOnInsertion { source, .. } => source.status_code(),
943 Error::ExecuteStatement { source, .. }
944 | Error::ExtractTableNames { source, .. }
945 | Error::PlanStatement { source, .. }
946 | Error::ParseQuery { source, .. }
947 | Error::ExecLogicalPlan { source, .. }
948 | Error::DescribeStatement { source, .. } => source.status_code(),
949 Error::AlterExprToRequest { source, .. } => source.status_code(),
950 Error::External { source, .. } => source.status_code(),
951 Error::FindTablePartitionRule { source, .. }
952 | Error::SplitInsert { source, .. }
953 | Error::SplitDelete { source, .. }
954 | Error::FindRegionLeader { source, .. } => source.status_code(),
955 Error::UnrecognizedTableOption { .. } => StatusCode::InvalidArguments,
956 Error::ReadObject { .. }
957 | Error::ReadParquetMetadata { .. }
958 | Error::ReadOrc { .. } => StatusCode::StorageUnavailable,
959 Error::ListObjects { source, .. }
960 | Error::ParseUrl { source, .. }
961 | Error::BuildBackend { source, .. } => source.status_code(),
962 Error::ExecuteDdl { source, .. } => source.status_code(),
963 Error::InvalidCopyParameter { .. } | Error::InvalidCopyDatabasePath { .. } => {
964 StatusCode::InvalidArguments
965 }
966 Error::ColumnDefaultValue { source, .. } => source.status_code(),
967 Error::EmptyDdlExpr { .. }
968 | Error::InvalidPartitionRule { .. }
969 | Error::ParseSqlValue { .. }
970 | Error::InvalidTimestampRange { .. } => StatusCode::InvalidArguments,
971 Error::CreateLogicalTables { .. } => StatusCode::Unexpected,
972 Error::ExecuteAdminFunction { source, .. } => source.status_code(),
973 Error::BuildRecordBatch { source, .. } => source.status_code(),
974 Error::UpgradeCatalogManagerRef { .. } => StatusCode::Internal,
975 Error::ColumnOptions { source, .. } => source.status_code(),
976 Error::DecodeFlightData { source, .. } => source.status_code(),
977 Error::ComputeArrow { .. } => StatusCode::Internal,
978 Error::InvalidTimeIndexType { .. } => StatusCode::InvalidArguments,
979 Error::InvalidProcessId { .. } => StatusCode::InvalidArguments,
980 Error::ProcessManagerMissing { .. } => StatusCode::Unexpected,
981 Error::PathNotFound { .. } => StatusCode::InvalidArguments,
982 Error::SqlCommon { source, .. } => source.status_code(),
983 }
984 }
985
986 fn as_any(&self) -> &dyn Any {
987 self
988 }
989}
990
991define_into_tonic_status!(Error);