arrow-bigquery 0.3.0__tar.gz → 0.3.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. {arrow_bigquery-0.3.0 → arrow_bigquery-0.3.2}/PKG-INFO +2 -2
  2. {arrow_bigquery-0.3.0 → arrow_bigquery-0.3.2}/arrow_bigquery/_read_bigquery.py +1 -1
  3. arrow_bigquery-0.3.2/arrow_bigquery/core/version.py +1 -0
  4. {arrow_bigquery-0.3.0 → arrow_bigquery-0.3.2}/crates/arrow-bigquery/src/bigquery_read_stream.rs +10 -21
  5. {arrow_bigquery-0.3.0 → arrow_bigquery-0.3.2}/crates/arrow-bigquery/src/decode.rs +13 -51
  6. {arrow_bigquery-0.3.0 → arrow_bigquery-0.3.2}/crates/arrow-bigquery/src/lib.rs +153 -153
  7. {arrow_bigquery-0.3.0 → arrow_bigquery-0.3.2}/crates/arrow-bigquery/src/query.rs +954 -149
  8. {arrow_bigquery-0.3.0 → arrow_bigquery-0.3.2}/crates/arrow-bigquery/tests/integration_test.rs +47 -0
  9. {arrow_bigquery-0.3.0 → arrow_bigquery-0.3.2}/py-arrow-bigquery/Cargo.toml +1 -1
  10. {arrow_bigquery-0.3.0 → arrow_bigquery-0.3.2}/py-arrow-bigquery/src/lib.rs +1 -1
  11. {arrow_bigquery-0.3.0 → arrow_bigquery-0.3.2}/py-arrow-bigquery/tests/unit/test_read_bigquery.py +13 -3
  12. {arrow_bigquery-0.3.0 → arrow_bigquery-0.3.2}/pyproject.toml +2 -2
  13. arrow_bigquery-0.3.0/arrow_bigquery/core/version.py +0 -1
  14. {arrow_bigquery-0.3.0 → arrow_bigquery-0.3.2}/Cargo.lock +0 -0
  15. {arrow_bigquery-0.3.0 → arrow_bigquery-0.3.2}/Cargo.toml +0 -0
  16. {arrow_bigquery-0.3.0 → arrow_bigquery-0.3.2}/arrow_bigquery/__init__.py +0 -0
  17. {arrow_bigquery-0.3.0 → arrow_bigquery-0.3.2}/arrow_bigquery/_testing.py +0 -0
  18. {arrow_bigquery-0.3.0 → arrow_bigquery-0.3.2}/arrow_bigquery/api/__init__.py +0 -0
  19. {arrow_bigquery-0.3.0 → arrow_bigquery-0.3.2}/arrow_bigquery/api/resources.py +0 -0
  20. {arrow_bigquery-0.3.0 → arrow_bigquery-0.3.2}/arrow_bigquery/core/__init__.py +0 -0
  21. {arrow_bigquery-0.3.0 → arrow_bigquery-0.3.2}/arrow_bigquery/exceptions.py +0 -0
  22. {arrow_bigquery-0.3.0 → arrow_bigquery-0.3.2}/crates/arrow-bigquery/Cargo.toml +0 -0
  23. {arrow_bigquery-0.3.0 → arrow_bigquery-0.3.2}/crates/arrow-bigquery/benches/query.rs +0 -0
  24. {arrow_bigquery-0.3.0 → arrow_bigquery-0.3.2}/crates/arrow-bigquery/benches/read.rs +0 -0
  25. {arrow_bigquery-0.3.0 → arrow_bigquery-0.3.2}/crates/arrow-bigquery/src/bigquery_read_retry.rs +0 -0
  26. {arrow_bigquery-0.3.0 → arrow_bigquery-0.3.2}/crates/arrow-bigquery/src/client_builder.rs +0 -0
  27. {arrow_bigquery-0.3.0 → arrow_bigquery-0.3.2}/crates/arrow-bigquery/src/error.rs +0 -0
  28. {arrow_bigquery-0.3.0 → arrow_bigquery-0.3.2}/py-arrow-bigquery/src/auth.rs +0 -0
  29. {arrow_bigquery-0.3.0 → arrow_bigquery-0.3.2}/py-arrow-bigquery/src/error.rs +0 -0
  30. {arrow_bigquery-0.3.0 → arrow_bigquery-0.3.2}/py-arrow-bigquery/src/stream.rs +0 -0
  31. {arrow_bigquery-0.3.0 → arrow_bigquery-0.3.2}/py-arrow-bigquery/src/table_id.rs +0 -0
  32. {arrow_bigquery-0.3.0 → arrow_bigquery-0.3.2}/py-arrow-bigquery/src/testing.rs +0 -0
  33. {arrow_bigquery-0.3.0 → arrow_bigquery-0.3.2}/py-arrow-bigquery/tests/unit/__init__.py +0 -0
  34. {arrow_bigquery-0.3.0 → arrow_bigquery-0.3.2}/py-arrow-bigquery/tests/unit/api/__init__.py +0 -0
  35. {arrow_bigquery-0.3.0 → arrow_bigquery-0.3.2}/py-arrow-bigquery/tests/unit/api/test_resources.py +0 -0
  36. {arrow_bigquery-0.3.0 → arrow_bigquery-0.3.2}/py-arrow-bigquery/tests/unit/conftest.py +0 -0
@@ -1,10 +1,10 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: arrow-bigquery
3
- Version: 0.3.0
3
+ Version: 0.3.2
4
4
  Classifier: Programming Language :: Rust
5
5
  Classifier: Programming Language :: Python :: Implementation :: CPython
6
6
  Classifier: Programming Language :: Python :: Implementation :: PyPy
7
7
  Requires-Dist: google-auth>=2.40.3
8
8
  Requires-Dist: requests>=2.33.0,<3.0.0
9
9
  Requires-Dist: cachetools>=5.0.0
10
- Requires-Python: >=3.10
10
+ Requires-Python: >=3.11
@@ -80,7 +80,7 @@ class Client:
80
80
  *,
81
81
  arrow_buffer_compression: str = "lz4frame",
82
82
  dry_run: bool = False,
83
- maintain_order: bool = False,
83
+ maintain_order: bool = True,
84
84
  use_query_cache: bool | None = None,
85
85
  ) -> arrow_bigquery._native.ArrowStreamExporter:
86
86
  return self._client.read_query(
@@ -0,0 +1 @@
1
+ __version__ = "0.3.2"
@@ -198,7 +198,6 @@ pub(crate) struct ReadStreamOptions {
198
198
  pub(crate) first_page_check: Option<FirstPageCheck>,
199
199
  pub(crate) tx: tokio::sync::mpsc::Sender<Result<RecordBatch, BigQueryError>>,
200
200
  pub(crate) retry_config: StreamRetryConfig,
201
- pub(crate) decode_pool: Arc<rayon::ThreadPool>,
202
201
  pub(crate) maintain_order: bool,
203
202
  pub(crate) cancel_tx: Arc<tokio::sync::watch::Sender<bool>>,
204
203
  pub(crate) cancel_rx: tokio::sync::watch::Receiver<bool>,
@@ -211,7 +210,6 @@ pub(crate) struct ReadQueryStreamOptions {
211
210
  pub(crate) metadata: Arc<StreamMetadata>,
212
211
  pub(crate) tx: tokio::sync::mpsc::Sender<Result<RecordBatch, BigQueryError>>,
213
212
  pub(crate) retry_config: StreamRetryConfig,
214
- pub(crate) decode_pool: Arc<rayon::ThreadPool>,
215
213
  pub(crate) maintain_order: bool,
216
214
  pub(crate) cancel_tx: Arc<tokio::sync::watch::Sender<bool>>,
217
215
  pub(crate) cancel_rx: tokio::sync::watch::Receiver<bool>,
@@ -241,7 +239,6 @@ impl ReadStream {
241
239
  first_page_check,
242
240
  tx,
243
241
  retry_config,
244
- decode_pool: _,
245
242
  maintain_order: _,
246
243
  cancel_tx,
247
244
  cancel_rx,
@@ -576,7 +573,7 @@ impl ReadStream {
576
573
 
577
574
  /// Orchestrates stream connection, consumption, and mid-stream reconnections via [`ReadStream::step`].
578
575
  pub(crate) async fn read_stream(options: ReadStreamOptions) -> TerminationReason {
579
- let decode_queue = DecodeQueue::new(Arc::clone(&options.decode_pool), options.maintain_order);
576
+ let decode_queue = DecodeQueue::new(options.maintain_order);
580
577
  let mut reader = ReadStream::new(options, decode_queue);
581
578
  reader.run().await
582
579
  }
@@ -592,12 +589,11 @@ pub(crate) async fn read_query_stream(options: ReadQueryStreamOptions) {
592
589
  metadata,
593
590
  tx,
594
591
  retry_config,
595
- decode_pool,
596
592
  maintain_order,
597
593
  cancel_tx,
598
594
  mut cancel_rx,
599
595
  } = options;
600
- let decode_queue = DecodeQueue::new(Arc::clone(&decode_pool), maintain_order);
596
+ let decode_queue = DecodeQueue::new(maintain_order);
601
597
 
602
598
  if !enqueue_decode_batch(
603
599
  &decode_queue,
@@ -623,7 +619,6 @@ pub(crate) async fn read_query_stream(options: ReadQueryStreamOptions) {
623
619
  first_page_check: None,
624
620
  tx,
625
621
  retry_config,
626
- decode_pool,
627
622
  maintain_order,
628
623
  cancel_tx,
629
624
  cancel_rx,
@@ -651,7 +646,6 @@ pub(crate) mod tests {
651
646
 
652
647
  use super::*;
653
648
  use crate::bigquery_read_retry::RetryableErrors;
654
- use crate::decode::default_decode_pool;
655
649
 
656
650
  #[derive(Debug, Default)]
657
651
  pub(crate) struct RecordedReadRows {
@@ -906,7 +900,6 @@ pub(crate) mod tests {
906
900
  first_page_check: None,
907
901
  tx,
908
902
  retry_config: test_retry_config(3),
909
- decode_pool: default_decode_pool(),
910
903
  maintain_order: true,
911
904
  cancel_tx: Arc::new(cancel_tx),
912
905
  cancel_rx,
@@ -956,7 +949,6 @@ pub(crate) mod tests {
956
949
  first_page_check: None,
957
950
  tx,
958
951
  retry_config: test_retry_config(3),
959
- decode_pool: default_decode_pool(),
960
952
  maintain_order: false,
961
953
  cancel_tx: Arc::new(cancel_tx),
962
954
  cancel_rx,
@@ -999,7 +991,6 @@ pub(crate) mod tests {
999
991
  first_page_check: None,
1000
992
  tx,
1001
993
  retry_config: test_retry_config(3),
1002
- decode_pool: default_decode_pool(),
1003
994
  maintain_order: false,
1004
995
  cancel_tx: Arc::clone(&cancel_tx),
1005
996
  cancel_rx,
@@ -1054,7 +1045,6 @@ pub(crate) mod tests {
1054
1045
  first_page_check: None,
1055
1046
  tx,
1056
1047
  retry_config: test_retry_config(3),
1057
- decode_pool: default_decode_pool(),
1058
1048
  maintain_order: false,
1059
1049
  cancel_tx: Arc::clone(&cancel_tx),
1060
1050
  cancel_rx,
@@ -1112,7 +1102,6 @@ pub(crate) mod tests {
1112
1102
  first_page_check: None,
1113
1103
  tx,
1114
1104
  retry_config: test_retry_config(3),
1115
- decode_pool: default_decode_pool(),
1116
1105
  maintain_order: false,
1117
1106
  cancel_tx: Arc::clone(&cancel_tx),
1118
1107
  cancel_rx,
@@ -1143,15 +1132,17 @@ pub(crate) mod tests {
1143
1132
  )
1144
1133
  }
1145
1134
 
1135
+ type TestReadStream = (
1136
+ ReadStream,
1137
+ Arc<Mutex<Vec<ReadRowsRequest>>>,
1138
+ tokio::sync::mpsc::Receiver<Result<RecordBatch, BigQueryError>>,
1139
+ );
1140
+
1146
1141
  fn make_test_read_stream(
1147
1142
  streams: Vec<MockStreamResult>,
1148
1143
  metadata: Option<Arc<StreamMetadata>>,
1149
1144
  retry_config: StreamRetryConfig,
1150
- ) -> (
1151
- ReadStream,
1152
- Arc<Mutex<Vec<ReadRowsRequest>>>,
1153
- tokio::sync::mpsc::Receiver<Result<RecordBatch, BigQueryError>>,
1154
- ) {
1145
+ ) -> TestReadStream {
1155
1146
  let requests = Arc::new(Mutex::new(vec![]));
1156
1147
  let mock_client = MockClient {
1157
1148
  requests: Arc::clone(&requests),
@@ -1161,8 +1152,7 @@ pub(crate) mod tests {
1161
1152
  let read_rows = client.read_rows().set_read_stream("streams/1");
1162
1153
  let (tx, rx) = tokio::sync::mpsc::channel(10);
1163
1154
  let (cancel_tx, cancel_rx) = tokio::sync::watch::channel(false);
1164
- let decode_pool = default_decode_pool();
1165
- let decode_queue = DecodeQueue::new(Arc::clone(&decode_pool), false);
1155
+ let decode_queue = DecodeQueue::new(false);
1166
1156
  let reader = ReadStream::new(
1167
1157
  ReadStreamOptions {
1168
1158
  read_rows,
@@ -1172,7 +1162,6 @@ pub(crate) mod tests {
1172
1162
  first_page_check: None,
1173
1163
  tx,
1174
1164
  retry_config,
1175
- decode_pool,
1176
1165
  maintain_order: false,
1177
1166
  cancel_tx: Arc::new(cancel_tx),
1178
1167
  cancel_rx,
@@ -1,6 +1,6 @@
1
1
  use std::collections::VecDeque;
2
2
  use std::io::Cursor;
3
- use std::sync::{Arc, LazyLock, Mutex};
3
+ use std::sync::{Arc, Mutex};
4
4
 
5
5
  use polars_arrow::io::ipc::read::{
6
6
  read_stream_metadata, StreamMetadata, StreamReader, StreamState,
@@ -9,24 +9,6 @@ use polars_arrow::record_batch::RecordBatch;
9
9
 
10
10
  use crate::BigQueryError;
11
11
 
12
- static DEFAULT_DECODE_POOL: LazyLock<Arc<rayon::ThreadPool>> = LazyLock::new(|| {
13
- let num_threads = std::thread::available_parallelism()
14
- .map(|n| n.get())
15
- .unwrap_or(1);
16
- let pool = rayon::ThreadPoolBuilder::new()
17
- .num_threads(num_threads)
18
- .thread_name(|i| format!("arrow-bq-decode-{i}"))
19
- .build()
20
- .expect("failed to build Arrow IPC decode thread pool");
21
- Arc::new(pool)
22
- });
23
-
24
- /// Returns a handle to the shared bounded thread pool used for CPU-bound
25
- /// Arrow IPC (LZ4/ZSTD) decompression.
26
- pub(crate) fn default_decode_pool() -> Arc<rayon::ThreadPool> {
27
- Arc::clone(&DEFAULT_DECODE_POOL)
28
- }
29
-
30
12
  /// Parses IPC-serialized Arrow schema bytes into [`StreamMetadata`].
31
13
  pub(crate) fn parse_arrow_schema(schema_bytes: &[u8]) -> Result<StreamMetadata, BigQueryError> {
32
14
  let mut cursor = Cursor::new(schema_bytes);
@@ -150,14 +132,12 @@ struct OrderedQueueState {
150
132
  /// A FIFO decode queue that keeps all decode jobs for a `maintain_order = true`
151
133
  /// read in a single worker queue without work-stealing across workers.
152
134
  pub(crate) struct OrderedDecodeQueue {
153
- decode_pool: Arc<rayon::ThreadPool>,
154
135
  state: Mutex<OrderedQueueState>,
155
136
  }
156
137
 
157
138
  impl OrderedDecodeQueue {
158
- pub(crate) fn new(decode_pool: Arc<rayon::ThreadPool>) -> Arc<Self> {
139
+ pub(crate) fn new() -> Arc<Self> {
159
140
  Arc::new(Self {
160
- decode_pool,
161
141
  state: Mutex::new(OrderedQueueState {
162
142
  queue: VecDeque::new(),
163
143
  running: false,
@@ -179,7 +159,7 @@ impl OrderedDecodeQueue {
179
159
 
180
160
  if should_spawn {
181
161
  let queue = Arc::clone(self);
182
- self.decode_pool.spawn_fifo(move || {
162
+ rayon::spawn_fifo(move || {
183
163
  queue.drain();
184
164
  });
185
165
  }
@@ -204,25 +184,25 @@ impl OrderedDecodeQueue {
204
184
 
205
185
  #[derive(Clone)]
206
186
  pub(crate) enum DecodeQueue {
207
- /// Uses Rayon's work-stealing queue when `maintain_order = false`.
208
- WorkStealing(Arc<rayon::ThreadPool>),
187
+ /// Uses Rayon's global work-stealing pool when `maintain_order = false`.
188
+ WorkStealing,
209
189
  /// Keeps all decode jobs in a single sequential queue when `maintain_order = true`.
210
190
  Ordered(Arc<OrderedDecodeQueue>),
211
191
  }
212
192
 
213
193
  impl DecodeQueue {
214
- pub(crate) fn new(decode_pool: Arc<rayon::ThreadPool>, maintain_order: bool) -> Self {
194
+ pub(crate) fn new(maintain_order: bool) -> Self {
215
195
  if maintain_order {
216
- Self::Ordered(OrderedDecodeQueue::new(decode_pool))
196
+ Self::Ordered(OrderedDecodeQueue::new())
217
197
  } else {
218
- Self::WorkStealing(decode_pool)
198
+ Self::WorkStealing
219
199
  }
220
200
  }
221
201
 
222
202
  pub(crate) fn push(&self, job: DecodeJob) {
223
203
  match self {
224
- Self::WorkStealing(pool) => {
225
- pool.spawn_fifo(move || job.run());
204
+ Self::WorkStealing => {
205
+ rayon::spawn_fifo(move || job.run());
226
206
  },
227
207
  Self::Ordered(queue) => {
228
208
  queue.push(job);
@@ -240,13 +220,7 @@ mod tests {
240
220
 
241
221
  #[tokio::test]
242
222
  async fn test_ordered_decode_queue_preserves_batch_order() {
243
- let pool = Arc::new(
244
- rayon::ThreadPoolBuilder::new()
245
- .num_threads(4)
246
- .build()
247
- .unwrap(),
248
- );
249
- let queue = DecodeQueue::new(pool, true);
223
+ let queue = DecodeQueue::new(true);
250
224
 
251
225
  // Earlier batches are much larger than later ones so work-stealing would finish
252
226
  // the smaller batches first if they were not kept in the worker's ordered queue.
@@ -302,13 +276,7 @@ mod tests {
302
276
 
303
277
  #[tokio::test]
304
278
  async fn test_work_stealing_decode_queue_decodes_all_batches() {
305
- let pool = Arc::new(
306
- rayon::ThreadPoolBuilder::new()
307
- .num_threads(4)
308
- .build()
309
- .unwrap(),
310
- );
311
- let queue = DecodeQueue::new(pool, false);
279
+ let queue = DecodeQueue::new(false);
312
280
 
313
281
  let sizes = [20_000, 10, 15_000, 10, 10_000, 10];
314
282
  let mut schema_bytes = Vec::new();
@@ -358,13 +326,7 @@ mod tests {
358
326
 
359
327
  #[tokio::test]
360
328
  async fn test_decode_job_error_signals_cancellation_and_pushes_err() {
361
- let pool = Arc::new(
362
- rayon::ThreadPoolBuilder::new()
363
- .num_threads(2)
364
- .build()
365
- .unwrap(),
366
- );
367
- let queue = DecodeQueue::new(pool, true);
329
+ let queue = DecodeQueue::new(true);
368
330
 
369
331
  let (schema_bytes, valid_batch) = create_test_arrow_payload_with_range(0, 5);
370
332
  let metadata = Arc::new(parse_arrow_schema(&schema_bytes).unwrap());