Skip to content

chore(ibis-bq): add timestamp function for BigQuery #1165

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 28, 2025
Merged
Show file tree
Hide file tree
Changes from all 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 @@ -17,6 +17,7 @@ scalar,timestamp_trunc,timestamp,,"timestamp,granularity","Truncates a timestamp
scalar,timestamp_micros,timestamp,,"int64","Converts the number of microseconds since 1970-01-01 00:00:00 UTC to a TIMESTAMP."
scalar,timestamp_millis,timestamp,,"int64","Converts the number of milliseconds since 1970-01-01 00:00:00 UTC to a TIMESTAMP."
scalar,timestamp_seconds,timestamp,,"int64","Converts the number of seconds since 1970-01-01 00:00:00 UTC to a TIMESTAMP."
scalar,timestamp,timestamp,,"text","Converts a string to a TIMESTAMP."
scalar,format_date,string,,"string,date","Formats a date according to the specified format string."
scalar,format_timestamp,string,,"string,timestamp","Formats a timestamp according to the specified format string."
scalar,parse_date,date,,"text,text","Parses a date from a string."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,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) == DATAFUSION_FUNCTION_COUNT + 34
assert len(result) == DATAFUSION_FUNCTION_COUNT + 35
the_func = next(
filter(
lambda x: x["name"] == "string_agg",
Expand Down
13 changes: 6 additions & 7 deletions ibis-server/tests/routers/v3/connector/bigquery/test_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,16 +78,16 @@ async def test_query(client, manifest_str, connection_info):
assert len(result["columns"]) == len(manifest["models"][0]["columns"])
assert len(result["data"]) == 1
assert result["data"][0] == [
36485,
1202,
"F",
"356711.63",
"1992-06-06 00:00:00.000000",
"36485_1202",
"2024-01-01 23:59:59.000000",
"2024-01-01 23:59:59.000000 UTC",
"2024-01-16 04:00:00.000000 UTC", # utc-5
"2024-07-16 03:00:00.000000 UTC", # utc-4
"36485_1202",
1202,
"1992-06-06 00:00:00.000000",
36485,
"F",
"356711.63",
]
assert result["dtypes"] == {
"o_orderkey": "int64",
Expand Down Expand Up @@ -141,7 +141,6 @@ async def test_query_with_invalid_manifest_str(client, connection_info):
},
)
assert response.status_code == 422
assert response.text == "Base64 decode error: Invalid padding"


async def test_query_without_manifest(client, connection_info):
Expand Down
2 changes: 1 addition & 1 deletion ibis-server/tools/query_local_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@

print("### Starting the session context ###")
print("#")
session_context = SessionContext(encoded_str, function_list_path)
session_context = SessionContext(encoded_str, function_list_path + f"{data_source}.csv")
planned_sql = session_context.transform_sql(sql)
print("# Planned SQL:\n", planned_sql)

Expand Down