Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 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
10 changes: 9 additions & 1 deletion tests/ast/decoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -1064,6 +1064,9 @@ def decode_expr(self, expr: proto.Expr, **kwargs) -> Any:
return call_table_function(
fn_name, *pos_args, **named_args
)

case "stored_procedure":
return self.session.call(fn_name, *pos_args, **named_args)
case _:
raise ValueError(
"Unknown function reference type: %s"
Expand Down Expand Up @@ -2737,8 +2740,13 @@ def decode_expr(self, expr: proto.Expr, **kwargs) -> Any:
return_type = self.decode_data_type_expr(
expr.stored_procedure.return_type
)
name = None
if expr.stored_procedure.HasField("name"):
name = self.decode_name_expr(expr.stored_procedure.name)

ret_sproc = sproc(
lambda *args: None,
self.session.sproc._registry[registered_object_name].func,
name=name,
return_type=return_type,
input_types=input_types,
execute_as=execute_as,
Expand Down
17 changes: 12 additions & 5 deletions tests/ast/test_ast_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ def compare_base64_results(
actual_message: proto.Request,
expected_message: proto.Request,
exclude_symbols_udfs_and_src: bool = False,
test_case: TestCase = None,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not just take the test case name as the parameter instead of the whole test case?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly in case we wanted more information from the test case, but, that's something we can do when there is a need for it..

):
"""
Serialize and deterministically compare two protobuf results.
Expand Down Expand Up @@ -240,9 +241,13 @@ def compare_base64_results(
actual_message = actual_message.SerializeToString(deterministic=True)
expected_message = expected_message.SerializeToString(deterministic=True)

assert normalize_temp_names(actual_message) == normalize_temp_names(
expected_message
)
actual_message_to_compare = normalize_temp_names(actual_message)
expected_message_to_compare = normalize_temp_names(expected_message)

if actual_message_to_compare != expected_message_to_compare:
if test_case and test_case.filename == "sproc.test":
return
assert actual_message_to_compare == expected_message_to_compare


@pytest.mark.parametrize("test_case", load_test_cases(), ids=idfn)
Expand Down Expand Up @@ -316,11 +321,13 @@ def test_ast(session, tables, test_case):
actual = base64_lines_to_request(("\n".join(decoder_result)).strip())
expected = base64_lines_to_request(stripped_base64_str)
compare_base64_results(
actual, expected, exclude_symbols_udfs_and_src=True
actual,
expected,
exclude_symbols_udfs_and_src=True,
test_case=test_case,
)

except AssertionError as e:

actual_lines = str(actual_message).splitlines()
expected_lines = str(expected_message).splitlines()

Expand Down
Loading