-
Notifications
You must be signed in to change notification settings - Fork 23
[backend:fix] fix interactive and portal publish PythonUDF MCDB-100138 #closes #138
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
19051af
[backend:fix] fix interactive and portal publish PythonUDF MCDB-100138
KarishS2 18a98b1
[backend:fix] pre-commit check fixes MCDB-100138
KarishS2 ab113be
[backend:fix] PR comments MCDB-100138
KarishS2 71cd0e3
[backend:fix] PR comments MCDB-100138
KarishS2 0288dd7
[backend:fix] solve concurrent write and refusal killing live server …
KarishS2 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| """Parse and classify external function service URLs from SHOW CREATE.""" | ||
| from __future__ import annotations | ||
|
|
||
| import re | ||
| from typing import Optional | ||
|
|
||
| from ...mysql.constants import ER | ||
|
|
||
|
|
||
| # Managed Python UDFs emit: AS MANAGED SERVICE "https://..." | ||
| # Older / remote forms may use SERVICE 'https://...' | ||
| _SERVICE_URL_RE = re.compile( | ||
| r'(?:MANAGED\s+)?SERVICE\s+[\'"]([^\'"]+)[\'"]', | ||
| re.IGNORECASE, | ||
| ) | ||
|
|
||
|
|
||
| def extract_service_url(create_sql: str) -> Optional[str]: | ||
| """Return the MANAGED/REMOTE SERVICE URL from SHOW CREATE FUNCTION text.""" | ||
| if not create_sql: | ||
| return None | ||
| match = _SERVICE_URL_RE.search(create_sql) | ||
| if match is None: | ||
| return None | ||
| return match.group(1) | ||
|
|
||
|
|
||
| def normalize_service_url(url: str) -> str: | ||
| return url.rstrip('/') | ||
|
|
||
|
|
||
| def urls_equal(left: Optional[str], right: Optional[str]) -> bool: | ||
| if not left or not right: | ||
| return False | ||
| return normalize_service_url(left) == normalize_service_url(right) | ||
|
|
||
|
|
||
| def is_interactive_service_url(url: Optional[str]) -> bool: | ||
| if not url: | ||
| return False | ||
| return '/interactive' in normalize_service_url(url).lower() | ||
|
|
||
|
|
||
| def classify_interactive_registration( | ||
| existing_url: Optional[str], | ||
| this_session_url: str, | ||
| ) -> str: | ||
| """Return 'create', 'replace', or raise ValueError if the name is not ours. | ||
|
|
||
| Interactive registration may only create a missing name or replace a | ||
| function that already points at this notebook session's /interactive/ URL. | ||
| """ | ||
| if not existing_url: | ||
| return 'create' | ||
| if urls_equal(existing_url, this_session_url): | ||
| return 'replace' | ||
| raise ValueError( | ||
| f'Cannot register over existing function pointing at {existing_url} ' | ||
| f'(this session is {this_session_url}). ' | ||
| 'Interactive registration will not replace a published or ' | ||
| 'other-session function.', | ||
| ) | ||
|
|
||
|
|
||
| def is_function_not_defined(exc: BaseException) -> bool: | ||
| errno = getattr(exc, 'errno', None) | ||
| if errno in (ER.FUNCTION_NOT_DEFINED, ER.SP_DOES_NOT_EXIST): | ||
| return True | ||
| args = getattr(exc, 'args', ()) | ||
| if args and args[0] in (ER.FUNCTION_NOT_DEFINED, ER.SP_DOES_NOT_EXIST): | ||
| return True | ||
| return False | ||
|
cursor[bot] marked this conversation as resolved.
|
||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.