SNOW-2267482: Fix flakiness due to SnowAPI dependency#4190
SNOW-2267482: Fix flakiness due to SnowAPI dependency#4190sfc-gh-yuwang wants to merge 33 commits into
Conversation
|
All contributors have signed the CLA ✍️ ✅ |
|
https://snowpark-python-001.jenkinsdev1.us-west-2.aws-dev.app.snowflake.com/job/SnowparkConnectRegressionRunner/500/ |
|
I have read the CLA Document and I hereby sign the CLA |
Codecov Report❌ Patch coverage is
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. 🚀 New features to boost your workflow:
|
| 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}" |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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"]) |
There was a problem hiding this comment.
Do we need regex here? Can we use simple col.like()?
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
Shouldn't we use DESCRIBE or DESCRIBE AS RESOURCE here for efficiency? We need to fetch only one record.
There was a problem hiding this comment.
the reason is that Describe or Describe as resource is returning different results then Show. We use this to not introduce BCR.
| schema_name = c._parse_schema(schema) | ||
| try: | ||
| return c.list_views( | ||
| database=db_name, |
There was a problem hiding this comment.
Use DESCRIBE or DESCRIBE AS RESOURCE instead?
There was a problem hiding this comment.
same reason as above, describe is returning different result than show and is missing information
| """ | ||
| self.version = get_version() | ||
| self._session_stage = None | ||
| self._use_sql_base_catalog = True |
There was a problem hiding this comment.
Who / where / how is this flag turned off?
There was a problem hiding this comment.
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")
| # | ||
|
|
||
| from abc import ABC, abstractmethod | ||
| from ctypes import ArgumentError |
There was a problem hiding this comment.
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
Is this helpful? React 👍 or 👎 to let us know.
sfc-gh-mayliu
left a comment
There was a problem hiding this comment.
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 |
Which Jira issue is this PR addressing? Make sure that there is an accompanying issue to your PR.
Fixes SNOW-2267482
Fill out the following pre-review checklist:
Please describe how your code solves the related issue.
Please write a short description of how your code change solves the related issue.