Skip to content

Commit da40737

Browse files
committed
Merge remote-tracking branch 'origin' into build_for_wasm
2 parents 37bc573 + 22e742b commit da40737

File tree

21 files changed

+1073
-512
lines changed

21 files changed

+1073
-512
lines changed

.github/workflows/arrow.yml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ on:
3030
- arrow-buffer/**
3131
- arrow-data/**
3232
- arrow-schema/**
33+
- arrow-select/**
3334
- arrow-integration-test/**
3435
- .github/**
3536

@@ -61,6 +62,8 @@ jobs:
6162
run: cargo test -p arrow-schema --all-features
6263
- name: Test arrow-array with all features
6364
run: cargo test -p arrow-array --all-features
65+
- name: Test arrow-select with all features
66+
run: cargo test -p arrow-select --all-features
6467
- name: Test arrow-integration-test with all features
6568
run: cargo test -p arrow-integration-test --all-features
6669
- name: Test arrow
@@ -193,13 +196,15 @@ jobs:
193196
run: |
194197
rustup component add clippy
195198
- name: Clippy arrow-buffer with all features
196-
run: cargo clippy -p arrow-buffer --all-features
199+
run: cargo clippy -p arrow-buffer --all-targets --all-features
197200
- name: Clippy arrow-data with all features
198-
run: cargo clippy -p arrow-data --all-features
201+
run: cargo clippy -p arrow-data --all-targets --all-features
199202
- name: Clippy arrow-schema with all features
200-
run: cargo clippy -p arrow-schema --all-features
203+
run: cargo clippy -p arrow-schema --all-targets --all-features
201204
- name: Clippy arrow-array with all features
202-
run: cargo clippy -p arrow-array --all-features
205+
run: cargo clippy -p arrow-array --all-targets --all-features
206+
- name: Clippy arrow-select with all features
207+
run: cargo clippy -p arrow-select --all-targets --all-features
203208
- name: Clippy arrow
204209
run: |
205210
cargo clippy -p arrow --features=prettyprint,csv,ipc,test_utils,ffi,ipc_compression,dyn_cmp_dict,dyn_arith_dict --all-targets -- -D warnings

.github/workflows/arrow_flight.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ on:
3232
- arrow-buffer/**
3333
- arrow-data/**
3434
- arrow-schema/**
35+
- arrow-select/**
3536
- arrow-flight/**
3637
- .github/**
3738

.github/workflows/dev_pr/labeler.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ arrow:
2121
- arrow-buffer/**/*
2222
- arrow-data/**/*
2323
- arrow-schema/**/*
24+
- arrow-select/**/*
2425

2526
arrow-flight:
2627
- arrow-flight/**/*

.github/workflows/integration.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ on:
2929
- arrow-buffer/**
3030
- arrow-data/**
3131
- arrow-schema/**
32+
- arrow-select/**
3233
- arrow-pyarrow-integration-testing/**
3334
- arrow-integration-test/**
3435
- arrow-integration-testing/**

.github/workflows/miri.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ on:
2929
- arrow-buffer/**
3030
- arrow-data/**
3131
- arrow-schema/**
32+
- arrow-select/**
3233
- .github/**
3334

3435
jobs:

.github/workflows/parquet.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ on:
3232
- arrow-buffer/**
3333
- arrow-data/**
3434
- arrow-schema/**
35+
- arrow-select/**
3536
- parquet/**
3637
- .github/**
3738

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ members = [
2525
"arrow-integration-test",
2626
"arrow-integration-testing",
2727
"arrow-schema",
28+
"arrow-select",
2829
"parquet",
2930
"parquet_derive",
3031
"parquet_derive_test",

arrow-array/src/array/primitive_array.rs

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1362,11 +1362,24 @@ mod tests {
13621362
}
13631363

13641364
#[test]
1365-
#[should_panic(expected = "invalid time")]
13661365
fn test_time32second_invalid_neg() {
1367-
// The panic should come from chrono, not from arrow
1366+
// chrono::NaiveDatetime::from_timestamp_opt returns None while input is invalid
13681367
let arr: PrimitiveArray<Time32SecondType> = vec![-7201, -60054].into();
1369-
println!("{:?}", arr);
1368+
assert_eq!(
1369+
"PrimitiveArray<Time32(Second)>\n[\n null,\n null,\n]",
1370+
format!("{:?}", arr)
1371+
)
1372+
}
1373+
1374+
#[test]
1375+
fn test_timestamp_micros_out_of_range() {
1376+
// replicate the issue from https://github.com/apache/arrow-datafusion/issues/3832
1377+
let arr: PrimitiveArray<TimestampMicrosecondType> =
1378+
vec![9065525203050843594].into();
1379+
assert_eq!(
1380+
"PrimitiveArray<Timestamp(Microsecond, None)>\n[\n null,\n]",
1381+
format!("{:?}", arr)
1382+
)
13701383
}
13711384

13721385
#[test]

arrow-array/src/temporal_conversions.rs

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,16 @@ pub const EPOCH_DAYS_FROM_CE: i32 = 719_163;
3737

3838
/// converts a `i32` representing a `date32` to [`NaiveDateTime`]
3939
#[inline]
40-
pub fn date32_to_datetime(v: i32) -> NaiveDateTime {
41-
NaiveDateTime::from_timestamp(v as i64 * SECONDS_IN_DAY, 0)
40+
pub fn date32_to_datetime(v: i32) -> Option<NaiveDateTime> {
41+
NaiveDateTime::from_timestamp_opt(v as i64 * SECONDS_IN_DAY, 0)
4242
}
4343

4444
/// converts a `i64` representing a `date64` to [`NaiveDateTime`]
4545
#[inline]
46-
pub fn date64_to_datetime(v: i64) -> NaiveDateTime {
46+
pub fn date64_to_datetime(v: i64) -> Option<NaiveDateTime> {
4747
let (sec, milli_sec) = split_second(v, MILLISECONDS);
4848

49-
NaiveDateTime::from_timestamp(
49+
NaiveDateTime::from_timestamp_opt(
5050
// extract seconds from milliseconds
5151
sec,
5252
// discard extracted seconds and convert milliseconds to nanoseconds
@@ -56,15 +56,15 @@ pub fn date64_to_datetime(v: i64) -> NaiveDateTime {
5656

5757
/// converts a `i32` representing a `time32(s)` to [`NaiveDateTime`]
5858
#[inline]
59-
pub fn time32s_to_time(v: i32) -> NaiveTime {
60-
NaiveTime::from_num_seconds_from_midnight(v as u32, 0)
59+
pub fn time32s_to_time(v: i32) -> Option<NaiveTime> {
60+
NaiveTime::from_num_seconds_from_midnight_opt(v as u32, 0)
6161
}
6262

6363
/// converts a `i32` representing a `time32(ms)` to [`NaiveDateTime`]
6464
#[inline]
65-
pub fn time32ms_to_time(v: i32) -> NaiveTime {
65+
pub fn time32ms_to_time(v: i32) -> Option<NaiveTime> {
6666
let v = v as i64;
67-
NaiveTime::from_num_seconds_from_midnight(
67+
NaiveTime::from_num_seconds_from_midnight_opt(
6868
// extract seconds from milliseconds
6969
(v / MILLISECONDS) as u32,
7070
// discard extracted seconds and convert milliseconds to
@@ -75,8 +75,8 @@ pub fn time32ms_to_time(v: i32) -> NaiveTime {
7575

7676
/// converts a `i64` representing a `time64(us)` to [`NaiveDateTime`]
7777
#[inline]
78-
pub fn time64us_to_time(v: i64) -> NaiveTime {
79-
NaiveTime::from_num_seconds_from_midnight(
78+
pub fn time64us_to_time(v: i64) -> Option<NaiveTime> {
79+
NaiveTime::from_num_seconds_from_midnight_opt(
8080
// extract seconds from microseconds
8181
(v / MICROSECONDS) as u32,
8282
// discard extracted seconds and convert microseconds to
@@ -87,8 +87,8 @@ pub fn time64us_to_time(v: i64) -> NaiveTime {
8787

8888
/// converts a `i64` representing a `time64(ns)` to [`NaiveDateTime`]
8989
#[inline]
90-
pub fn time64ns_to_time(v: i64) -> NaiveTime {
91-
NaiveTime::from_num_seconds_from_midnight(
90+
pub fn time64ns_to_time(v: i64) -> Option<NaiveTime> {
91+
NaiveTime::from_num_seconds_from_midnight_opt(
9292
// extract seconds from nanoseconds
9393
(v / NANOSECONDS) as u32,
9494
// discard extracted seconds
@@ -98,16 +98,16 @@ pub fn time64ns_to_time(v: i64) -> NaiveTime {
9898

9999
/// converts a `i64` representing a `timestamp(s)` to [`NaiveDateTime`]
100100
#[inline]
101-
pub fn timestamp_s_to_datetime(v: i64) -> NaiveDateTime {
102-
NaiveDateTime::from_timestamp(v, 0)
101+
pub fn timestamp_s_to_datetime(v: i64) -> Option<NaiveDateTime> {
102+
NaiveDateTime::from_timestamp_opt(v, 0)
103103
}
104104

105105
/// converts a `i64` representing a `timestamp(ms)` to [`NaiveDateTime`]
106106
#[inline]
107-
pub fn timestamp_ms_to_datetime(v: i64) -> NaiveDateTime {
107+
pub fn timestamp_ms_to_datetime(v: i64) -> Option<NaiveDateTime> {
108108
let (sec, milli_sec) = split_second(v, MILLISECONDS);
109109

110-
NaiveDateTime::from_timestamp(
110+
NaiveDateTime::from_timestamp_opt(
111111
// extract seconds from milliseconds
112112
sec,
113113
// discard extracted seconds and convert milliseconds to nanoseconds
@@ -117,10 +117,10 @@ pub fn timestamp_ms_to_datetime(v: i64) -> NaiveDateTime {
117117

118118
/// converts a `i64` representing a `timestamp(us)` to [`NaiveDateTime`]
119119
#[inline]
120-
pub fn timestamp_us_to_datetime(v: i64) -> NaiveDateTime {
120+
pub fn timestamp_us_to_datetime(v: i64) -> Option<NaiveDateTime> {
121121
let (sec, micro_sec) = split_second(v, MICROSECONDS);
122122

123-
NaiveDateTime::from_timestamp(
123+
NaiveDateTime::from_timestamp_opt(
124124
// extract seconds from microseconds
125125
sec,
126126
// discard extracted seconds and convert microseconds to nanoseconds
@@ -130,10 +130,10 @@ pub fn timestamp_us_to_datetime(v: i64) -> NaiveDateTime {
130130

131131
/// converts a `i64` representing a `timestamp(ns)` to [`NaiveDateTime`]
132132
#[inline]
133-
pub fn timestamp_ns_to_datetime(v: i64) -> NaiveDateTime {
133+
pub fn timestamp_ns_to_datetime(v: i64) -> Option<NaiveDateTime> {
134134
let (sec, nano_sec) = split_second(v, NANOSECONDS);
135135

136-
NaiveDateTime::from_timestamp(
136+
NaiveDateTime::from_timestamp_opt(
137137
// extract seconds from nanoseconds
138138
sec, // discard extracted seconds
139139
nano_sec,
@@ -172,14 +172,14 @@ pub fn duration_ns_to_duration(v: i64) -> Duration {
172172
/// Converts an [`ArrowPrimitiveType`] to [`NaiveDateTime`]
173173
pub fn as_datetime<T: ArrowPrimitiveType>(v: i64) -> Option<NaiveDateTime> {
174174
match T::DATA_TYPE {
175-
DataType::Date32 => Some(date32_to_datetime(v as i32)),
176-
DataType::Date64 => Some(date64_to_datetime(v)),
175+
DataType::Date32 => date32_to_datetime(v as i32),
176+
DataType::Date64 => date64_to_datetime(v),
177177
DataType::Time32(_) | DataType::Time64(_) => None,
178178
DataType::Timestamp(unit, _) => match unit {
179-
TimeUnit::Second => Some(timestamp_s_to_datetime(v)),
180-
TimeUnit::Millisecond => Some(timestamp_ms_to_datetime(v)),
181-
TimeUnit::Microsecond => Some(timestamp_us_to_datetime(v)),
182-
TimeUnit::Nanosecond => Some(timestamp_ns_to_datetime(v)),
179+
TimeUnit::Second => timestamp_s_to_datetime(v),
180+
TimeUnit::Millisecond => timestamp_ms_to_datetime(v),
181+
TimeUnit::Microsecond => timestamp_us_to_datetime(v),
182+
TimeUnit::Nanosecond => timestamp_ns_to_datetime(v),
183183
},
184184
// interval is not yet fully documented [ARROW-3097]
185185
DataType::Interval(_) => None,
@@ -199,14 +199,14 @@ pub fn as_time<T: ArrowPrimitiveType>(v: i64) -> Option<NaiveTime> {
199199
// safe to immediately cast to u32 as `self.value(i)` is positive i32
200200
let v = v as u32;
201201
match unit {
202-
TimeUnit::Second => Some(time32s_to_time(v as i32)),
203-
TimeUnit::Millisecond => Some(time32ms_to_time(v as i32)),
202+
TimeUnit::Second => time32s_to_time(v as i32),
203+
TimeUnit::Millisecond => time32ms_to_time(v as i32),
204204
_ => None,
205205
}
206206
}
207207
DataType::Time64(unit) => match unit {
208-
TimeUnit::Microsecond => Some(time64us_to_time(v)),
209-
TimeUnit::Nanosecond => Some(time64ns_to_time(v)),
208+
TimeUnit::Microsecond => time64us_to_time(v),
209+
TimeUnit::Nanosecond => time64ns_to_time(v),
210210
_ => None,
211211
},
212212
DataType::Timestamp(_, _) => as_datetime::<T>(v).map(|datetime| datetime.time()),
@@ -241,51 +241,51 @@ mod tests {
241241
fn negative_input_timestamp_ns_to_datetime() {
242242
assert_eq!(
243243
timestamp_ns_to_datetime(-1),
244-
NaiveDateTime::from_timestamp(-1, 999_999_999)
244+
NaiveDateTime::from_timestamp_opt(-1, 999_999_999)
245245
);
246246

247247
assert_eq!(
248248
timestamp_ns_to_datetime(-1_000_000_001),
249-
NaiveDateTime::from_timestamp(-2, 999_999_999)
249+
NaiveDateTime::from_timestamp_opt(-2, 999_999_999)
250250
);
251251
}
252252

253253
#[test]
254254
fn negative_input_timestamp_us_to_datetime() {
255255
assert_eq!(
256256
timestamp_us_to_datetime(-1),
257-
NaiveDateTime::from_timestamp(-1, 999_999_000)
257+
NaiveDateTime::from_timestamp_opt(-1, 999_999_000)
258258
);
259259

260260
assert_eq!(
261261
timestamp_us_to_datetime(-1_000_001),
262-
NaiveDateTime::from_timestamp(-2, 999_999_000)
262+
NaiveDateTime::from_timestamp_opt(-2, 999_999_000)
263263
);
264264
}
265265

266266
#[test]
267267
fn negative_input_timestamp_ms_to_datetime() {
268268
assert_eq!(
269269
timestamp_ms_to_datetime(-1),
270-
NaiveDateTime::from_timestamp(-1, 999_000_000)
270+
NaiveDateTime::from_timestamp_opt(-1, 999_000_000)
271271
);
272272

273273
assert_eq!(
274274
timestamp_ms_to_datetime(-1_001),
275-
NaiveDateTime::from_timestamp(-2, 999_000_000)
275+
NaiveDateTime::from_timestamp_opt(-2, 999_000_000)
276276
);
277277
}
278278

279279
#[test]
280280
fn negative_input_date64_to_datetime() {
281281
assert_eq!(
282282
date64_to_datetime(-1),
283-
NaiveDateTime::from_timestamp(-1, 999_000_000)
283+
NaiveDateTime::from_timestamp_opt(-1, 999_000_000)
284284
);
285285

286286
assert_eq!(
287287
date64_to_datetime(-1_001),
288-
NaiveDateTime::from_timestamp(-2, 999_000_000)
288+
NaiveDateTime::from_timestamp_opt(-2, 999_000_000)
289289
);
290290
}
291291

arrow-select/Cargo.toml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
[package]
19+
name = "arrow-select"
20+
version = "25.0.0"
21+
description = "Selection kernels for arrow arrays"
22+
homepage = "https://github.com/apache/arrow-rs"
23+
repository = "https://github.com/apache/arrow-rs"
24+
authors = ["Apache Arrow <[email protected]>"]
25+
license = "Apache-2.0"
26+
keywords = ["arrow"]
27+
include = [
28+
"benches/*.rs",
29+
"src/**/*.rs",
30+
"Cargo.toml",
31+
]
32+
edition = "2021"
33+
rust-version = "1.62"
34+
35+
[lib]
36+
name = "arrow_select"
37+
path = "src/lib.rs"
38+
bench = false
39+
40+
[dependencies]
41+
arrow-buffer = { version = "25.0.0", path = "../arrow-buffer" }
42+
arrow-data = { version = "25.0.0", path = "../arrow-data" }
43+
arrow-schema = { version = "25.0.0", path = "../arrow-schema" }
44+
arrow-array = { version = "25.0.0", path = "../arrow-array" }
45+
num = { version = "0.4", default-features = false, features = ["std"] }
46+
47+
[features]
48+
default = []
49+
50+
[dev-dependencies]
51+
rand = { version = "0.8", default-features = false, features = ["std", "std_rng"] }

0 commit comments

Comments
 (0)