Skip to content

Commit 1eba8be

Browse files
committed
feat(snowflake): implement TimestampFromYMDHMS
1 parent 3292e91 commit 1eba8be

File tree

3 files changed

+17
-2
lines changed

3 files changed

+17
-2
lines changed

ibis/backends/snowflake/registry.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,7 @@ def _map(_, op):
233233
),
234234
1,
235235
),
236+
ops.TimestampFromYMDHMS: fixed_arity(sa.func.timestamp_from_parts, 6),
236237
}
237238
)
238239

@@ -256,7 +257,6 @@ def _map(_, op):
256257
ops.IntervalFromInteger,
257258
ops.TimestampDiff,
258259
ops.TimestampFromUNIX,
259-
ops.TimestampFromYMDHMS,
260260
}
261261

262262
operation_registry = {

ibis/backends/tests/test_temporal.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -781,7 +781,7 @@ def test_date_literal(con):
781781
assert result.strftime('%Y-%m-%d') == '2022-02-04'
782782

783783

784-
@pytest.mark.notimpl(["pandas", "datafusion", "mysql", "dask", "pyspark", "snowflake"])
784+
@pytest.mark.notimpl(["pandas", "datafusion", "mysql", "dask", "pyspark"])
785785
@pytest.mark.notyet(["clickhouse", "impala"])
786786
def test_timestamp_literal(con):
787787
expr = ibis.timestamp(2022, 2, 4, 16, 20, 0)
@@ -824,6 +824,20 @@ def test_date_column_from_ymd(con, alltypes, df):
824824
tm.assert_series_equal(golden, result.timestamp_col)
825825

826826

827+
@pytest.mark.notimpl(["pandas", "datafusion", "mysql", "dask", "pyspark"])
828+
@pytest.mark.notyet(["clickhouse", "impala"])
829+
def test_timestamp_column_from_ymdhms(con, alltypes, df):
830+
c = alltypes.timestamp_col
831+
expr = ibis.timestamp(
832+
c.year(), c.month(), c.day(), c.hour(), c.minute(), c.second()
833+
)
834+
tbl = alltypes[expr.name('timestamp_col')]
835+
result = con.execute(tbl)
836+
837+
golden = df.timestamp_col.dt.floor("s").astype('datetime64[ns]')
838+
tm.assert_series_equal(golden, result.timestamp_col)
839+
840+
827841
@pytest.mark.notimpl(["datafusion", "impala"])
828842
def test_date_scalar_from_iso(con):
829843
expr = ibis.literal('2022-02-24')

ibis/expr/api.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -585,6 +585,7 @@ def timestamp(
585585
@timestamp.register(np.floating)
586586
@timestamp.register(int)
587587
@timestamp.register(float)
588+
@timestamp.register(ir.IntegerValue)
588589
def _timestamp_from_ymdhms(
589590
value, *args, timezone: str | None = None
590591
) -> ir.TimestampScalar:

0 commit comments

Comments
 (0)