Skip to content

SNOW-2267482: Fix flakiness due to SnowAPI dependency#4190

Open
sfc-gh-yuwang wants to merge 33 commits into
mainfrom
SNOW-2267482
Open

SNOW-2267482: Fix flakiness due to SnowAPI dependency#4190
sfc-gh-yuwang wants to merge 33 commits into
mainfrom
SNOW-2267482

Conversation

@sfc-gh-yuwang
Copy link
Copy Markdown
Collaborator

@sfc-gh-yuwang sfc-gh-yuwang commented Apr 21, 2026

  1. Which Jira issue is this PR addressing? Make sure that there is an accompanying issue to your PR.

    Fixes SNOW-2267482

  2. Fill out the following pre-review checklist:

    • I am adding a new automated test(s) to verify correctness of my new code
      • If this test skips Local Testing mode, I'm requesting review from @snowflakedb/local-testing
    • I am adding new logging messages
    • I am adding a new telemetry message
    • I am adding new credentials
    • I am adding a new dependency
    • If this is a new feature/behavior, I'm adding the Local Testing parity changes.
    • I acknowledge that I have ensured my changes to be thread-safe. Follow the link for more information: Thread-safe Developer Guidelines
    • If adding any arguments to public Snowpark APIs or creating new public Snowpark APIs, I acknowledge that I have ensured my changes include AST support. Follow the link for more information: AST Support Guidelines
  3. Please describe how your code solves the related issue.

    Please write a short description of how your code change solves the related issue.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 21, 2026

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@sfc-gh-yuwang
Copy link
Copy Markdown
Collaborator Author

sfc-gh-yuwang commented Apr 21, 2026

@sfc-gh-yuwang
Copy link
Copy Markdown
Collaborator Author

I have read the CLA Document and I hereby sign the CLA

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Apr 21, 2026

Codecov Report

❌ Patch coverage is 93.83378% with 23 lines in your changes missing coverage. Please review.
✅ Project coverage is 95.02%. Comparing base (91f7657) to head (1823470).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/snowflake/snowpark/catalog.py 93.78% 20 Missing and 3 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4190      +/-   ##
==========================================
- Coverage   95.04%   95.02%   -0.03%     
==========================================
  Files         171      171              
  Lines       43876    44157     +281     
  Branches     7525     7535      +10     
==========================================
+ Hits        41703    41961     +258     
- Misses       1368     1388      +20     
- Partials      805      808       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@sfc-gh-yuwang sfc-gh-yuwang added the NO-CHANGELOG-UPDATES This pull request does not need to update CHANGELOG.md label Apr 28, 2026
c = self._catalog
like_str = f"LIKE '{like}'" if like else ""
df = c._session.sql(
f"SHOW AS RESOURCE DATABASES {like_str} LIMIT {_SHOW_AS_RESOURCE_LIMIT}"
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Why SHOW AS RESOURCE DATABASES instead of just SHOW DATABASES? For some resources SHOW AS RESOURCES can be much more expensive because they return a lot more data since SHOW AS RESOURCE was built for REST API output. For example, SHOW AS RESOURCE TABLE recurses into columns of the table and return all columns of the table with constraints, their data types etc.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I was following the pattern in the PR that was merged before: https://github.com/snowflakedb/snowpark-python/pull/3942/changes

I think the goal that this was originally used was to maintain the behavior as much as possible.

c._initialize_regex_udf()
assert c._python_regex_udf is not None # pyright
df = df.filter(
c._python_regex_udf(lit(pattern), parse_json('"As Resource"')["name"])
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Do we need regex here? Can we use simple col.like()?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

This is also a existing pattern in current main, I am trying to follow it as much as possible

db_name = c._parse_database(database)
try:
return self.list_schemas(database=db_name, like=unquote_if_quoted(schema))[
0
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Shouldn't we use DESCRIBE or DESCRIBE AS RESOURCE here for efficiency? We need to fetch only one record.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

the reason is that Describe or Describe as resource is returning different results then Show. We use this to not introduce BCR.

Comment thread src/snowflake/snowpark/catalog.py Outdated
schema_name = c._parse_schema(schema)
try:
return c.list_views(
database=db_name,
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Use DESCRIBE or DESCRIBE AS RESOURCE instead?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

same reason as above, describe is returning different result than show and is missing information

Comment thread src/snowflake/snowpark/catalog.py Outdated
Comment thread src/snowflake/snowpark/exceptions.py Outdated
Comment thread src/snowflake/snowpark/session.py Outdated
"""
self.version = get_version()
self._session_stage = None
self._use_sql_base_catalog = True
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Who / where / how is this flag turned off?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

this is controlled in SCOS at here: https://github.com/snowflake-eng/sas/pull/3822/changes#diff-e7ffc1935ec104660e3a0eccbd0693faa973359ed84d9429d28a28684fb55a38R821
basically user can controll it like:
spark.conf.set("snowpark.connect.catalog.use_sql_base_catalog", "false")

Comment thread src/snowflake/snowpark/exceptions.py Outdated
Comment thread src/snowflake/snowpark/session.py Outdated
Comment thread src/snowflake/snowpark/session.py Outdated
Comment thread src/snowflake/snowpark/catalog.py Outdated
Comment thread src/snowflake/snowpark/catalog.py
Comment thread src/snowflake/snowpark/catalog.py
#

from abc import ABC, abstractmethod
from ctypes import ArgumentError
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Incorrect import: ArgumentError from ctypes is intended for ctypes-specific errors, not general argument validation. This is used on lines 494 and 524 to validate user input.

Impact: Raises semantically incorrect exception type that could confuse callers expecting standard Python exceptions.

Fix:

# Remove this import
# from ctypes import ArgumentError

# Then on lines 494 and 524, use:
raise ValueError(
    "When provided procedure is a Procedure class no other arguments can be provided"
)

Spotted by Graphite

Fix in Graphite


Is this helpful? React 👍 or 👎 to let us know.

Copy link
Copy Markdown
Collaborator

@sfc-gh-mayliu sfc-gh-mayliu left a comment

Choose a reason for hiding this comment

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

Snowpark change LGTM, can you paste a good SnowparkConnectRegressionRunnerV2 result before Snowpark PR merge to verify no regression to SCOS? https://snowpark-python-001.jenkinsdev1.us-west-2.aws-dev.app.snowflake.com/job/SnowparkConnectRegressionRunnerV2/

@sfc-gh-yuwang
Copy link
Copy Markdown
Collaborator Author

Snowpark change LGTM, can you paste a good SnowparkConnectRegressionRunnerV2 result before Snowpark PR merge to verify no regression to SCOS? https://snowpark-python-001.jenkinsdev1.us-west-2.aws-dev.app.snowflake.com/job/SnowparkConnectRegressionRunnerV2/

Will do! Will fix bugs if there is any

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

NO-CHANGELOG-UPDATES This pull request does not need to update CHANGELOG.md

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants