Skip to content
This repository was archived by the owner on May 7, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ibis-server/resources/function_list/bigquery.csv
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ scalar,current_timestamp,timestamptz,,"","Returns current timestamp."
scalar,date_add,date,,"date,int64","Adds a number of day to a date."
scalar,date_sub,date,,"date,interval","Subtracts a specified interval from a date."
scalar,date_diff,int64,,"date,date,granularity","Returns the difference between two dates."
scalar,datediff,int64,,"date,date,granularity","Returns the difference between two dates."
scalar,timestamp_add,timestamp,,"timestamp,granularity","Adds a specified interval to a timestamp."
scalar,timestamp_sub,timestamp,,"timestamp,granularity","Subtracts a specified interval from a timestamp."
scalar,timestamp_diff,int64,,"timestamp,timestamp,granularity","Returns the difference between two timestamps."
Expand Down
1 change: 1 addition & 0 deletions ibis-server/resources/white_function_list/bigquery.csv
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ scalar,current_datetime,timestamp,,"","Returns current date and time."
scalar,date_add,date,,"date,int64","Adds a number of day to a date."
scalar,date_sub,date,,"date,interval","Subtracts a specified interval from a date."
scalar,date_diff,int64,,"date,date,granularity","Returns the difference between two dates."
scalar,datediff,int64,,"date,date,granularity","Returns the difference between two dates."
scalar,timestamp_add,timestamp,,"timestamp,granularity","Adds a specified interval to a timestamp."
scalar,timestamp_sub,timestamp,,"timestamp,granularity","Subtracts a specified interval from a timestamp."
scalar,timestamp_diff,int64,,"timestamp,timestamp,granularity","Returns the difference between two timestamps."
Expand Down
2 changes: 1 addition & 1 deletion ibis-server/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def file_path(path: str) -> str:
return os.path.join(os.path.dirname(__file__), path)


DATAFUSION_FUNCTION_COUNT = 283
DATAFUSION_FUNCTION_COUNT = 285


@pytest.fixture(scope="session")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
},
"columns": [
{"name": "o_orderkey", "type": "integer"},
{"name": "o_orderdate", "type": "date"},
],
},
],
Expand Down Expand Up @@ -52,7 +53,7 @@ async def test_function_list(client):
response = await client.get(url=f"{base_url}/functions")
assert response.status_code == 200
result = response.json()
assert len(result) == 175
assert len(result) == 176
the_func = next(
filter(
lambda x: x["name"] == "string_agg",
Expand Down Expand Up @@ -160,3 +161,85 @@ async def test_datetime_function(client, manifest_str: str, connection_info):
"data": [["2001-01-01 00:11:11.000000"]],
"dtypes": {"col": "timestamp[us]"},
}


async def test_date_diff_function(client, manifest_str: str, connection_info):
response = await client.post(
url=f"{base_url}/query",
json={
"connectionInfo": connection_info,
"manifestStr": manifest_str,
"sql": "SELECT DATE_DIFF(DAY, CURRENT_DATE(), o_orderdate) AS col FROM orders LIMIT 1",
},
)

assert response.status_code == 200
result = response.json()
assert result == {
"columns": ["col"],
"data": [[result["data"][0][0]]],
"dtypes": {"col": "int64"},
}

response = await client.post(
url=f"{base_url}/query",
json={
"connectionInfo": connection_info,
"manifestStr": manifest_str,
"sql": "SELECT DATEDIFF(DAY, CURRENT_DATE(), o_orderdate) AS col FROM orders LIMIT 1",
},
)

assert response.status_code == 200
result = response.json()
assert result == {
"columns": ["col"],
"data": [[result["data"][0][0]]],
"dtypes": {"col": "int64"},
}

response = await client.post(
url=f"{base_url}/query",
json={
"connectionInfo": connection_info,
"manifestStr": manifest_str,
"sql": "SELECT DATEDIFF('DAY', CURRENT_DATE(), o_orderdate) AS col FROM orders LIMIT 1",
},
)

assert response.status_code == 200
result = response.json()
assert result == {
"columns": ["col"],
"data": [[result["data"][0][0]]],
"dtypes": {"col": "int64"},
}

response = await client.post(
url=f"{base_url}/query",
json={
"connectionInfo": connection_info,
"manifestStr": manifest_str,
"sql": "SELECT DATEDIFF('DAYS', CURRENT_DATE(), o_orderdate) AS col FROM orders LIMIT 1",
},
)

assert response.status_code == 422
assert "Unsupported date part 'DAYS' for BIGQUERY." in response.text

response = await client.post(
url=f"{base_url}/query",
json={
"connectionInfo": connection_info,
"manifestStr": manifest_str,
"sql": "SELECT DATEDIFF('HOUR', CURRENT_TIMESTAMP(), TIMESTAMP WITH TIME ZONE '2025-01-01 00:00:00') AS col FROM orders LIMIT 1",
},
)

assert response.status_code == 200
result = response.json()
assert result == {
"columns": ["col"],
"data": [[result["data"][0][0]]],
"dtypes": {"col": "int64"},
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ async def test_function_list(client):
assert response.status_code == 200
result = response.json()
# 429 is the number of functions in `resources/function_list/duckdb.csv` file excluded the default functions in DataFusion.
assert len(result) == DATAFUSION_FUNCTION_COUNT + 427
assert len(result) == DATAFUSION_FUNCTION_COUNT + 425
Comment thread
goldmedal marked this conversation as resolved.
the_func = next(filter(lambda x: x["name"] == "regexp_escape", result))
assert the_func == {
"name": "regexp_escape",
Expand Down
58 changes: 29 additions & 29 deletions wren-core-py/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading