risingwave_sqlsmith/
validation.rs1use risingwave_expr::ExprError;
17use risingwave_frontend::optimizer::variant_key::VARIANT_KEY_HINT;
18
19fn is_zero_err(db_error: &str) -> bool {
21 db_error.contains(&ExprError::DivisionByZero.to_string()) || db_error.contains("can't be zero")
22}
23
24fn is_numeric_out_of_range_err(db_error: &str) -> bool {
30 db_error.contains(&ExprError::NumericOutOfRange.to_string())
31 || db_error.contains("Casting to u32 out of range")
32}
33
34fn is_parse_err(db_error: &str) -> bool {
35 db_error.contains("Parse error")
36}
37
38fn is_unimplemented_error(db_error: &str) -> bool {
40 db_error.contains("not yet implemented")
41}
42
43fn not_unique_error(db_error: &str) -> bool {
48 db_error.contains("Bind error") && db_error.contains("is not unique")
49}
50
51fn is_window_error(db_error: &str) -> bool {
52 db_error.contains("Bind error: The size arg of window table function should be an interval literal")
53 || db_error.contains("Bind error: The 2nd arg of window table function should be a column name but not complex expression. Consider using an intermediate CTE or view as workaround")
54}
55
56fn is_nested_loop_join_error(db_error: &str) -> bool {
58 db_error.contains("Not supported: streaming nested-loop join")
59}
60
61fn is_variant_key_error(db_error: &str) -> bool {
62 db_error.contains(VARIANT_KEY_HINT)
63}
64
65fn is_subquery_unnesting_error(db_error: &str) -> bool {
66 db_error.contains("Subquery cannot be unnested")
67 || db_error.contains("Scalar subquery might produce more than one row")
68}
69
70fn is_numeric_overflow_error(db_error: &str) -> bool {
72 db_error.contains("Number") && db_error.contains("overflows")
73}
74
75fn is_neg_substr_error(db_error: &str) -> bool {
77 db_error.contains("negative substring length not allowed")
78}
79
80fn is_overlay_start_error(db_error: &str) -> bool {
82 db_error.contains("Invalid parameter start") && db_error.contains("is not positive")
83}
84
85fn is_broken_channel_error(db_error: &str) -> bool {
87 db_error.contains("failed to finish command: channel closed")
88}
89
90pub fn is_recovery_in_progress_error(db_error: &str) -> bool {
104 db_error.contains("Barrier read is unavailable for now. Likely the cluster is recovering")
105 || db_error.contains("Service unavailable: The cluster is starting or recovering")
106}
107
108pub fn is_neg_exp_error(db_error: &str) -> bool {
109 db_error.contains("zero raised to a negative power is undefined")
110}
111
112pub fn is_neg_input_error(db_error: &str) -> bool {
113 db_error.contains("input cannot be negative value")
114}
115
116pub fn is_permissible_error(db_error: &str) -> bool {
120 is_numeric_out_of_range_err(db_error)
121 || is_zero_err(db_error)
122 || is_parse_err(db_error)
123 || is_unimplemented_error(db_error)
124 || not_unique_error(db_error)
125 || is_window_error(db_error)
126 || is_nested_loop_join_error(db_error)
127 || is_variant_key_error(db_error)
128 || is_subquery_unnesting_error(db_error)
129 || is_numeric_overflow_error(db_error)
130 || is_neg_substr_error(db_error)
131 || is_overlay_start_error(db_error)
132 || is_broken_channel_error(db_error)
133 || is_neg_exp_error(db_error)
134 || is_neg_input_error(db_error)
135}