-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Expose bulk ingest in flight sql client and server #6201
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
Merged
Merged
Changes from 10 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
5c88002
Expose CommandStatementIngest as pub in sql module
djanderson 6d669b2
Add do_put_statement_ingest to FlightSqlService
djanderson 228342a
Sort list
djanderson 1599afb
Implement stub do_put_statement_ingest in example
djanderson a8a9afc
Refactor helper functions into tests/common/utils
djanderson 4dcaeab
Implement execute_ingest for flight sql client
djanderson dfa7e55
Add integration test for sql client execute_ingest
djanderson b48a060
Fix lint clippy::new_without_default
djanderson 6c4ed33
Allow streaming ingest for FlightClient::execute_ingest
alamb 5641350
Merge pull request #1 from alamb/alamb/flight_ingest_check
djanderson 22a4a1d
Properly return client errors
alamb cfa6160
Merge remote-tracking branch 'apache/master' into do-put-statement-in…
alamb 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -18,3 +18,4 @@ | |
| pub mod fixture; | ||
| pub mod server; | ||
| pub mod trailers_layer; | ||
| pub mod utils; | ||
This file contains hidden or 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,118 @@ | ||
| // Licensed to the Apache Software Foundation (ASF) under one | ||
| // or more contributor license agreements. See the NOTICE file | ||
| // distributed with this work for additional information | ||
| // regarding copyright ownership. The ASF licenses this file | ||
| // to you 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. | ||
|
|
||
| //! Common utilities for testing flight clients and servers | ||
|
|
||
| use std::sync::Arc; | ||
|
|
||
| use arrow_array::{ | ||
| types::Int32Type, ArrayRef, BinaryViewArray, DictionaryArray, Float64Array, RecordBatch, | ||
| StringViewArray, UInt8Array, | ||
| }; | ||
| use arrow_schema::{DataType, Field, Schema}; | ||
|
|
||
| /// Make a primitive batch for testing | ||
| /// | ||
| /// Example: | ||
| /// i: 0, 1, None, 3, 4 | ||
| /// f: 5.0, 4.0, None, 2.0, 1.0 | ||
| #[allow(dead_code)] | ||
| pub fn make_primitive_batch(num_rows: usize) -> RecordBatch { | ||
| let i: UInt8Array = (0..num_rows) | ||
| .map(|i| { | ||
| if i == num_rows / 2 { | ||
| None | ||
| } else { | ||
| Some(i.try_into().unwrap()) | ||
| } | ||
| }) | ||
| .collect(); | ||
|
|
||
| let f: Float64Array = (0..num_rows) | ||
| .map(|i| { | ||
| if i == num_rows / 2 { | ||
| None | ||
| } else { | ||
| Some((num_rows - i) as f64) | ||
| } | ||
| }) | ||
| .collect(); | ||
|
|
||
| RecordBatch::try_from_iter(vec![("i", Arc::new(i) as ArrayRef), ("f", Arc::new(f))]).unwrap() | ||
| } | ||
|
|
||
| /// Make a dictionary batch for testing | ||
| /// | ||
| /// Example: | ||
| /// a: value0, value1, value2, None, value1, value2 | ||
| #[allow(dead_code)] | ||
| pub fn make_dictionary_batch(num_rows: usize) -> RecordBatch { | ||
| let values: Vec<_> = (0..num_rows) | ||
| .map(|i| { | ||
| if i == num_rows / 2 { | ||
| None | ||
| } else { | ||
| // repeat some values for low cardinality | ||
| let v = i / 3; | ||
| Some(format!("value{v}")) | ||
| } | ||
| }) | ||
| .collect(); | ||
|
|
||
| let a: DictionaryArray<Int32Type> = values | ||
| .iter() | ||
| .map(|s| s.as_ref().map(|s| s.as_str())) | ||
| .collect(); | ||
|
|
||
| RecordBatch::try_from_iter(vec![("a", Arc::new(a) as ArrayRef)]).unwrap() | ||
| } | ||
|
|
||
| #[allow(dead_code)] | ||
| pub fn make_view_batches(num_rows: usize) -> RecordBatch { | ||
| const LONG_TEST_STRING: &str = | ||
| "This is a long string to make sure binary view array handles it"; | ||
| let schema = Schema::new(vec![ | ||
| Field::new("field1", DataType::BinaryView, true), | ||
| Field::new("field2", DataType::Utf8View, true), | ||
| ]); | ||
|
|
||
| let string_view_values: Vec<Option<&str>> = (0..num_rows) | ||
| .map(|i| match i % 3 { | ||
| 0 => None, | ||
| 1 => Some("foo"), | ||
| 2 => Some(LONG_TEST_STRING), | ||
| _ => unreachable!(), | ||
| }) | ||
| .collect(); | ||
|
|
||
| let bin_view_values: Vec<Option<&[u8]>> = (0..num_rows) | ||
| .map(|i| match i % 3 { | ||
| 0 => None, | ||
| 1 => Some("bar".as_bytes()), | ||
| 2 => Some(LONG_TEST_STRING.as_bytes()), | ||
| _ => unreachable!(), | ||
| }) | ||
| .collect(); | ||
|
|
||
| let binary_array = BinaryViewArray::from_iter(bin_view_values); | ||
| let utf8_array = StringViewArray::from_iter(string_view_values); | ||
| RecordBatch::try_new( | ||
| Arc::new(schema.clone()), | ||
| vec![Arc::new(binary_array), Arc::new(utf8_array)], | ||
| ) | ||
| .unwrap() | ||
| } |
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.
This comment is no longer true, but is it still reasonable to unwrap or should we raise the error, or fuse the input stream, or...?
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.
I think we should return the error from the client. Let me see if I can figure it out....
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.
I think I fixed that in 22a4a1d -- but it was quite fiddly