-
Notifications
You must be signed in to change notification settings - Fork 597
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
feat(connector): introduce azblob file scan #20046
Open
wcy-fdu
wants to merge
18
commits into
main
Choose a base branch
from
wcy/azblob_file_scan.pr
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 16 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
5658fc7
add gcs file scan
wcy-fdu 727bde6
code refactor
wcy-fdu a056d7c
code refactor
wcy-fdu 22885f6
Merge branch 'wcy/gcs_file_scan.pr' of https://github.com/risingwavel…
wcy-fdu ceefc56
support azblob file scan
wcy-fdu bf78a28
minor refactor
wcy-fdu 47afa32
Merge branch 'main' of https://github.com/risingwavelabs/risingwave i…
wcy-fdu 092ddf2
remove service account
wcy-fdu 2f9b1d9
update License header
wcy-fdu 56e9977
merge change from gcs.pr
wcy-fdu 6d79064
update License header
wcy-fdu ea663af
minor
wcy-fdu 967f409
resolve conflict
wcy-fdu 531e130
revert change in Cargo.lock
wcy-fdu 14ef860
more strict table function parameter length judgment
wcy-fdu c41d56b
Merge branch 'main' of https://github.com/risingwavelabs/risingwave i…
wcy-fdu 0cc006d
fix typr
wcy-fdu 6c5c2e1
Merge branch 'main' into wcy/azblob_file_scan.pr
wcy-fdu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
// Copyright 2025 RisingWave Labs | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
use futures_async_stream::try_stream; | ||
use futures_util::stream::StreamExt; | ||
use risingwave_common::array::DataChunk; | ||
use risingwave_common::catalog::{Field, Schema}; | ||
use risingwave_connector::source::iceberg::{ | ||
extract_bucket_and_file_name, new_azblob_operator, read_parquet_file, FileScanBackend, | ||
}; | ||
use risingwave_pb::batch_plan::file_scan_node; | ||
use risingwave_pb::batch_plan::plan_node::NodeBody; | ||
|
||
use crate::error::BatchError; | ||
use crate::executor::{BoxedExecutor, BoxedExecutorBuilder, Executor, ExecutorBuilder}; | ||
|
||
#[derive(PartialEq, Debug)] | ||
pub enum FileFormat { | ||
Parquet, | ||
} | ||
|
||
/// Azblob file scan executor. Currently only support parquet file format. | ||
pub struct AzblobFileScanExecutor { | ||
file_format: FileFormat, | ||
file_location: Vec<String>, | ||
account_name: String, | ||
account_key: String, | ||
endpoint: String, | ||
batch_size: usize, | ||
schema: Schema, | ||
identity: String, | ||
} | ||
|
||
impl Executor for AzblobFileScanExecutor { | ||
fn schema(&self) -> &risingwave_common::catalog::Schema { | ||
&self.schema | ||
} | ||
|
||
fn identity(&self) -> &str { | ||
&self.identity | ||
} | ||
|
||
fn execute(self: Box<Self>) -> super::BoxedDataChunkStream { | ||
self.do_execute().boxed() | ||
} | ||
} | ||
|
||
impl AzblobFileScanExecutor { | ||
pub fn new( | ||
file_format: FileFormat, | ||
file_location: Vec<String>, | ||
account_name: String, | ||
account_key: String, | ||
endpoint: String, | ||
batch_size: usize, | ||
schema: Schema, | ||
identity: String, | ||
) -> Self { | ||
Self { | ||
file_format, | ||
file_location, | ||
account_name, | ||
account_key, | ||
endpoint, | ||
batch_size, | ||
schema, | ||
identity, | ||
} | ||
} | ||
|
||
#[try_stream(ok = DataChunk, error = BatchError)] | ||
async fn do_execute(self: Box<Self>) { | ||
assert_eq!(self.file_format, FileFormat::Parquet); | ||
for file in self.file_location { | ||
let (bucket, file_name) = | ||
extract_bucket_and_file_name(&file, &FileScanBackend::Azblob)?; | ||
let op = new_azblob_operator( | ||
self.account_name.clone(), | ||
self.account_key.clone(), | ||
self.endpoint.clone(), | ||
bucket.clone(), | ||
)?; | ||
let chunk_stream = | ||
read_parquet_file(op, file_name, None, None, self.batch_size, 0).await?; | ||
#[for_await] | ||
for stream_chunk in chunk_stream { | ||
let stream_chunk = stream_chunk?; | ||
let (data_chunk, _) = stream_chunk.into_parts(); | ||
yield data_chunk; | ||
} | ||
} | ||
} | ||
} | ||
|
||
pub struct AzblobFileScanExecutorBuilder {} | ||
|
||
impl BoxedExecutorBuilder for AzblobFileScanExecutorBuilder { | ||
async fn new_boxed_executor( | ||
source: &ExecutorBuilder<'_>, | ||
_inputs: Vec<BoxedExecutor>, | ||
) -> crate::error::Result<BoxedExecutor> { | ||
let file_scan_node = try_match_expand!( | ||
source.plan_node().get_node_body().unwrap(), | ||
NodeBody::AzblobFileScan | ||
)?; | ||
|
||
Ok(Box::new(AzblobFileScanExecutor::new( | ||
match file_scan_node::FileFormat::try_from(file_scan_node.file_format).unwrap() { | ||
file_scan_node::FileFormat::Parquet => FileFormat::Parquet, | ||
file_scan_node::FileFormat::Unspecified => unreachable!(), | ||
}, | ||
file_scan_node.file_location.clone(), | ||
file_scan_node.account_name.clone(), | ||
file_scan_node.account_key.clone(), | ||
file_scan_node.endpoint.clone(), | ||
source.context().get_config().developer.chunk_size, | ||
Schema::from_iter(file_scan_node.columns.iter().map(Field::from)), | ||
source.plan_node().get_identity().clone(), | ||
))) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a minor typo in the error message - remove the double colon in
as follows::
to make itas follows:
Spotted by Graphite Reviewer
Is this helpful? React 👍 or 👎 to let us know.