Skip to content

Commit 2b9ab7d

Browse files
authored
Merge pull request #13 from bmsuisse/ts
support timestamp[ns]
2 parents ccba2e4 + fdc2a00 commit 2b9ab7d

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ build-backend = "maturin"
55
[project]
66
name = "lakeapi2sql"
77
requires-python = ">=3.10"
8-
version = "0.8.1"
8+
version = "0.8.2"
99
classifiers = [
1010
"Programming Language :: Rust",
1111
"Programming Language :: Python :: Implementation :: CPython",

src/arrow_convert.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ use arrow::array::StringArray;
1818
use arrow::array::Time32SecondArray;
1919
use arrow::array::TimestampMicrosecondArray;
2020
use arrow::array::TimestampMillisecondArray;
21+
use arrow::array::TimestampNanosecondArray;
2122
use arrow::array::UInt16Array;
2223
use arrow::array::UInt32Array;
2324
use arrow::array::UInt64Array;
@@ -194,6 +195,27 @@ pub(crate) fn get_token_rows<'a, 'b>(
194195
rowindex += 1;
195196
}
196197
}
198+
arrow::datatypes::DataType::Timestamp(arrow::datatypes::TimeUnit::Nanosecond, _) => {
199+
let ba = col
200+
.as_any()
201+
.downcast_ref::<TimestampNanosecondArray>()
202+
.unwrap();
203+
204+
let mut rowindex = 0;
205+
for val in ba.iter() {
206+
token_rows[rowindex].push(match val {
207+
Some(vs) => {
208+
if vs < 0 {
209+
ColumnData::DateTime2(None)
210+
} else {
211+
to_col_dt((unix_min + StdDuration::from_nanos(vs as u64)).to_sql())
212+
}
213+
}
214+
None => ColumnData::DateTime2(None),
215+
});
216+
rowindex += 1;
217+
}
218+
}
197219
arrow::datatypes::DataType::Null => {
198220
if coltype == &ColumnType::BigVarChar
199221
|| coltype == &ColumnType::Text

0 commit comments

Comments
 (0)