8000 add to_timestamp_nanos (#1020) · nirnayroy/datafusion-python@40a61c1 · GitHub
[go: up one dir, main page]

Skip to content

Commit 40a61c1

Browse files
authored
add to_timestamp_nanos (apache#1020)
1 parent d635d56 commit 40a61c1

File tree

3 files changed

+7
-0
lines changed

3 files changed

+7
-0
lines changed

python/datafusion/functions.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,7 @@
252252
"to_hex",
253253
"to_timestamp",
254254
"to_timestamp_micros",
255+
"to_timestamp_nanos",
255256
"to_timestamp_millis",
256257
"to_timestamp_seconds",
257258
"to_unixtime",

python/tests/test_functions.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -871,6 +871,7 @@ def test_temporal_functions(df):
871871
f.to_timestamp_millis(literal("2023-09-07 05:06:14.523952")),
872872
f.to_timestamp_micros(literal("2023-09-07 05:06:14.523952")),
873873
f.extract(literal("day"), column("d")),
874+
f.to_timestamp_nanos(literal("2023-09-07 05:06:14.523952")),
874875
)
875876
result = df.collect()
876877
assert len(result) == 1
@@ -909,6 +910,9 @@ def test_temporal_functions(df):
909910
[datetime(2023, 9, 7, 5, 6, 14, 523952)] * 3, type=pa.timestamp("us")
910911
)
911912
assert result.column(10) == pa.array([31, 26, 2], type=pa.int32())
913+
assert result.column(11) == pa.array(
914+
[datetime(2023, 9, 7, 5, 6, 14, 523952)] * 3, type=pa.timestamp("ns")
915+
)
912916

913917

914918
def test_arrow_cast(df):

src/functions.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -553,6 +553,7 @@ expr_fn!(
553553
expr_fn!(now);
554554
expr_fn_vec!(to_timestamp);
555555
expr_fn_vec!(to_timestamp_millis);
556+
expr_fn_vec!(to_timestamp_nanos);
556557
expr_fn_vec!(to_timestamp_micros);
557558
expr_fn_vec!(to_timestamp_seconds);
558559
expr_fn_vec!(to_unixtime);
@@ -977,6 +978,7 @@ pub(crate) fn init_module(m: &Bound<'_, PyModule>) -> PyResult<()> {
977978
m.add_wrapped(wrap_pyfunction!(to_hex))?;
978979
m.add_wrapped(wrap_pyfunction!(to_timestamp))?;
979980
m.add_wrapped(wrap_pyfunction!(to_timestamp_millis))?;
981+
m.add_wrapped(wrap_pyfunction!(to_timestamp_nanos))?;
980982
m.add_wrapped(wrap_pyfunction!(to_timestamp_micros))?;
981983
m.add_wrapped(wrap_pyfunction!(to_timestamp_seconds))?;
982984
m.add_wrapped(wrap_pyfunction!(to_unixtime))?;

0 commit comments

Comments
 (0)
0