Skip to content

Commit

Permalink
fix: add missing error display message (#2791)
Browse files Browse the repository at this point in the history
* fix: add missing error display message

Signed-off-by: Ruihang Xia <[email protected]>

* update sqlness result

Signed-off-by: Ruihang Xia <[email protected]>

---------

Signed-off-by: Ruihang Xia <[email protected]>
  • Loading branch information
waynexia authored Nov 23, 2023
1 parent 4c76d4d commit 56fc77e
Show file tree
Hide file tree
Showing 30 changed files with 136 additions and 186 deletions.
4 changes: 2 additions & 2 deletions src/catalog/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ pub enum Error {
source: table::error::Error,
},

#[snafu(display(""))]
#[snafu(display("Internal error"))]
Internal {
location: Location,
source: BoxedError,
Expand Down Expand Up @@ -216,7 +216,7 @@ pub enum Error {
#[snafu(display("Illegal access to catalog: {} and schema: {}", catalog, schema))]
QueryAccessDenied { catalog: String, schema: String },

#[snafu(display(""))]
#[snafu(display("DataFusion error"))]
Datafusion {
#[snafu(source)]
error: DataFusionError,
Expand Down
4 changes: 2 additions & 2 deletions src/frontend/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ pub enum Error {
source: common_meta::error::Error,
},

#[snafu(display(""))]
#[snafu(display("External error"))]
External {
location: Location,
source: BoxedError,
Expand Down Expand Up @@ -170,7 +170,7 @@ pub enum Error {
source: query::error::Error,
},

#[snafu(display(""))]
#[snafu(display("Operation to region server failed"))]
InvokeRegionServer {
location: Location,
source: servers::error::Error,
Expand Down
2 changes: 1 addition & 1 deletion src/query/src/datafusion/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use snafu::{Location, Snafu};
#[snafu(visibility(pub))]
#[stack_trace_debug]
pub enum InnerError {
#[snafu(display(""))]
#[snafu(display("DataFusion error"))]
Datafusion {
#[snafu(source)]
error: DataFusionError,
Expand Down
4 changes: 2 additions & 2 deletions src/query/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ pub enum Error {
location: Location,
},

#[snafu(display(""))]
#[snafu(display("DataFusion error"))]
DataFusion {
#[snafu(source)]
error: DataFusionError,
Expand All @@ -140,7 +140,7 @@ pub enum Error {
source: sql::error::Error,
},

#[snafu(display(""))]
#[snafu(display("Failed to plan SQL"))]
PlanSql {
#[snafu(source)]
error: DataFusionError,
Expand Down
2 changes: 1 addition & 1 deletion src/script/src/python/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ pub enum Error {
error: ArrowError,
},

#[snafu(display(""))]
#[snafu(display("DataFusion error"))]
DataFusion {
location: SnafuLocation,
#[snafu(source)]
Expand Down
13 changes: 8 additions & 5 deletions src/servers/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -339,8 +339,12 @@ pub enum Error {
source: crate::http::pprof::nix::Error,
},

#[snafu(display(""))]
Metrics { source: BoxedError },
#[snafu(display("Failed to update jemalloc metrics"))]
UpdateJemallocMetrics {
#[snafu(source)]
error: tikv_jemalloc_ctl::Error,
location: Location,
},

#[snafu(display("DataFrame operation error"))]
DataFrame {
Expand Down Expand Up @@ -408,7 +412,8 @@ impl ErrorExt for Error {
| TcpIncoming { .. }
| CatalogError { .. }
| GrpcReflectionService { .. }
| BuildHttpResponse { .. } => StatusCode::Internal,
| BuildHttpResponse { .. }
| UpdateJemallocMetrics { .. } => StatusCode::Internal,

CollectRecordbatch { .. } => StatusCode::EngineExecuteQuery,

Expand Down Expand Up @@ -479,8 +484,6 @@ impl ErrorExt for Error {
#[cfg(feature = "pprof")]
DumpPprof { source, .. } => source.status_code(),

Metrics { source } => source.status_code(),

ConvertScalarValue { source, .. } => source.status_code(),

ToJson { .. } => StatusCode::Internal,
Expand Down
5 changes: 2 additions & 3 deletions src/servers/src/metrics/jemalloc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,16 @@
// See the License for the specific language governing permissions and
// limitations under the License.

mod error;

use common_telemetry::error;
use error::UpdateJemallocMetricsSnafu;
use lazy_static::lazy_static;
use once_cell::sync::Lazy;
use prometheus::*;
use snafu::ResultExt;
use tikv_jemalloc_ctl::stats::{allocated_mib, resident_mib};
use tikv_jemalloc_ctl::{epoch, epoch_mib, stats};

use crate::error::UpdateJemallocMetricsSnafu;

lazy_static! {
pub static ref SYS_JEMALLOC_RESIDEN: IntGauge = register_int_gauge!(
"sys_jemalloc_resident",
Expand Down
52 changes: 0 additions & 52 deletions src/servers/src/metrics/jemalloc/error.rs

This file was deleted.

2 changes: 1 addition & 1 deletion src/table/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ pub type Result<T> = std::result::Result<T, Error>;
#[snafu(visibility(pub))]
#[stack_trace_debug]
pub enum Error {
#[snafu(display(""))]
#[snafu(display("DataFusion error"))]
Datafusion {
#[snafu(source)]
error: DataFusionError,
Expand Down
4 changes: 2 additions & 2 deletions tests/cases/distributed/optimizer/filter_push_down.result
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ SELECT * FROM integers i1 WHERE NOT EXISTS(SELECT i FROM integers WHERE i=i1.i)

SELECT i1.i,i2.i FROM integers i1, integers i2 WHERE i1.i=(SELECT i FROM integers WHERE i1.i=i) AND i1.i=i2.i ORDER BY i1.i;

Error: 3001(EngineExecuteQuery), Error during planning: Correlated scalar subquery must be aggregated to return at most one row
Error: 3001(EngineExecuteQuery), DataFusion error: Error during planning: Correlated scalar subquery must be aggregated to return at most one row

SELECT * FROM (SELECT i1.i AS a, i2.i AS b FROM integers i1, integers i2) a1 WHERE a=b ORDER BY 1;

Expand Down Expand Up @@ -241,7 +241,7 @@ Error: 3001(EngineExecuteQuery), Invalid argument error: must either specify a r

SELECT * FROM (SELECT 0=1 AS cond FROM integers i1, integers i2 GROUP BY 1) a1 WHERE cond ORDER BY 1;

Error: 3001(EngineExecuteQuery), Error during planning: Attempted to create Filter predicate with expression `Boolean(false)` aliased as 'Int64(0) = Int64(1)'. Filter predicates should not be aliased.
Error: 3001(EngineExecuteQuery), DataFusion error: Error during planning: Attempted to create Filter predicate with expression `Boolean(false)` aliased as 'Int64(0) = Int64(1)'. Filter predicates should not be aliased.

DROP TABLE integers;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ SELECT DISTINCT i%2 FROM integers ORDER BY 1;
-- +-----------------------+
SELECT DISTINCT i % 2 FROM integers WHERE i<3 ORDER BY i;

Error: 3000(PlanQuery), Error during planning: For SELECT DISTINCT, ORDER BY expressions i must appear in select list
Error: 3000(PlanQuery), Failed to plan SQL: Error during planning: For SELECT DISTINCT, ORDER BY expressions i must appear in select list

SELECT DISTINCT ON (1) i % 2, i FROM integers WHERE i<3 ORDER BY i;

Error: 3000(PlanQuery), This feature is not implemented: DISTINCT ON Exprs not supported
Error: 3000(PlanQuery), Failed to plan SQL: This feature is not implemented: DISTINCT ON Exprs not supported

SELECT DISTINCT integers.i FROM integers ORDER BY i DESC;

Expand Down
2 changes: 1 addition & 1 deletion tests/cases/standalone/common/alter/rename_table.result
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Error: 4001(TableNotFound), Table not found: t

SELECT * FROM t;

Error: 3000(PlanQuery), Error during planning: Table not found: greptime.public.t
Error: 3000(PlanQuery), Failed to plan SQL: Error during planning: Table not found: greptime.public.t

CREATE TABLE t(i INTEGER, j TIMESTAMP TIME INDEX);

Expand Down
2 changes: 1 addition & 1 deletion tests/cases/standalone/common/catalog/schema.result
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ Error: 1001(Unsupported), SQL statement is not supported: DROP SCHEMA test_publi

SELECT * FROM test_public_schema.hello;

Error: 3000(PlanQuery), Error during planning: Table not found: greptime.test_public_schema.hello
Error: 3000(PlanQuery), Failed to plan SQL: Error during planning: Table not found: greptime.test_public_schema.hello

USE public;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Affected Rows: 2

select * from system_Metric;

Error: 3000(PlanQuery), Error during planning: Table not found: greptime.upper_case_table_name.system_metric
Error: 3000(PlanQuery), Failed to plan SQL: Error during planning: Table not found: greptime.upper_case_table_name.system_metric

select * from "system_Metric";

Expand Down
8 changes: 4 additions & 4 deletions tests/cases/standalone/common/cte/cte.result
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,12 @@ with cte1 as (select i as j from a), cte2 as (select ref.j as k from cte1 as ref

with cte1 as (select 42), cte1 as (select 42) select * FROM cte1;

Error: 3000(PlanQuery), sql parser error: WITH query name "cte1" specified more than once
Error: 3000(PlanQuery), Failed to plan SQL: sql parser error: WITH query name "cte1" specified more than once

-- reference to CTE before its actually defined, it's not supported by datafusion
with cte3 as (select ref2.j as i from cte1 as ref2), cte1 as (Select i as j from a), cte2 as (select ref.j+1 as k from cte1 as ref) select * from cte2 union all select * FROM cte3;

Error: 3000(PlanQuery), Error during planning: Table not found: greptime.public.cte1
Error: 3000(PlanQuery), Failed to plan SQL: Error during planning: Table not found: greptime.public.cte1

with cte1 as (Select i as j from a) select * from cte1 cte11, cte1 cte12;

Expand Down Expand Up @@ -109,7 +109,7 @@ WITH RECURSIVE cte(d) AS (
)
SELECT max(d) FROM cte;

Error: 3000(PlanQuery), This feature is not implemented: Recursive CTEs are not supported
Error: 3000(PlanQuery), Failed to plan SQL: This feature is not implemented: Recursive CTEs are not supported

-- Nested aliases is not supported in datafusion
with cte (a) as (
Expand All @@ -121,7 +121,7 @@ select
from cte
where alias2 > 0;

Error: 3000(PlanQuery), No field named alias2. Valid fields are cte.a.
Error: 3000(PlanQuery), Failed to plan SQL: No field named alias2. Valid fields are cte.a.

drop table a;

Expand Down
6 changes: 3 additions & 3 deletions tests/cases/standalone/common/cte/cte_in_cte.result
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ with cte1 as (with b as (Select i as j from a) select j from b), cte2 as (with c

with cte1 as (select 42), cte1 as (select 42) select * FROM cte1;

Error: 3000(PlanQuery), sql parser error: WITH query name "cte1" specified more than once
Error: 3000(PlanQuery), Failed to plan SQL: sql parser error: WITH query name "cte1" specified more than once

with cte1 as (Select i as j from a) select * from (with cte2 as (select max(j) as j from cte1) select * from cte2) f;

Expand All @@ -64,12 +64,12 @@ with cte1 as (Select i as j from a) select * from cte1 where j = (with cte2 as (
-- this feature is not implemented in datafusion
with cte as (Select i as j from a) select * from cte where j = (with cte as (select max(j) as j from cte) select j from cte);

Error: 3000(PlanQuery), sql parser error: WITH query name "cte" specified more than once
Error: 3000(PlanQuery), Failed to plan SQL: sql parser error: WITH query name "cte" specified more than once

-- self-refer to non-existent cte-
with cte as (select * from cte) select * from cte;

Error: 3000(PlanQuery), Error during planning: Table not found: greptime.public.cte
Error: 3000(PlanQuery), Failed to plan SQL: Error during planning: Table not found: greptime.public.cte

drop table a;

Expand Down
6 changes: 3 additions & 3 deletions tests/cases/standalone/common/insert/insert_select.result
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ Affected Rows: 2

insert into demo2(host) select * from demo1;

Error: 3000(PlanQuery), Error during planning: Column count doesn't match insert query!
Error: 3000(PlanQuery), Failed to plan SQL: Error during planning: Column count doesn't match insert query!

insert into demo2 select cpu,memory from demo1;

Error: 3000(PlanQuery), Error during planning: Column count doesn't match insert query!
Error: 3000(PlanQuery), Failed to plan SQL: Error during planning: Column count doesn't match insert query!

insert into demo2(ts) select memory from demo1;

Error: 3000(PlanQuery), Error during planning: Cannot automatically convert Float64 to Timestamp(Millisecond, None)
Error: 3000(PlanQuery), Failed to plan SQL: Error during planning: Cannot automatically convert Float64 to Timestamp(Millisecond, None)

insert into demo2 select * from demo1;

Expand Down
2 changes: 1 addition & 1 deletion tests/cases/standalone/common/insert/special_value.result
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ select * from data;

insert into data values (4, 'infinityyyy'::double);

Error: 3001(EngineExecuteQuery), Cast error: Cannot cast string 'infinityyyy' to value of Float64 type
Error: 3001(EngineExecuteQuery), DataFusion error: Cast error: Cannot cast string 'infinityyyy' to value of Float64 type

drop table data;

Expand Down
Loading

0 comments on commit 56fc77e

Please sign in to comment.