Repository navigation
feat(NoTicket): send NULL output format for server-side async queries #555
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,6 +11,7 @@ | |
| from firebolt.common.constants import ( | ||
| JSON_LINES_OUTPUT_FORMAT, | ||
| JSON_OUTPUT_FORMAT, | ||
| NULL_OUTPUT_FORMAT, | ||
| ) | ||
| from firebolt.utils.exception import ( | ||
| ConfigurationError, | ||
|
|
@@ -129,8 +130,15 @@ def _create_bulk_plan_impl( | |
| """Create parameter-style specific bulk execution plan.""" | ||
|
|
||
| @staticmethod | ||
| def _get_output_format(streaming: bool) -> str: | ||
| def _get_output_format(streaming: bool, async_execution: bool = False) -> str: | ||
| """Get output format for the query.""" | ||
| assert not ( | ||
| streaming and async_execution | ||
| ), "Streaming and async execution are not supported together" | ||
| # Async queries return no rows, and the server only accepts async | ||
| # SELECTs when no result serialization is requested. | ||
| if async_execution: | ||
| return NULL_OUTPUT_FORMAT | ||
|
Comment on lines
+140
to
+141
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🤖 Major: This makes every execute_async depend on the engine accepting NULL, not just async SELECT. Engines from before the async SELECT change reject the Null output format without advanced_mode ("Output format 'NULL' is not supported, choose one of: ..."). So after the SDK upgrade, async INSERT / COPY / VACUUM break against any older engine. The "Before merging" note covers staging, but not customers. Firebolt Core users pin image tags. The SDK release is not tied to the engine rollout. I see three options. We keep JSON_Compact as the default and send NULL only for SELECT (when the statement is parsed). Or we fall back to JSON_Compact on that specific format error. Or we hold the release until every supported engine and Core image has the engine change, and document the minimum version. I'd prefer one of the first two, so the SDK stays compatible with older engines. |
||
| if streaming: | ||
| return JSON_LINES_OUTPUT_FORMAT | ||
| return JSON_OUTPUT_FORMAT | ||
|
|
@@ -203,7 +211,7 @@ def _build_fb_numeric_query_params( | |
| ] | ||
|
|
||
| query_params: Dict[str, Any] = { | ||
| "output_format": self._get_output_format(streaming), | ||
| "output_format": self._get_output_format(streaming, async_execution), | ||
| } | ||
| if query_parameters: | ||
| query_params["query_parameters"] = json.dumps(query_parameters) | ||
|
|
@@ -263,7 +271,7 @@ def _create_standard_execution_plan( | |
|
|
||
| # Build basic query parameters for qmark style | ||
| query_params: Dict[str, Any] = { | ||
| "output_format": self._get_output_format(streaming), | ||
| "output_format": self._get_output_format(streaming, async_execution), | ||
| } | ||
| if async_execution: | ||
| query_params["async"] = True | ||
|
|
@@ -288,7 +296,7 @@ def _create_bulk_plan_impl( | |
|
|
||
| # Build query parameters for bulk insert | ||
| query_params: Dict[str, Any] = { | ||
| "output_format": self._get_output_format(False), | ||
| "output_format": self._get_output_format(False, async_execution), | ||
| } | ||
| if async_execution: | ||
| query_params["async"] = True | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤖 Minor: This should say from which Firebolt version async SELECT is accepted. Older engines still reject it. With this PR as is, they would reject all async queries from this SDK version (see the comment on statement_planners.py). Also, the " - " reads like a broken dash. Two sentences would be cleaner.