Skip to content

Commit

Permalink
feat(snowflake): date from ymd
Browse files Browse the repository at this point in the history
  • Loading branch information
cpcloud committed Jan 19, 2023
1 parent 5aba997 commit 035f856
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 27 deletions.
2 changes: 1 addition & 1 deletion ibis/backends/snowflake/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ def _map(_, op):
ops.BitAnd: reduction(sa.func.bitand_agg),
ops.BitOr: reduction(sa.func.bitor_agg),
ops.BitXor: reduction(sa.func.bitxor_agg),
ops.DateFromYMD: fixed_arity(sa.func.date_from_parts, 3),
}
)

Expand All @@ -247,7 +248,6 @@ def _map(_, op):
# ibis.expr.operations.structs
ops.StructField,
# ibis.expr.operations.temporal
ops.DateFromYMD,
ops.ExtractMillisecond,
ops.IntervalFromInteger,
ops.StringToTimestamp,
Expand Down
28 changes: 13 additions & 15 deletions ibis/backends/tests/test_param.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,26 +135,24 @@ def test_scalar_param(alltypes, df, value, dtype, col):


@pytest.mark.parametrize(
("value", "dtype"),
[
param("2009-01-20", "date", id="string_date"),
param(datetime.date(2009, 1, 20), "date", id="date_date"),
param(datetime.datetime(2009, 1, 20), "date", id="datetime_date"),
],
)
@pytest.mark.notimpl(
["mysql", "polars", "dask", "datafusion", "sqlite", "impala", "mssql"]
"value",
["2009-01-20", datetime.date(2009, 1, 20), datetime.datetime(2009, 1, 20)],
ids=["string", "date", "datetime"],
)
def test_scalar_param_date(backend, alltypes, value, dtype):
param = ibis.param(dtype)
ds_col = alltypes.date_string_col.split("/")
month, day, year = ds_col[0], ds_col[1], ds_col[2]
date_col = ibis.literal("-").join(["20" + year, month, day]).cast(dtype)
@pytest.mark.notimpl(["datafusion"])
@pytest.mark.notyet(["impala"], reason="impala doesn't support dates")
def test_scalar_param_date(backend, alltypes, value):
param = ibis.param("date")
ds_col = alltypes.date_string_col
month = ds_col[:2]
day = ds_col[3:5]
year = "20" + ds_col[6:8]
date_col = (year + "-" + month + "-" + day).cast(param.type())

base = alltypes.mutate(date_col=date_col)
expr = (
alltypes.mutate(date_col=date_col)
.filter([lambda t: t.date_col == param])
.filter(lambda t: t.date_col == param)
.drop("date_col")
)

Expand Down
13 changes: 2 additions & 11 deletions ibis/backends/tests/test_temporal.py
Original file line number Diff line number Diff line change
Expand Up @@ -779,7 +779,7 @@ def test_now_from_projection(alltypes):
tm.assert_series_equal(ts.dt.year, year_expected)


@pytest.mark.notimpl(["pandas", "datafusion", "mysql", "dask", "pyspark", "snowflake"])
@pytest.mark.notimpl(["pandas", "datafusion", "mysql", "dask", "pyspark"])
@pytest.mark.notyet(["clickhouse", "impala"])
def test_date_literal(con):
expr = ibis.date(2022, 2, 4)
Expand Down Expand Up @@ -816,16 +816,7 @@ def test_time_literal(con):
assert str(result) == '16:20:00'


@pytest.mark.notimpl(
[
"pandas",
"datafusion",
"mysql",
"dask",
"pyspark",
"snowflake",
]
)
@pytest.mark.notimpl(["pandas", "datafusion", "mysql", "dask", "pyspark"])
@pytest.mark.notyet(["clickhouse", "impala"])
def test_date_column_from_ymd(con, alltypes, df):
c = alltypes.timestamp_col
Expand Down

0 comments on commit 035f856

Please sign in to comment.