Skip to content

Commit ee74e3a

Browse files
krzysztof-kwittcpcloud
authored andcommitted
feat(clickhouse): implement ops.ExtractMillisecond
1 parent 05f5ae5 commit ee74e3a

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

ibis/backends/clickhouse/compiler/values.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1085,6 +1085,12 @@ def _fmt(op, _name: str = _name, **kw):
10851085
del _fmt, _name, _op
10861086

10871087

1088+
@translate_val.register(ops.ExtractMillisecond)
1089+
def _extract_millisecond(op, **kw):
1090+
arg = translate_val(op.arg, **kw)
1091+
return f"substring(formatDateTime({arg}, '%f'), 1, 3)"
1092+
1093+
10881094
@translate_val.register
10891095
def _sort_key(op: ops.SortKey, **kw):
10901096
arg = translate_val(op.expr, **kw)

ibis/backends/tests/test_temporal.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ def test_timestamp_extract_literal(con, func, expected):
9898
assert con.execute(func(value).name("tmp")) == expected
9999

100100

101-
@pytest.mark.notimpl(["datafusion", "clickhouse"])
101+
@pytest.mark.notimpl(["datafusion"])
102102
@pytest.mark.notyet(["sqlite", "pyspark"])
103103
def test_timestamp_extract_milliseconds(backend, alltypes, df):
104104
expr = alltypes.timestamp_col.millisecond().name("millisecond")
@@ -863,7 +863,7 @@ def test_date_column_from_iso(con, alltypes, df):
863863

864864

865865
@pytest.mark.notimpl(["datafusion"])
866-
@pytest.mark.notyet(["clickhouse", "pyspark"])
866+
@pytest.mark.notyet(["pyspark"])
867867
def test_timestamp_extract_milliseconds_with_big_value(con):
868868
timestamp = ibis.timestamp("2021-01-01 01:30:59.333456")
869869
millis = timestamp.millisecond()

0 commit comments

Comments
 (0)