Skip to content

Commit

Permalink
add missed required function: current_datetime
Browse files Browse the repository at this point in the history
  • Loading branch information
goldmedal committed Nov 14, 2024
1 parent 6d7e9d0 commit 26f9ce0
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 8 deletions.
15 changes: 8 additions & 7 deletions ibis-server/resources/function_list/bigquery.csv
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ scalar,array_concat,ARRAY,"Concatenates multiple arrays into one."
scalar,array_to_string,STRING,"Converts an array to a single string."
scalar,generate_array,ARRAY,"Generates an array of values in a range."
scalar,generate_date_array,ARRAY,"Generates an array of dates in a range."
scalar,parse_timestamp,TIMESTAMP,"Parses a timestamp from a string."
scalar,parse_timestamp,TIMESTAMPTZ,"Parses a timestamp from a string."
scalar,string_to_array,ARRAY,"Splits a string into an array of substrings."
scalar,safe_divide,FLOAT64,"Divides two numbers, returning NULL if the divisor is zero."
scalar,safe_multiply,FLOAT64,"Multiplies two numbers, returning NULL if an overflow occurs."
Expand Down Expand Up @@ -74,17 +74,18 @@ scalar,substr,STRING,"Returns a substring."
scalar,cast,ANY,"Converts a value to a different data type."
scalar,safe_cast,ANY,"Converts a value to a different data type, returning NULL on error."
scalar,current_date,DATE,"Returns the current date."
scalar,current_datetime,TIMESTAMP,"Returns the current date."
scalar,date_add,DATE,"Adds a specified interval to a date."
scalar,date_sub,DATE,"Subtracts a specified interval from a date."
scalar,date_diff,INT64,"Returns the difference between two dates."
scalar,date_trunc,DATE,"Truncates a date to a specified granularity."
scalar,timestamp_add,TIMESTAMP,"Adds a specified interval to a timestamp."
scalar,timestamp_sub,TIMESTAMP,"Subtracts a specified interval from a timestamp."
scalar,timestamp_add,TIMESTAMPTZ,"Adds a specified interval to a timestamp."
scalar,timestamp_sub,TIMESTAMPTZ,"Subtracts a specified interval from a timestamp."
scalar,timestamp_diff,INT64,"Returns the difference between two timestamps."
scalar,timestamp_trunc,TIMESTAMP,"Truncates a timestamp to a specified granularity."
scalar,timestamp_micros,TIMESTAMP,"Converts the number of microseconds since 1970-01-01 00:00:00 UTC to a TIMESTAMP."
scalar,timestamp_millis,TIMESTAMP,"Converts the number of milliseconds since 1970-01-01 00:00:00 UTC to a TIMESTAMP."
scalar,timestamp_seconds,TIMESTAMP,"Converts the number of seconds since 1970-01-01 00:00:00 UTC to a TIMESTAMP."
scalar,timestamp_trunc,TIMESTAMPTZ,"Truncates a timestamp to a specified granularity."
scalar,timestamp_micros,TIMESTAMPTZ,"Converts the number of microseconds since 1970-01-01 00:00:00 UTC to a TIMESTAMP."
scalar,timestamp_millis,TIMESTAMPTZ,"Converts the number of milliseconds since 1970-01-01 00:00:00 UTC to a TIMESTAMP."
scalar,timestamp_seconds,TIMESTAMPTZ,"Converts the number of seconds since 1970-01-01 00:00:00 UTC to a TIMESTAMP."
scalar,format_date,STRING,"Formats a date according to the specified format string."
scalar,format_timestamp,STRING,"Formats a timestamp according to the specified format string."
scalar,parse_date,DATE,"Parses a date from a string."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def test_function_list():
response = client.get(url=f"{base_url}/functions")
assert response.status_code == 200
result = response.json()
assert len(result) == DATAFUSION_FUNCTION_COUNT + 33
assert len(result) == DATAFUSION_FUNCTION_COUNT + 34
the_func = next(filter(lambda x: x["name"] == "abs", result))
assert the_func == {
"name": "abs",
Expand Down
19 changes: 19 additions & 0 deletions ibis-server/tests/routers/v3/connector/bigquery/test_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,3 +237,22 @@ def test_timestamp_func(manifest_str, connection_info):
"micros": "object",
"seconds": "object",
}

response = client.post(
url=f"{base_url}/query",
json={
"connectionInfo": connection_info,
"manifestStr": manifest_str,
"sql": "SELECT timestamp with time zone '2000-01-01 10:00:00' < current_datetime() as compare",
},
)
assert response.status_code == 200
result = response.json()
assert len(result["columns"]) == 1
assert len(result["data"]) == 1
assert result["data"][0] == [
True,
]
assert result["dtypes"] == {
"compare": "bool",
}

0 comments on commit 26f9ce0

Please sign in to comment.