Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(error): migrate function errors to anyhow #14159

Closed
wants to merge 10 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion e2e_test/batch/aggregate/sum.slt.part
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ select sum(d) from t;
statement ok
insert into t values (9000000000000000000000000000);

statement error Numeric out of range
statement error numeric out of range
select sum(d) from t;

statement ok
Expand Down
10 changes: 5 additions & 5 deletions e2e_test/batch/basic/func.slt.part
Original file line number Diff line number Diff line change
Expand Up @@ -528,10 +528,10 @@ select regexp_replace('abc123', 'abc', 'prefix\&suffix');
----
prefixabcsuffix123

query error invalid digit found in string
query error invalid input syntax for type integer: "g"
select regexp_replace('foobarbaz', 'b..', 'X', 1, 'g');

query error invalid digit found in string
query error invalid input syntax for type integer: "g"
select regexp_replace('foobarbaz', 'b..', 'X', 'g', 1);

# With Unicode
Expand Down Expand Up @@ -634,16 +634,16 @@ select regexp_count('foobarbaz', 'b..', 3);
----
2

query error invalid digit found in string
query error invalid input syntax for type integer: "g"
select regexp_count('foobarbaz', 'b..', 'g');

query error invalid digit found in string
query error invalid input syntax for type integer: "i"
select regexp_count('foobarbaz', 'b..', 'i');

query error invalid regular expression option: "a"
select regexp_count('foobarbaz', 'b..', 3, 'a');

query error does not support the global option
query error regexp_count\(\) does not support the "global" option
select regexp_count('foobar', 'b..', 1, 'g');

query T
Expand Down
10 changes: 5 additions & 5 deletions e2e_test/batch/basic/make_timestamptz.slt.part
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@ SELECT make_timestamptz(-1973, 07, 15, 08, 15, 55.33);
----
-1973-07-15 08:15:55.330+00:00

query error Invalid parameter sec: invalid sec
query error invalid sec
SELECT make_timestamptz(1973, 07, 15, 08, 15, -55.33);

query error Invalid parameter hour, min, sec: invalid time
query error invalid time
SELECT make_timestamptz(1973, 07, 15, 08, -15, 55.33);

query error Invalid parameter year, month, day: invalid date
query error invalid date
SELECT make_timestamptz(1973, -07, 15, 08, 15, 55.33);

query error Invalid parameter year, month, day: invalid date
query error invalid date
SELECT make_timestamptz(1973, 06, 31, 08, 15, 55.33);

statement ok
Expand All @@ -45,7 +45,7 @@ select * from ttz;
statement ok
drop table ttz;

query error Invalid parameter time_zone: 'Nehwon/Lankhmar' is not a valid timezone
query error 'Nehwon/Lankhmar' is not a valid timezone
SELECT make_timestamptz(1910, 12, 24, 0, 0, 0, 'Nehwon/Lankhmar');

query TT
Expand Down
2 changes: 1 addition & 1 deletion e2e_test/batch/basic/query.slt.part
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ select count(*) from t3;
----
1

statement error Division by zero
statement error division by zero
select v1/0 from t3;


Expand Down
4 changes: 2 additions & 2 deletions e2e_test/batch/functions/array_max.slt.part
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ select array_max(array['2c😅🤔😅️c2', '114🥵514', '30🤣🥳03', '5
----
5🥵💩💩🥵5

query error invalid digit found in string
query error invalid input syntax for type integer: "a"
select array_max(array['a', 'b', 'c', 114514]);

query error invalid digit found in string
query error invalid input syntax for type integer: "a"
select array_max(array[114514, 'a', 'b', 'c']);

# i32::MIN & i32::MIN - 1 & i32::MAX
Expand Down
4 changes: 2 additions & 2 deletions e2e_test/batch/functions/array_min.slt.part
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ select array_min(array['901😅🤔😅️109', '114🥵514', '3🤣🥳3', '5
----
114🥵514

query error invalid digit found in string
query error invalid input syntax for type integer: "a"
select array_min(array['a', 'b', 'c', 114514]);

query error invalid digit found in string
query error invalid input syntax for type integer: "a"
select array_min(array[114514, 'a', 'b', 'c']);

# i32::MIN & i32::MIN - 1 & i32::MAX
Expand Down
2 changes: 1 addition & 1 deletion e2e_test/batch/functions/array_sort.slt.part
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,5 @@ select array_sort(array[3, 2, NULL, 1, NULL]);
----
{1,2,3,NULL,NULL}

query error invalid digit found in string
query error invalid input syntax for type integer: "a"
select array_sort(array[3, 2, 1, 'a']);
17 changes: 8 additions & 9 deletions e2e_test/batch/functions/pow.slt.part
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,13 @@ select pow(100000, 0);
----
1

statement error underflow
statement error numeric out of range: underflow
select pow(100000, -200000000000000);

statement error Numeric out of range
statement error numeric out of range: overflow
select pow(100000, 200000000000000);


statement error Numeric out of range
statement error numeric out of range: overflow
select pow(-100000, 200000000000001);

query R
Expand Down Expand Up @@ -98,14 +97,14 @@ select 100000 ^ 0;
----
1

statement error underflow
statement error numeric out of range: underflow
select 100000 ^ -200000000000000;

statement error Numeric out of range
statement error numeric out of range: overflow
select 100000 ^ 200000000000000;


statement error Numeric out of range
statement error numeric out of range: overflow
select -100000 ^ 200000000000001;

query RRRR
Expand Down Expand Up @@ -231,10 +230,10 @@ select exp(2::smallint)
----
7.38905609893065

statement error Numeric out of range: overflow
statement error numeric out of range: overflow
select exp(10000000);

statement error Numeric out of range: underflow
statement error numeric out of range: underflow
select exp(-10000000);

query TRR
Expand Down
15 changes: 10 additions & 5 deletions e2e_test/batch/functions/to_char.slt.part
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,8 @@ db error: ERROR: Failed to run the query

Caused by these errors (recent errors listed first):
1: Expr error
2: Invalid parameter pattern: invalid format specification for an interval value, HINT: Intervals are not tied to specific calendar dates.
2: in function "to_char"
3: invalid format specification for an interval value, HINT: Intervals are not tied to specific calendar dates.


query error
Expand All @@ -123,7 +124,8 @@ db error: ERROR: Failed to run the query

Caused by these errors (recent errors listed first):
1: Expr error
2: Invalid parameter pattern: invalid format specification for an interval value, HINT: Intervals are not tied to specific calendar dates.
2: in function "to_char"
3: invalid format specification for an interval value, HINT: Intervals are not tied to specific calendar dates.


query error
Expand All @@ -133,7 +135,8 @@ db error: ERROR: Failed to run the query

Caused by these errors (recent errors listed first):
1: Expr error
2: Invalid parameter pattern: invalid format specification for an interval value, HINT: Intervals are not tied to specific calendar dates.
2: in function "to_char"
3: invalid format specification for an interval value, HINT: Intervals are not tied to specific calendar dates.


query error
Expand All @@ -143,7 +146,8 @@ db error: ERROR: Failed to run the query

Caused by these errors (recent errors listed first):
1: Expr error
2: Invalid parameter pattern: invalid format specification for an interval value, HINT: Intervals are not tied to specific calendar dates.
2: in function "to_char"
3: invalid format specification for an interval value, HINT: Intervals are not tied to specific calendar dates.


query error
Expand All @@ -153,4 +157,5 @@ db error: ERROR: Failed to run the query

Caused by these errors (recent errors listed first):
1: Expr error
2: Invalid parameter pattern: invalid format specification for an interval value, HINT: Intervals are not tied to specific calendar dates.
2: in function "to_char"
3: invalid format specification for an interval value, HINT: Intervals are not tied to specific calendar dates.
2 changes: 1 addition & 1 deletion e2e_test/batch/issue_7324.slt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ INSERT INTO INT2_TBL(f1) VALUES ('32767');
statement ok
INSERT INTO INT2_TBL(f1) VALUES ('-32767');

statement error Numeric out of range
statement error numeric out of range
SELECT i.f1, i.f1 * smallint '2' AS x FROM INT2_TBL i;

statement ok
Expand Down
3 changes: 2 additions & 1 deletion e2e_test/error_ui/extended/main.slt
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ db error: ERROR: Failed to execute the statement

Caused by these errors (recent errors listed first):
1: Expr error
2: Division by zero
2: in function "divide"
3: division by zero
6 changes: 4 additions & 2 deletions e2e_test/error_ui/simple/main.slt
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ db error: ERROR: Failed to run the query

Caused by these errors (recent errors listed first):
1: Expr error
2: Division by zero
2: in function "divide"
3: division by zero


query error
Expand All @@ -57,7 +58,8 @@ db error: ERROR: Failed to run the query

Caused by these errors (recent errors listed first):
1: Expr error
2: Division by zero
2: in function "divide"
3: division by zero


statement error
Expand Down
1 change: 0 additions & 1 deletion e2e_test/source/basic/ddl.slt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ create source invalid_startup_mode (
properties.bootstrap.server = 'message_queue:29092'
) FORMAT PLAIN ENCODE JSON;

# TODO: Better to refine the error message.
statement error invalid digit found in string
create source invalid_startup_timestamp (
column1 varchar
Expand Down
1 change: 0 additions & 1 deletion e2e_test/source/basic/old_row_format_syntax/ddl.slt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ create source invalid_startup_mode (
properties.bootstrap.server = 'message_queue:29092'
) ROW FORMAT JSON;

# TODO: Better to refine the error message.
statement error invalid digit found in string
create source invalid_startup_timestamp (
column1 varchar
Expand Down
12 changes: 6 additions & 6 deletions src/batch/src/executor/hop_window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

use std::num::NonZeroUsize;

use anyhow::anyhow;
use futures_async_stream::try_stream;
use itertools::Itertools;
use risingwave_common::array::DataChunk;
Expand Down Expand Up @@ -158,13 +159,12 @@ impl HopWindowExecutor {
let units = window_size
.exact_div(&window_slide)
.and_then(|x| NonZeroUsize::new(usize::try_from(x).ok()?))
.ok_or_else(|| ExprError::InvalidParam {
name: "window",
reason: format!(
.ok_or_else(|| {
ExprError::from(anyhow!(
"window_size {} cannot be divided by window_slide {}",
window_size, window_slide
)
.into(),
window_size,
window_slide
))
})?
.get();

Expand Down