codeant-ai-for-open-source[bot] commented on code in PR #43453:
URL: https://github.com/apache/superset/pull/43453#discussion_r3842478660
##########
superset-frontend/src/components/Datasource/components/DatasourceEditor/DatasourceEditor.tsx:
##########
@@ -779,6 +779,35 @@ function EditorsSelector({
const ResultTable =
extensionsRegistry.get('sqleditor.extension.resultTable') ?? FilterableTable;
+// D3's '%' type is a valid spec that multiplies by 100, so it never trips
+// the "Invalid format" fallback even when applied to a raw count.
+const isPercentD3Format = (d3format?: string): boolean =>
+ !!d3format && d3format.trim().endsWith('%');
+
+const isCountExpression = (expression?: string): boolean =>
+ !!expression && /^\s*count\s*\(/i.test(expression);
Review Comment:
**Suggestion:** The prefix-only check classifies every SQL expression
beginning with `COUNT(` as a raw count, including derived expressions such as
`COUNT(*) / COUNT(*)` or `COUNT(*) * 100` where a percentage format can be
intentional. This produces a misleading warning for valid calculated metrics;
restrict the check to a supported raw-count expression shape or use the
metric's aggregate metadata. [incorrect condition logic]
<details>
<summary><b>Severity Level:</b> Minor ๐งน</summary>
```mdx
- โ ๏ธ Metric editor warns on intentional count-derived ratios.
- โ ๏ธ Authors may remove valid percentage formatting unnecessarily.
- โ ๏ธ Chart rendering remains unchanged; this affects authoring guidance only.
```
</details>
[](https://docs.codeant.ai/cli/resolve-pr-comments-skill)
<details>
<summary><b>Prompt for AI Agent ๐ค </b></summary>
```mdx
This is a comment left during a code review.
**Path:**
superset-frontend/src/components/Datasource/components/DatasourceEditor/DatasourceEditor.tsx
**Line:** 787:788
**Comment:**
*Incorrect Condition Logic: The prefix-only check classifies every SQL
expression beginning with `COUNT(` as a raw count, including derived
expressions such as `COUNT(*) / COUNT(*)` or `COUNT(*) * 100` where a
percentage format can be intentional. This produces a misleading warning for
valid calculated metrics; restrict the check to a supported raw-count
expression shape or use the metric's aggregate metadata.
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%2F43453&comment_hash=7f518300e0d7a2553482d7a85cc51a8906ef0d457d24e6b774bbcc2a818c7ec7&reaction=like'>๐</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F43453&comment_hash=7f518300e0d7a2553482d7a85cc51a8906ef0d457d24e6b774bbcc2a818c7ec7&reaction=dislike'>๐</a>
##########
superset-frontend/src/components/Datasource/components/DatasourceEditor/DatasourceEditor.tsx:
##########
@@ -779,6 +779,35 @@ function EditorsSelector({
const ResultTable =
extensionsRegistry.get('sqleditor.extension.resultTable') ?? FilterableTable;
+// D3's '%' type is a valid spec that multiplies by 100, so it never trips
+// the "Invalid format" fallback even when applied to a raw count.
+const isPercentD3Format = (d3format?: string): boolean =>
+ !!d3format && d3format.trim().endsWith('%');
Review Comment:
**Suggestion:** Checking only `endsWith('%')` does not establish that the
value is a valid D3 format specifier. Inputs such as `foo%` or `.0%garbage%`
end in `%` but are rejected by D3 and will use the existing invalid-format
fallback, while this code additionally reports that the metric is using a
percentage format. Validate the format with the same D3 formatter/parser used
by rendering before showing this warning. [type error]
<details>
<summary><b>Severity Level:</b> Minor ๐งน</summary>
```mdx
- โ ๏ธ Invalid D3 formats receive a contradictory percentage warning.
- โ ๏ธ Metric authors see redundant or misleading validation feedback.
- โ ๏ธ The existing invalid-format fallback still renders; charts are not
otherwise changed.
```
</details>
[](https://docs.codeant.ai/cli/resolve-pr-comments-skill)
<details>
<summary><b>Prompt for AI Agent ๐ค </b></summary>
```mdx
This is a comment left during a code review.
**Path:**
superset-frontend/src/components/Datasource/components/DatasourceEditor/DatasourceEditor.tsx
**Line:** 784:785
**Comment:**
*Type Error: Checking only `endsWith('%')` does not establish that the
value is a valid D3 format specifier. Inputs such as `foo%` or `.0%garbage%`
end in `%` but are rejected by D3 and will use the existing invalid-format
fallback, while this code additionally reports that the metric is using a
percentage format. Validate the format with the same D3 formatter/parser used
by rendering before showing this warning.
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%2F43453&comment_hash=70ba8320988959661654e94f4e2a912b1c3f12441d62fbad079c1396ab6383dc&reaction=like'>๐</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F43453&comment_hash=70ba8320988959661654e94f4e2a912b1c3f12441d62fbad079c1396ab6383dc&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]