GreptimeTeam / greptimedb

An open-source, cloud-native, unified time series database for metrics, logs and events with SQL/PromQL supported. Available on GreptimeCloud.
https://greptime.com/
Apache License 2.0
4.14k stars 295 forks source link

Improve error messages #4340

Open killme2008 opened 1 month ago

killme2008 commented 1 month ago

What type of enhancement is this?

API improvement

What does the enhancement do?

The error messages in GreptimeDB have some issues:

Implementation challenges

No response

evenyag commented 1 month ago

Returns the correct errors from DataFusion.

As mentioned in https://github.com/GreptimeTeam/greptimedb/pull/4362#discussion_r1677778154, maybe we can wrap the error into a BoxedError before casting to the DataFusion error. Then we can always downcast the error into our BoxedError. cc @shuiyisong

leaf-potato commented 1 month ago

I want to have a try for PostgreSQL.

killme2008 commented 1 month ago

I want to have a try for PostgreSQL.

Cool, thank you.

leaf-potato commented 1 month ago

@killme2008 I have a problem. Different from mysql crate, no type of PostgreSQL error codes found in pgwire crate. So in order to map StatusCode, I need to define enum PgWireErrorCode first?

enum PgWireErrorCode {
    EC_00000,
    EC_01000,
    ...
}
killme2008 commented 1 month ago

@killme2008 I have a problem. Different from mysql crate, no type of PostgreSQL error codes found in pgwire crate. So in order to map StatusCode, I need to define enum PgWireErrorCode first?

enum PgWireErrorCode {
    EC_00000,
    EC_01000,
    ...
}

Yes, but i think you don't need to define all the pg error codes, but just the StatusCode needs.

https://greptimedb.rs/common_error/status_code/enum.StatusCode.html

killme2008 commented 1 month ago

Or maybe a function like fn status_code_to_pg_error(status: StatusCode) -> &str is enough.