codeant-ai-for-open-source[bot] commented on code in PR #40180:
URL: https://github.com/apache/superset/pull/40180#discussion_r3525361548
##########
superset-frontend/plugins/plugin-chart-table/test/TableChart.test.tsx:
##########
@@ -1843,6 +1843,54 @@ describe('plugin-chart-table', () => {
expect(secondCallArg.extraFormData.filters).toEqual([]);
});
+ test('clicking a temporal numeric-string cell emits numeric cross-filter
values', () => {
+ const setDataMask = jest.fn();
+ const timestamp = 1777248000000;
+ const props = transformProps({
+ ...testData.basic,
+ hooks: { setDataMask },
+ emitCrossFilters: true,
+ });
+
+ render(
+ <ProviderWrapper>
+ <TableChart
+ {...props}
+ data={[{ install_date: String(timestamp) }]}
+ columns={[
+ {
+ key: 'install_date',
+ label: 'install_date',
+ dataType: GenericDataType.Temporal,
+ isNumeric: false,
+ isMetric: false,
+ isPercentMetric: false,
+ formatter: String,
+ config: {},
+ },
+ ]}
+ emitCrossFilters
+ setDataMask={setDataMask}
+ sticky={false}
+ />
+ </ProviderWrapper>,
+ );
+
+ fireEvent.click(screen.getByText(String(timestamp)));
+
+ const crossFilterCall = setDataMask.mock.calls.find(
+ (call: any[]) => call[0]?.filterState?.filters,
+ );
Review Comment:
**Suggestion:** Replace the `any[]` callback parameter type with a concrete
typed structure that matches the `setDataMask` mock call payload. [custom_rule]
**Severity Level:** Minor ⚠️
<details>
<summary><b>Why it matters? 🤔 </b></summary>
The custom rule forbids new or changed TypeScript code that uses `any`. This
added test callback explicitly types its parameter as `any[]`, so the violation
is real and directly present in the new hunk.
</details>
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=0c1b1f44c86d420b8efd93238d8c5f07&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=0c1b1f44c86d420b8efd93238d8c5f07&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-frontend/plugins/plugin-chart-table/test/TableChart.test.tsx
**Line:** 1881:1883
**Comment:**
*Custom Rule: Replace the `any[]` callback parameter type with a
concrete typed structure that matches the `setDataMask` mock call payload.
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%2F40180&comment_hash=132950e3bb7fddfea908ad3e01f0ddc44911b7f9595f0917e346c0cd2c20e2ce&reaction=like'>👍</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F40180&comment_hash=132950e3bb7fddfea908ad3e01f0ddc44911b7f9595f0917e346c0cd2c20e2ce&reaction=dislike'>👎</a>
##########
superset/models/helpers.py:
##########
@@ -2637,21 +2637,50 @@ def filter_values_handler( # pylint:
disable=too-many-arguments # noqa: C901
if values is None:
return None
- def handle_single_value(value: Optional[FilterValue]) ->
Optional[FilterValue]:
- if operator == utils.FilterOperator.TEMPORAL_RANGE:
- return value
+ temporal_comparison_operators = {
+ utils.FilterOperator.EQUALS,
+ utils.FilterOperator.NOT_EQUALS,
+ utils.FilterOperator.IN,
+ utils.FilterOperator.NOT_IN,
+ utils.FilterOperator.GREATER_THAN,
+ utils.FilterOperator.LESS_THAN,
+ utils.FilterOperator.GREATER_THAN_OR_EQUALS,
+ utils.FilterOperator.LESS_THAN_OR_EQUALS,
+ }
Review Comment:
**Suggestion:** Add an explicit type annotation to
`temporal_comparison_operators` (for example a typed set of filter operators)
to satisfy the type-hint requirement for new relevant variables. [custom_rule]
**Severity Level:** Minor ⚠️
<details>
<summary><b>Why it matters? 🤔 </b></summary>
This is a newly introduced local variable in modified Python code, and it is
not annotated. That matches the type-hint rule because the variable can be
typed (for example as a set of filter operators) and currently omits an
explicit annotation.
</details>
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=1c6c74de27e949ac899835ec6edfceb1&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=1c6c74de27e949ac899835ec6edfceb1&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/models/helpers.py
**Line:** 2640:2649
**Comment:**
*Custom Rule: Add an explicit type annotation to
`temporal_comparison_operators` (for example a typed set of filter operators)
to satisfy the type-hint requirement for new relevant variables.
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%2F40180&comment_hash=5c2af7cc5503090384da6b722f75a279096935fa5bc850ba4787ef06f6a8ad25&reaction=like'>👍</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F40180&comment_hash=5c2af7cc5503090384da6b722f75a279096935fa5bc850ba4787ef06f6a8ad25&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]