Skip to content

Commit

Permalink
test(clickhouse): add test for aliasing (#9813)
Browse files Browse the repository at this point in the history
  • Loading branch information
cpcloud authored Aug 10, 2024
1 parent 7a2938b commit 36f5162
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions ibis/backends/clickhouse/tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -409,3 +409,19 @@ def test_subquery_with_join(con):
expr = s.join(w, "a").select(a=w.a).select(b=lambda t: t.a + 1)
result = expr.to_pandas()
assert set(result["b"].tolist()) == {2, 3, 4}


def test_alias_column_ref(con):
data = {"user_id": [1, 2, 3], "account_id": [4, 5, 6]}
t = con.create_table(gen_name("clickhouse_temp_table"), data, temp=True)
expr = t.alias("df").sql("select *, halfMD5(account_id) as id_md5 from df")

result = expr.execute()

assert len(result) == 3

assert result.columns.tolist() == ["user_id", "account_id", "id_md5"]

assert result.user_id.notnull().all()
assert result.account_id.notnull().all()
assert result.id_md5.notnull().all()

0 comments on commit 36f5162

Please sign in to comment.