Skip to content

Commit

Permalink
feat(snowflake): implement TimestampFromYMDHMS
Browse files Browse the repository at this point in the history
  • Loading branch information
cpcloud committed Jan 19, 2023
1 parent 3292e91 commit 1eba8be
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
2 changes: 1 addition & 1 deletion ibis/backends/snowflake/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ def _map(_, op):
),
1,
),
ops.TimestampFromYMDHMS: fixed_arity(sa.func.timestamp_from_parts, 6),
}
)

Expand All @@ -256,7 +257,6 @@ def _map(_, op):
ops.IntervalFromInteger,
ops.TimestampDiff,
ops.TimestampFromUNIX,
ops.TimestampFromYMDHMS,
}

operation_registry = {
Expand Down
16 changes: 15 additions & 1 deletion ibis/backends/tests/test_temporal.py
Original file line number Diff line number Diff line change
Expand Up @@ -781,7 +781,7 @@ def test_date_literal(con):
assert result.strftime('%Y-%m-%d') == '2022-02-04'


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


@pytest.mark.notimpl(["pandas", "datafusion", "mysql", "dask", "pyspark"])
@pytest.mark.notyet(["clickhouse", "impala"])
def test_timestamp_column_from_ymdhms(con, alltypes, df):
c = alltypes.timestamp_col
expr = ibis.timestamp(
c.year(), c.month(), c.day(), c.hour(), c.minute(), c.second()
)
tbl = alltypes[expr.name('timestamp_col')]
result = con.execute(tbl)

golden = df.timestamp_col.dt.floor("s").astype('datetime64[ns]')
tm.assert_series_equal(golden, result.timestamp_col)


@pytest.mark.notimpl(["datafusion", "impala"])
def test_date_scalar_from_iso(con):
expr = ibis.literal('2022-02-24')
Expand Down
1 change: 1 addition & 0 deletions ibis/expr/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -585,6 +585,7 @@ def timestamp(
@timestamp.register(np.floating)
@timestamp.register(int)
@timestamp.register(float)
@timestamp.register(ir.IntegerValue)
def _timestamp_from_ymdhms(
value, *args, timezone: str | None = None
) -> ir.TimestampScalar:
Expand Down

0 comments on commit 1eba8be

Please sign in to comment.