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

chore(sink): validate file sink when creating #18707

Merged
merged 4 commits into from
Sep 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ci/scripts/e2e-sink-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ sqllogictest -p 4566 -d dev './e2e_test/sink/create_sink_as.slt'
sqllogictest -p 4566 -d dev './e2e_test/sink/blackhole_sink.slt'
sqllogictest -p 4566 -d dev './e2e_test/sink/remote/types.slt'
sqllogictest -p 4566 -d dev './e2e_test/sink/sink_into_table/*.slt'
sqllogictest -p 4566 -d dev './e2e_test/sink/file_sink.slt'
sleep 1

echo "--- testing remote sinks"
Expand Down
20 changes: 20 additions & 0 deletions e2e_test/sink/file_sink.slt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
statement ok
CREATE TABLE t (v1 int, v2 int);

statement error
CREATE table s3_4(
v1 int,
v2 int,
)
WITH (
connector = 's3',
match_pattern = '*.parquet',
s3.region_name = 'custom',
s3.bucket_name = 'hummock001',
s3.credentials.access = 'wrong_access',
s3.credentials.secret = 'wrong_secret',
s3.endpoint_url = 'http://hummock001.127.0.0.1:9301',
) FORMAT PLAIN ENCODE PARQUET;

statement ok
DROP TABLE t;
7 changes: 6 additions & 1 deletion src/connector/src/sink/file_sink/opendal_sink.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,11 @@ impl<S: OpendalSinkBackend> Sink for FileSink<S> {
"File sink only supports `PARQUET` encode at present."
)));
}
Ok(())

match self.op.list(&self.path).await {
lmatz marked this conversation as resolved.
Show resolved Hide resolved
Ok(_) => Ok(()),
Err(e) => Err(anyhow!(e).into()),
}
}

async fn new_log_sinker(
Expand Down Expand Up @@ -139,6 +143,7 @@ impl<S: OpendalSinkBackend> TryFrom<SinkParam> for FileSink<S> {
let path = S::get_path(config.clone()).to_string();
let op = S::new_operator(config.clone())?;
let engine_type = S::get_engine_type();

Ok(Self {
op,
path,
Expand Down
Loading