mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-05-30 03:40:37 +00:00
feat: impl select (grpc) (#138)
* SelectExpr: change to oneof expr * Convert between Vec<u8> and SelectResult * Chore: use encode_to_vec and decode, instead of encode_length_delimited_to_vec and decode_length_delimited * Chore: move bitset into separate file * Grpc select impl
This commit is contained in:
@@ -4,48 +4,56 @@ use std::fmt;
|
||||
#[derive(Debug, Clone, Copy, PartialEq)]
|
||||
pub enum StatusCode {
|
||||
// ====== Begin of common status code ==============
|
||||
/// Success.
|
||||
Success = 0,
|
||||
/// Unknown error.
|
||||
Unknown,
|
||||
Unknown = 1,
|
||||
/// Unsupported operation.
|
||||
Unsupported,
|
||||
Unsupported = 2,
|
||||
/// Unexpected error, maybe there is a BUG.
|
||||
Unexpected,
|
||||
Unexpected = 3,
|
||||
/// Internal server error.
|
||||
Internal,
|
||||
Internal = 4,
|
||||
/// Invalid arguments.
|
||||
InvalidArguments,
|
||||
InvalidArguments = 5,
|
||||
// ====== End of common status code ================
|
||||
|
||||
// ====== Begin of SQL related status code =========
|
||||
/// SQL Syntax error.
|
||||
InvalidSyntax,
|
||||
InvalidSyntax = 6,
|
||||
// ====== End of SQL related status code ===========
|
||||
|
||||
// ====== Begin of query related status code =======
|
||||
/// Fail to create a plan for the query.
|
||||
PlanQuery,
|
||||
PlanQuery = 7,
|
||||
/// The query engine fail to execute query.
|
||||
EngineExecuteQuery,
|
||||
EngineExecuteQuery = 8,
|
||||
// ====== End of query related status code =========
|
||||
|
||||
// ====== Begin of catalog related status code =====
|
||||
/// Table already exists.
|
||||
TableAlreadyExists,
|
||||
TableNotFound,
|
||||
TableColumnNotFound,
|
||||
TableAlreadyExists = 9,
|
||||
TableNotFound = 10,
|
||||
TableColumnNotFound = 11,
|
||||
// ====== End of catalog related status code =======
|
||||
|
||||
// ====== Begin of storage related status code =====
|
||||
/// Storage is temporarily unable to handle the request
|
||||
StorageUnavailable,
|
||||
StorageUnavailable = 12,
|
||||
// ====== End of storage related status code =======
|
||||
|
||||
// ====== Begin of server related status code =====
|
||||
/// Runtime resources exhausted, like creating threads failed.
|
||||
RuntimeResourcesExhausted,
|
||||
RuntimeResourcesExhausted = 13,
|
||||
// ====== End of server related status code =======
|
||||
}
|
||||
|
||||
impl StatusCode {
|
||||
pub fn is_success(code: u32) -> bool {
|
||||
Self::Success as u32 == code
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Display for StatusCode {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
// The current debug format is suitable to display.
|
||||
@@ -67,4 +75,12 @@ mod tests {
|
||||
assert_status_code_display(StatusCode::Unknown, "Unknown");
|
||||
assert_status_code_display(StatusCode::TableAlreadyExists, "TableAlreadyExists");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_is_success() {
|
||||
assert!(StatusCode::is_success(0));
|
||||
assert!(!StatusCode::is_success(1));
|
||||
assert!(!StatusCode::is_success(2));
|
||||
assert!(!StatusCode::is_success(3));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user