Skip to content

Commit

Permalink
chore: adjust for new wren core
Browse files Browse the repository at this point in the history
  • Loading branch information
grieve54706 committed Nov 19, 2024
1 parent 8f7173f commit 966fe68
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 32 deletions.
42 changes: 21 additions & 21 deletions ibis-server/resources/function_list/postgres.csv
Original file line number Diff line number Diff line change
@@ -1,37 +1,37 @@
function_type,name,return_type,param_names,param_types,description
aggregate,every,boolean,,boolean,"Equivalent to bool_and"
aggregate,json_object_agg,json,,text&any,"Aggregates pairs into JSON object"
aggregate,jsonb_object_agg,jsonb,,text&any,"Aggregates pairs into JSONB object"
aggregate,json_object_agg,json,,"text,any","Aggregates pairs into JSON object"
aggregate,jsonb_object_agg,jsonb,,"text,any","Aggregates pairs into JSONB object"
aggregate,xmlagg,xml,,xml,"Concatenates XML values"
scalar,age,interval,,timestamp&timestamp,"Difference between timestamps"
scalar,array_lower,int,,array&integer,"Lower bound of array"
scalar,age,interval,,"timestamp,timestamp","Difference between timestamps"
scalar,array_lower,int,,"array,integer","Lower bound of array"
scalar,array_to_json,json,,array,"Convert array to JSON"
scalar,array_upper,int,,array&integer,"Upper bound of array"
scalar,convert_from,text,,bytea&text,"Convert from encoding"
scalar,convert_to,bytea,,text&text,"Convert to encoding"
scalar,extract,numeric,,text&timestamp,"Get subfield from date/time"
scalar,format,text,,text&any[],"Format string"
scalar,greatest,same as arg types,,any[],"Greatest of arguments"
scalar,array_upper,int,,"array,integer","Upper bound of array"
scalar,convert_from,text,,"bytea,text","Convert from encoding"
scalar,convert_to,bytea,,"text,text","Convert to encoding"
scalar,extract,numeric,,"text,timestamp","Get subfield from date/time"
scalar,format,text,,"text,array<any>","Format string"
scalar,greatest,same as arg types,,array<any>,"Greatest of arguments"
scalar,host,text,,inet,"Extract host from IP address"
scalar,isfinite,boolean,,timestamp,"Test for finite date/timestamp/interval"
scalar,json_array_length,int,,json,"Length of JSON array"
scalar,json_extract_path,json,,json&text[],"Get JSON object at path"
scalar,json_extract_path,json,,"json,array<text>","Get JSON object at path"
scalar,json_object_keys,setof text,,json,"Get JSON object keys"
scalar,jsonb_array_length,int,,jsonb,"Length of JSONB array"
scalar,jsonb_extract_path,jsonb,,jsonb&text[],"Get JSONB object at path"
scalar,jsonb_extract_path,jsonb,,"jsonb,array<text>","Get JSONB object at path"
scalar,jsonb_object_keys,setof text,,jsonb,"Get JSONB object keys"
scalar,least,same as arg types,,any[],"Least of arguments"
scalar,mod,numeric,,numeric&numeric,"Modulo (remainder)"
scalar,parse_ident,text[],,text&boolean,"Parse qualified identifier"
scalar,least,same as arg types,,array<any>,"Least of arguments"
scalar,mod,numeric,,"numeric,numeric","Modulo (remainder)"
scalar,parse_ident,array<text>,,"text,boolean","Parse qualified identifier"
scalar,pg_client_encoding,name,,,"Current client encoding"
scalar,pg_get_expr,text,,pg_node_tree&oid,"Decompile internal form of expression"
scalar,pg_get_viewdef,text,,oid,"Get view definition"
scalar,pg_get_expr,text,,"pg_node_tree,oid","Decompile internal form of expression"
scalar,pg_get_viewdef,text,,"oid","Get view definition"
scalar,quote_ident,text,,text,"Quote identifier"
scalar,quote_literal,text,,any,"Quote literal"
scalar,quote_nullable,text,,any,"Quote nullable"
scalar,regexp_split_to_array,text[],,text&text,"Split string by pattern"
scalar,regexp_split_to_table,setof text,,text&text,"Split string by pattern"
scalar,regexp_split_to_array,array<text>,,"text,text","Split string by pattern"
scalar,regexp_split_to_table,setof text,,"text,text","Split string by pattern"
scalar,sign,numeric,,numeric,"Sign of number"
scalar,to_json,json,,bool,"Convert to JSON"
scalar,to_number,numeric,,text&text,"Convert string to number"
scalar,to_json,json,,boolean,"Convert to JSON"
scalar,to_number,numeric,,"text,text","Convert string to number"
scalar,unistr,varchar,,text,"Postgres: Evaluate escaped Unicode characters in the argument"
19 changes: 9 additions & 10 deletions ibis-server/tests/routers/v3/connector/postgres/test_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,16 +62,15 @@ def test_function_list():
assert response.status_code == 200
result = response.json()
assert len(result) == DATAFUSION_FUNCTION_COUNT + 36
# It will be failed because Rust can not read CSV correctly
# the_func = next(filter(lambda x: x["name"] == "extract", result))
# assert the_func == {
# "name": "extract",
# "description": "Get subfield from date/time",
# "function_type": "scalar",
# "param_names": None,
# "param_types": "text&timestamp",
# "return_type": "numeric",
# }
the_func = next(filter(lambda x: x["name"] == "extract", result))
assert the_func == {
"name": "extract",
"description": "Get subfield from date/time",
"function_type": "scalar",
"param_names": None,
"param_types": "text,timestamp",
"return_type": "numeric",
}

config.set_remote_function_list_path(None)
response = client.get(url=f"{base_url}/functions")
Expand Down
4 changes: 3 additions & 1 deletion ibis-server/tests/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def parse(self) -> list[Function]:

@staticmethod
def _split_param(param: str) -> list[str]:
return param.split("&") if param else []
return param.split(",") if param else []


class SqlTestGenerator:
Expand All @@ -60,6 +60,8 @@ def generate_scalar_sql(self, function: Function) -> str:
args[0] = "'day'"
if function.name in ("json_array_length", "jsonb_array_length"):
args[0] = '\'[{"key": "value"}]\''
if function.name in ("json_extract_path", "jsonb_extract_path"):
args[1] = "'key'"
if function.name == "to_number":
args = ["'123'", "'999'"]
formatted_args = ", ".join(args)
Expand Down

0 comments on commit 966fe68

Please sign in to comment.