Skip to content

Commit

Permalink
fix(sqlite): ensure ibis.uuid() generates a unique uuid per row (#8535
Browse files Browse the repository at this point in the history
)

Fixes part of #8532.
  • Loading branch information
jcrist authored Mar 4, 2024
1 parent e8bc3b9 commit c097a2d
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion ibis/backends/sqlite/udf.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ def pi():
return math.pi


@udf(skip_if_exists=True)
@udf(skip_if_exists=True, deterministic=False)
def uuid():
return str(uuid4())

Expand Down
23 changes: 23 additions & 0 deletions ibis/backends/tests/test_uuid.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,26 @@ def test_uuid_function(con):
obj = con.execute(ibis.uuid())
assert isinstance(obj, uuid.UUID)
assert obj.version == 4


@pytest.mark.notimpl(
[
"datafusion",
"druid",
"exasol",
"flink",
"mssql",
"mysql",
"oracle",
"polars",
"pyspark",
"risingwave",
],
raises=com.OperationNotDefinedError,
)
@pytest.mark.notimpl(["pandas", "dask"], raises=ValueError)
def test_uuid_unique_each_row(con):
expr = (
con.tables.functional_alltypes.mutate(uuid=ibis.uuid()).limit(2).uuid.nunique()
)
assert expr.execute() == 2

0 comments on commit c097a2d

Please sign in to comment.