Skip to content

Commit f51382c

Browse files
SNOW-3071754: use internal describe for getting return type of sp (#4113)
1 parent 54605e9 commit f51382c

3 files changed

Lines changed: 24 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212
- Fixed a bug when saving a fdn table into an iceberg table in overwrite mode, error is raised because `StringType` is saved in wrong length.
1313
- Fixed a bug in `ai_complete` where `model_parameters` and `response_format` values containing single quotes would generate malformed SQL.
1414

15+
#### Improvements
16+
17+
- Use internal describe to get return type when executing a stored procedure.
18+
1519
## 1.47.0 (2026-03-05)
1620

1721
### Snowpark Python API Updates

src/snowflake/snowpark/session.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4509,10 +4509,11 @@ def _infer_is_return_table(
45094509
# describe procedure returns two column table with columns - property and value
45104510
# the second row in the sproc_desc is property=returns and value=<return type of procedure>
45114511
# when no procedure of the signature is found, SQL exception is raised
4512-
sproc_desc = self._run_query(
4512+
sproc_desc = self._conn.run_query(
45134513
f"describe procedure {func_signature}",
4514+
_is_internal=True,
45144515
log_on_exception=log_on_exception,
4515-
)
4516+
)["data"]
45164517
return_type = sproc_desc[1][1]
45174518
return return_type.upper().startswith("TABLE")
45184519
except Exception as exc:

tests/unit/test_session.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -774,6 +774,23 @@ def test_get_default_artifact_repository():
774774

775775
assert mocked_run_query.call_count == 1
776776

777+
778+
def test_infer_is_return_table_uses_internal_describe():
779+
fake_server_connection = mock.create_autospec(ServerConnection)
780+
fake_server_connection._thread_safe_session_enabled = True
781+
fake_server_connection.run_query = MagicMock(
782+
return_value={"data": [("signature", "dummy"), ("returns", "TABLE (A NUMBER)")]}
783+
)
784+
session = Session(fake_server_connection)
785+
786+
assert session._infer_is_return_table("test_proc") is True
787+
788+
fake_server_connection.run_query.assert_called_once_with(
789+
"describe procedure TEST_PROC()",
790+
_is_internal=True,
791+
log_on_exception=False,
792+
)
793+
777794
with mock.patch.object(
778795
session, "_run_query", side_effect=ProgrammingError("Not found")
779796
) as mocked_run_query, mock.patch.object(

0 commit comments

Comments
 (0)