codeant-ai-for-open-source[bot] commented on code in PR #37516:
URL: https://github.com/apache/superset/pull/37516#discussion_r3592131098
##########
superset/common/query_actions.py:
##########
@@ -191,20 +252,121 @@ def _get_full(
] + rejected_time_columns
if result_type == ChartDataResultType.RESULTS and status !=
QueryStatus.FAILED:
- return {
+ result = {
Review Comment:
**Suggestion:** Add a concrete type annotation for this newly created
response dictionary variable. [custom_rule]
**Severity Level:** Minor ๐งน
<details>
<summary><b>Why it matters? โญ </b></summary>
The new local variable `result` is introduced without an explicit annotation
in added code. Since it is a dictionary-shaped intermediate value that can be
typed, this is a valid type-hint omission under the rule.
</details>
<details>
<summary><b>Rule source ๐ </b></summary>
.cursor/rules/dev-standard.mdc (line 28)
</details>
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=66c214034a5144719368bf27e450727d&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
[](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=66c214034a5144719368bf27e450727d&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
*(Use Cmd/Ctrl + Click for best experience)*
<details>
<summary><b>Prompt for AI Agent ๐ค </b></summary>
```mdx
This is a comment left during a code review.
**Path:** superset/common/query_actions.py
**Line:** 255:255
**Comment:**
*Custom Rule: Add a concrete type annotation for this newly created
response dictionary variable.
Validate the correctness of the flagged issue. If correct, How can I resolve
this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask
user if the user wants to fix the rest of the comments as well. if said yes,
then fetch all the comments validate the correctness and implement a minimal fix
```
</details>
<a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F37516&comment_hash=45e9d3f1460bfa9ee295a594ee2c30b58ff90eb6710d63a3d43afd091452806b&reaction=like'>๐</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F37516&comment_hash=45e9d3f1460bfa9ee295a594ee2c30b58ff90eb6710d63a3d43afd091452806b&reaction=dislike'>๐</a>
##########
superset/common/query_actions.py:
##########
@@ -191,20 +252,121 @@ def _get_full(
] + rejected_time_columns
if result_type == ChartDataResultType.RESULTS and status !=
QueryStatus.FAILED:
- return {
+ result = {
"data": payload.get("data"),
"colnames": payload.get("colnames"),
"coltypes": payload.get("coltypes"),
"rowcount": payload.get("rowcount"),
"sql_rowcount": payload.get("sql_rowcount"),
"detected_currency": payload.get("detected_currency"),
}
- return payload
+ payload = result
+ materialization_ns = pre_materialization_ns + max(
+ 0, time.perf_counter_ns() - materialization_start_ns
+ )
+ return QueryDataResult(
+ payload=payload,
+ timing=acquisition.timing.materialized(materialization_ns),
+ )
-def _get_samples(
- query_context: QueryContext, query_obj: QueryObject, force_cached: bool =
False
-) -> dict[str, Any]:
+def _metadata_result(render: Callable[[], dict[str, Any]]) -> QueryDataResult:
+ """Render metadata while retaining datasource work in the timing
sidecar."""
+
+ start_ns = time.perf_counter_ns()
+ collector = SourceTimingCollector()
+ with collector.activated():
+ payload = render()
+ elapsed_ns = max(0, time.perf_counter_ns() - start_ns)
+ sources = collector.snapshot()
+ if (parent_collector := active_source_collector()) is not None:
+ parent_collector.attach(sources)
+ source_ns = min(elapsed_ns, sum(source.total_ns for source in sources))
+ return QueryDataResult(
+ payload=payload,
+ timing=QueryAcquisitionTiming(
+ cache_key_ns=0,
+ cache_read_ns=0,
+ source_ns=source_ns,
+ cache_write_ns=None,
+ cache_write_outcome=CacheWriteOutcome.NOT_ATTEMPTED,
+ cache_hit=None,
+ sources=sources,
+ ).materialized(elapsed_ns - source_ns),
+ )
+
+
+def acquire_query_data(
+ result_type: ChartDataResultType,
+ query_context: QueryContext,
+ query_obj: QueryObject,
+ force_cached: bool,
+ *,
+ detect_currency_value: bool = True,
+ cache_key_extra: Mapping[str, Any] | None = None,
+) -> AcquiredQuery | None:
+ """Prepare and acquire dataframe-backed query data without materializing
it."""
+
+ prepared = query_obj
Review Comment:
**Suggestion:** Add an explicit variable annotation for this intermediate
query object assignment to keep new logic fully type-checked. [custom_rule]
**Severity Level:** Minor ๐งน
<details>
<summary><b>Why it matters? โญ </b></summary>
The new local variable `prepared` is assigned without a type hint in newly
added Python code, and it is a relevant variable that can be annotated. This
matches the Python type-hint rule.
</details>
<details>
<summary><b>Rule source ๐ </b></summary>
.cursor/rules/dev-standard.mdc (line 28)
</details>
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=4ea8640fc9234adcb47582fba735d9e2&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
[](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=4ea8640fc9234adcb47582fba735d9e2&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
*(Use Cmd/Ctrl + Click for best experience)*
<details>
<summary><b>Prompt for AI Agent ๐ค </b></summary>
```mdx
This is a comment left during a code review.
**Path:** superset/common/query_actions.py
**Line:** 310:310
**Comment:**
*Custom Rule: Add an explicit variable annotation for this intermediate
query object assignment to keep new logic fully type-checked.
Validate the correctness of the flagged issue. If correct, How can I resolve
this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask
user if the user wants to fix the rest of the comments as well. if said yes,
then fetch all the comments validate the correctness and implement a minimal fix
```
</details>
<a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F37516&comment_hash=b3a3b96558849eafa13ca5e9f3fe1adba1729a7c2c8d5372759e4889a88a8ea3&reaction=like'>๐</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F37516&comment_hash=b3a3b96558849eafa13ca5e9f3fe1adba1729a7c2c8d5372759e4889a88a8ea3&reaction=dislike'>๐</a>
##########
superset/common/query_actions.py:
##########
@@ -191,20 +252,121 @@ def _get_full(
] + rejected_time_columns
if result_type == ChartDataResultType.RESULTS and status !=
QueryStatus.FAILED:
- return {
+ result = {
"data": payload.get("data"),
"colnames": payload.get("colnames"),
"coltypes": payload.get("coltypes"),
"rowcount": payload.get("rowcount"),
"sql_rowcount": payload.get("sql_rowcount"),
"detected_currency": payload.get("detected_currency"),
}
- return payload
+ payload = result
+ materialization_ns = pre_materialization_ns + max(
+ 0, time.perf_counter_ns() - materialization_start_ns
+ )
+ return QueryDataResult(
+ payload=payload,
+ timing=acquisition.timing.materialized(materialization_ns),
+ )
-def _get_samples(
- query_context: QueryContext, query_obj: QueryObject, force_cached: bool =
False
-) -> dict[str, Any]:
+def _metadata_result(render: Callable[[], dict[str, Any]]) -> QueryDataResult:
+ """Render metadata while retaining datasource work in the timing
sidecar."""
+
+ start_ns = time.perf_counter_ns()
+ collector = SourceTimingCollector()
+ with collector.activated():
+ payload = render()
+ elapsed_ns = max(0, time.perf_counter_ns() - start_ns)
+ sources = collector.snapshot()
+ if (parent_collector := active_source_collector()) is not None:
+ parent_collector.attach(sources)
+ source_ns = min(elapsed_ns, sum(source.total_ns for source in sources))
+ return QueryDataResult(
+ payload=payload,
+ timing=QueryAcquisitionTiming(
+ cache_key_ns=0,
+ cache_read_ns=0,
+ source_ns=source_ns,
+ cache_write_ns=None,
+ cache_write_outcome=CacheWriteOutcome.NOT_ATTEMPTED,
+ cache_hit=None,
+ sources=sources,
+ ).materialized(elapsed_ns - source_ns),
+ )
+
+
+def acquire_query_data(
+ result_type: ChartDataResultType,
+ query_context: QueryContext,
+ query_obj: QueryObject,
+ force_cached: bool,
+ *,
+ detect_currency_value: bool = True,
+ cache_key_extra: Mapping[str, Any] | None = None,
+) -> AcquiredQuery | None:
+ """Prepare and acquire dataframe-backed query data without materializing
it."""
+
+ prepared = query_obj
+ if result_type == ChartDataResultType.SAMPLES:
+ prepared = _prepare_samples_query(query_context, query_obj)
+ elif result_type == ChartDataResultType.DRILL_DETAIL:
+ prepared = _prepare_drill_detail_query(query_context, query_obj)
+ elif not is_data_result_type(result_type):
+ return None
+
+ acquisition = query_context.get_df_payload_result(
+ prepared,
+ force_cached=force_cached,
+ cache_key_extra=cache_key_extra,
+ )
+ acquisition, detected_currency, currency_processing_ns = (
+ _acquire_currency_dependency(
+ query_context,
+ prepared,
+ acquisition,
+ force_cached,
+ detect_value=detect_currency_value,
+ )
+ )
+ return AcquiredQuery(
+ query_obj=prepared,
+ acquisition=acquisition,
+ detected_currency=detected_currency,
+ currency_processing_ns=currency_processing_ns,
+ )
+
+
+def materialize_acquired_query(
+ query_context: QueryContext,
+ acquired: AcquiredQuery,
+) -> QueryDataResult:
+ """Materialize an acquired dataframe into the requested response format."""
+
+ return _materialize_full(
+ query_context,
+ acquired.query_obj,
+ acquired.acquisition,
+ acquired.detected_currency,
+ acquired.currency_processing_ns,
+ )
+
+
+def cache_acquired_query(acquired: AcquiredQuery) -> QueryDataResult:
+ """Return cache-only metadata without serializing the acquired
dataframe."""
+
+ cache_payload = {
Review Comment:
**Suggestion:** Annotate this new cache payload variable with an explicit
mapping/dictionary type. [custom_rule]
**Severity Level:** Minor ๐งน
<details>
<summary><b>Why it matters? โญ </b></summary>
The new local variable `cache_payload` is added without an explicit type
annotation, even though it is a clear mapping/dictionary value that can be
annotated. This is a real instance of the Python type-hint rule violation.
</details>
<details>
<summary><b>Rule source ๐ </b></summary>
.cursor/rules/dev-standard.mdc (line 28)
</details>
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=0dcaf0c4857f472c8738963c83270d1e&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
[](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=0dcaf0c4857f472c8738963c83270d1e&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
*(Use Cmd/Ctrl + Click for best experience)*
<details>
<summary><b>Prompt for AI Agent ๐ค </b></summary>
```mdx
This is a comment left during a code review.
**Path:** superset/common/query_actions.py
**Line:** 358:358
**Comment:**
*Custom Rule: Annotate this new cache payload variable with an explicit
mapping/dictionary type.
Validate the correctness of the flagged issue. If correct, How can I resolve
this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask
user if the user wants to fix the rest of the comments as well. if said yes,
then fetch all the comments validate the correctness and implement a minimal fix
```
</details>
<a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F37516&comment_hash=9bf9f0098fb85d44f8e1552d169bc23d855c82c4301dea229fa7f7168733776b&reaction=like'>๐</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F37516&comment_hash=9bf9f0098fb85d44f8e1552d169bc23d855c82c4301dea229fa7f7168733776b&reaction=dislike'>๐</a>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]