Skip to content

Commit

Permalink
resolve conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
chenzl25 committed Feb 23, 2024
2 parents f9d74fa + 5cda6dd commit fd3137c
Show file tree
Hide file tree
Showing 150 changed files with 1,720 additions and 721 deletions.
2 changes: 2 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 29 additions & 4 deletions e2e_test/batch/basic/make_time.slt.part
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,20 @@ SELECT make_timestamptz(1973, 07, 15, 08, 15, 55.33);
query T
SELECT make_timestamptz(-1973, 07, 15, 08, 15, 55.33);
----
-1972-07-15 08:15:55.330+00:00
1973-07-15 08:15:55.330+00:00 BC

query T
SELECT make_timestamptz(20240, 1, 26, 14, 20, 26);
----
20240-01-26 14:20:26+00:00

query error Invalid parameter year, month, day: invalid date: -3-2-29
SELECT make_timestamptz(-4, 02, 29, 08, 15, 55.33);

query T
SELECT make_timestamptz(-5, 02, 29, 08, 15, 55.33);
----
-0004-02-29 08:15:55.330+00:00
0005-02-29 08:15:55.330+00:00 BC

query error Invalid parameter sec: invalid sec: -55.33
SELECT make_timestamptz(1973, 07, 15, 08, 15, -55.33);
Expand Down Expand Up @@ -105,6 +110,11 @@ SELECT make_date(2024, 1, 26);
----
2024-01-26

query T
SELECT make_date(20240, 1, 26);
----
20240-01-26

query T
SELECT make_date(-2024, 1, 26);
----
Expand Down Expand Up @@ -146,15 +156,30 @@ SELECT make_timestamp(2024, 1, 26, 14, 20, 26);
----
2024-01-26 14:20:26

query T
SELECT make_timestamp(20240, 1, 26, 14, 20, 26);
----
20240-01-26 14:20:26

query T
SELECT make_timestamp(-1973, 07, 15, 08, 15, 55.33);
----
-1972-07-15 08:15:55.330
1973-07-15 08:15:55.330 BC

query error Invalid parameter year, month, day: invalid date: -3-2-29
SELECT make_timestamp(-4, 02, 29, 08, 15, 55.33);

query T
SELECT make_timestamp(-5, 02, 29, 08, 15, 55.33);
----
-0004-02-29 08:15:55.330
0005-02-29 08:15:55.330 BC

query T
select '0001-01-01 12:34:56'::timestamp - '10 year'::interval;
----
0010-01-01 12:34:56 BC

query T
select '0001-01-01 12:34:56'::timestamptz - '10 year'::interval;
----
0010-01-01 12:34:56+00:00 BC
8 changes: 8 additions & 0 deletions e2e_test/batch/catalog/pg_settings.slt.part
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,14 @@ query TT
SELECT * FROM pg_catalog.pg_settings where name='dummy';
----

# https://github.com/risingwavelabs/risingwave/issues/15125
query TT
SELECT min(name) name, context FROM pg_catalog.pg_settings GROUP BY context;
----
application_name user
backup_storage_directory postmaster
block_size_kb internal

# Tab-completion of `SET` command
query T
SELECT name
Expand Down
3 changes: 2 additions & 1 deletion e2e_test/source/basic/ddl.slt
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ db error: ERROR: Failed to run the query
Caused by these errors (recent errors listed first):
1: gRPC request to meta service failed: Internal error
2: failed to create source worker
3: missing field `properties.bootstrap.server`
3: failed to parse json
4: missing field `properties.bootstrap.server`


statement error
Expand Down
23 changes: 23 additions & 0 deletions e2e_test/streaming/bug_fixes/issue_15198.slt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# https://github.com/risingwavelabs/risingwave/issues/15198

statement ok
SET RW_IMPLICIT_FLUSH TO TRUE;

statement ok
create materialized view "tumble_with_offset"
as (
with
input as (
select 1 as id, TO_TIMESTAMP('2024-01-01 01:30:02', 'YYYY-MM-DD HH24:MI:SS') as timestamps
)
select *
from tumble(input, timestamps, interval '1 DAY', '+6 HOURS')
);

query ITTT
select * from tumble_with_offset;
----
1 2024-01-01 01:30:02+00:00 2023-12-31 06:00:00+00:00 2024-01-01 06:00:00+00:00

statement ok
drop materialized view tumble_with_offset;
File renamed without changes.
44 changes: 44 additions & 0 deletions e2e_test/streaming/rate_limit/upstream_amplification.slt
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# This test will test that barrier latency does not spike
# when there's rate limit on source.
# The upstream side should backpressure the source reader,
# but still allow barriers to flow through.

statement ok
SET STREAMING_PARALLELISM=2;

statement ok
SET STREAMING_RATE_LIMIT=1;

statement ok
CREATE TABLE source_table (i1 int)
WITH (
connector = 'datagen',
fields.i1.start = '1',
fields.i1.end = '5',
datagen.rows.per.second = '10000'
) FORMAT PLAIN ENCODE JSON;

statement ok
CREATE SINK sink AS
SELECT x.i1 as i1 FROM source_table x
JOIN source_table s1 ON x.i1 = s1.i1
JOIN source_table s2 ON x.i1 = s2.i1
JOIN source_table s3 ON x.i1 = s3.i1
WITH (connector = 'blackhole');

# The following sequence of FLUSH should be fast, since barrier should be able to bypass sink.
# Otherwise, these FLUSH will take a long time to complete, and trigger timeout.
statement ok
flush;

statement ok
flush;

statement ok
flush;

statement ok
drop sink sink;

statement ok
drop table source_table;
75 changes: 56 additions & 19 deletions lints/src/format_error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use clippy_utils::diagnostics::span_lint_and_help;
use clippy_utils::macros::{
find_format_arg_expr, find_format_args, is_format_macro, macro_backtrace,
};
use clippy_utils::ty::implements_trait;
use clippy_utils::ty::{implements_trait, match_type};
use clippy_utils::{
is_in_cfg_test, is_in_test_function, is_trait_method, match_def_path, match_function_call,
};
Expand Down Expand Up @@ -64,6 +64,7 @@ const TRACING_FIELD_DEBUG: [&str; 3] = ["tracing_core", "field", "debug"];
const TRACING_FIELD_DISPLAY: [&str; 3] = ["tracing_core", "field", "display"];
const TRACING_MACROS_EVENT: [&str; 3] = ["tracing", "macros", "event"];
const ANYHOW_MACROS_ANYHOW: [&str; 3] = ["anyhow", "macros", "anyhow"];
const ANYHOW_ERROR: [&str; 2] = ["anyhow", "Error"];

impl<'tcx> LateLintPass<'tcx> for FormatError {
fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) {
Expand Down Expand Up @@ -143,20 +144,27 @@ fn check_fmt_arg_in_anyhow_error(cx: &LateContext<'_>, arg_expr: &Expr<'_>) {
check_fmt_arg_with_help(
cx,
arg_expr,
"consider directly wrapping the error with `anyhow::anyhow!(..)` instead of formatting it",
(
"consider directly wrapping the error with `anyhow::anyhow!(..)` instead of formatting it",
"consider removing the redundant wrapping of `anyhow::anyhow!(..)`",
),
);
}

fn check_fmt_arg_in_anyhow_context(cx: &LateContext<'_>, arg_expr: &Expr<'_>) {
check_fmt_arg_with_help(
cx,
arg_expr,
"consider using `anyhow::Error::context`, `anyhow::Context::(with_)context` to \
(
"consider using `anyhow::Context::(with_)context` to \
attach additional message to the error and make it an error source instead",
"consider using `.context(..)` to \
attach additional message to the error and make it an error source instead",
),
);
}

fn check_fmt_arg_with_help(cx: &LateContext<'_>, arg_expr: &Expr<'_>, help: &str) {
fn check_fmt_arg_with_help(cx: &LateContext<'_>, arg_expr: &Expr<'_>, help: impl Help) {
check_arg(cx, arg_expr, arg_expr.span, help);
}

Expand All @@ -169,27 +177,56 @@ fn check_to_string_call(cx: &LateContext<'_>, receiver: &Expr<'_>, to_string_spa
);
}

fn check_arg(cx: &LateContext<'_>, arg_expr: &Expr<'_>, span: Span, help: &str) {
fn check_arg(cx: &LateContext<'_>, arg_expr: &Expr<'_>, span: Span, help: impl Help) {
let Some(error_trait_id) = cx.tcx.get_diagnostic_item(sym::Error) else {
return;
};

let ty = cx.typeck_results().expr_ty(arg_expr).peel_refs();

if implements_trait(cx, ty, error_trait_id, &[]) {
if let Some(span) = core::iter::successors(Some(span), |s| s.parent_callsite())
.find(|s| s.can_be_used_for_suggestions())
{
// TODO: applicable suggestions
span_lint_and_help(
cx,
FORMAT_ERROR,
span,
"should not format error directly",
None,
help,
);
}
let help = if implements_trait(cx, ty, error_trait_id, &[]) {
help.normal_help()
} else if match_type(cx, ty, &ANYHOW_ERROR) {
help.anyhow_help()
} else {
return;
};

if let Some(span) = core::iter::successors(Some(span), |s| s.parent_callsite())
.find(|s| s.can_be_used_for_suggestions())
{
// TODO: applicable suggestions
span_lint_and_help(
cx,
FORMAT_ERROR,
span,
"should not format error directly",
None,
help,
);
}
}

trait Help {
fn normal_help(&self) -> &str;
fn anyhow_help(&self) -> &str {
self.normal_help()
}
}

impl Help for &str {
fn normal_help(&self) -> &str {
self
}
}

impl Help for (&str, &str) {
fn normal_help(&self) -> &str {
self.0
}

fn anyhow_help(&self) -> &str {
self.1
}
}

Expand Down
1 change: 1 addition & 0 deletions lints/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

#![feature(rustc_private)]
#![feature(let_chains)]
#![feature(lazy_cell)]
#![warn(unused_extern_crates)]

extern crate rustc_ast;
Expand Down
18 changes: 18 additions & 0 deletions lints/ui/format_error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,22 @@ fn main() {
let _ = anyhow!("{:?}", err);
let _ = anyhow!("some error occurred: {}", err);
let _ = anyhow!("some error occurred: {:?}", err);

// `anyhow::Error` does not implement `Error` trait, test the special path here.
let make_anyhow_err = || anyhow!("foobar");
let anyhow_err = make_anyhow_err();

let _ = format!("{}", anyhow_err);
let _ = format!("{}", &anyhow_err);
let _ = format!("{}", &&anyhow_err);
let _ = format!("{}", Box::new(&anyhow_err)); // TODO: fail to lint

tracing::field::display(&anyhow_err);
tracing::field::debug(make_anyhow_err());

let _ = anyhow_err.to_string();
let _ = (&&anyhow_err).to_string();

let _ = anyhow!("{}", anyhow_err);
let _ = anyhow!("some error occurred: {:?}", anyhow_err);
}
Loading

0 comments on commit fd3137c

Please sign in to comment.