Skip to content
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

fix(explore): Explore page boolean filter is broken for Presto DB #14952

Merged
merged 11 commits into from Jun 10, 2021

Conversation

m-ajay
Copy link
Contributor

@m-ajay m-ajay commented Jun 2, 2021

SUMMARY

Explore page boolean filter was not working for presto db even after the PR #14567. #10098

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

IS_TRUE filter
filter_is_true
IS_TRUE false
filter_is_false

TESTING INSTRUCTIONS

  • Manual and CI

ADDITIONAL INFORMATION

  • Has associated issue:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • Migration is atomic, supports rollback & is backwards-compatible
    • Confirm DB migration upgrade and downgrade tested
    • Runtime estimates and downtime expectations provided
  • Introduces new feature or API
  • Removes existing feature or API

@m-ajay m-ajay changed the title [WIP] (fix)explore: Explore page boolean filter is broken for Preset DB [WIP] (fix)explore: Explore page boolean filter is broken for Presto DB Jun 2, 2021
@graceguo-supercat
Copy link

@m-ajay Thanks for the fix. I tested this PR in dev environment. it works as expected. You can add more description and it will be ready for code review.

@m-ajay m-ajay changed the title [WIP] (fix)explore: Explore page boolean filter is broken for Presto DB (fix)explore: Explore page boolean filter is broken for Presto DB Jun 7, 2021
@m-ajay m-ajay marked this pull request as ready for review June 7, 2021 20:00
@m-ajay m-ajay changed the title (fix)explore: Explore page boolean filter is broken for Presto DB fix(explore): Explore page boolean filter is broken for Presto DB Jun 7, 2021
@codecov
Copy link

codecov bot commented Jun 8, 2021

Codecov Report

Merging #14952 (e221f7f) into master (21aa3da) will decrease coverage by 0.15%.
The diff coverage is 73.10%.

❗ Current head e221f7f differs from pull request most recent head f8638a9. Consider uploading reports for the commit f8638a9 to get more accurate results
Impacted file tree graph

@@            Coverage Diff             @@
##           master   #14952      +/-   ##
==========================================
- Coverage   77.51%   77.36%   -0.16%     
==========================================
  Files         966      967       +1     
  Lines       49615    49740     +125     
  Branches     6311     6351      +40     
==========================================
+ Hits        38458    38479      +21     
- Misses      10956    11059     +103     
- Partials      201      202       +1     
Flag Coverage Δ
javascript 72.44% <73.05%> (-0.34%) ⬇️
mysql ?

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
superset-frontend/src/common/components/index.tsx 100.00% <ø> (ø)
superset-frontend/src/components/Button/index.tsx 100.00% <ø> (ø)
...c/components/ErrorMessage/DatabaseErrorMessage.tsx 94.73% <ø> (ø)
...onents/ErrorMessage/ErrorMessageWithStackTrace.tsx 77.77% <0.00%> (ø)
.../components/ErrorMessage/ParameterErrorMessage.tsx 96.87% <ø> (ø)
...rset-frontend/src/components/ErrorMessage/types.ts 100.00% <ø> (ø)
...et-frontend/src/components/Select/NativeSelect.tsx 100.00% <ø> (ø)
...tersConfigModal/FiltersConfigForm/DefaultValue.tsx 25.00% <0.00%> (-1.32%) ⬇️
...-frontend/src/explore/components/ControlHeader.jsx 85.71% <ø> (ø)
...trols/DateFilterControl/components/CustomFrame.tsx 92.15% <ø> (ø)
... and 61 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 21aa3da...f8638a9. Read the comment docs.

Copy link
Member

@etr2460 etr2460 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some comments, nice work so far!

operation: string;
}

export const OPERATOR_MAPPING: {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure about this naming, perhaps OPERATOR_ENUM_TO_OPERATOR_TYPE?

'IS TRUE': 'IS TRUE',
'IS FALSE': 'IS FALSE',
export enum Operators {
EQUALS = 1,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if we're using this as an id, then for ease of debugging, i think i'd prefer using

EQUALS = 'EQUALS',
NOT_EQUALS = 'NOT_EQUALS',
etc.

sumValueAdhocMetric,
];

function setup(overrides?: object) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer Record<string, any> to object

};
const onSubjectChange = (id: string) => {
const option = props.options.find(
// @ts-ignore
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is the ts-ignore needed here? Can we type option as ColumnType to get around it?

isOperatorRelevant,
onComparatorChange,
} = useSimpleTabFilterProps(props);
const [suggestions, setSuggestions] = useState<JsonObject>([]);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is JsonObject the right thing to use here since you initialize to an empty array? Perhaps Record<string, any>[] is correct?

Comment on lines 234 to 236
const [abortActiveRequest, setAbortActiveRequest] = useState<
(() => void) | null
>(null);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe out of scope, but initializing this to NO_OP (or maybe noOp, I forget how it's named in our utils file, it's basically an empty function) would prevent the need to manually set the type and to check if abortActiveRequest exists before calling it everytime. Seems cleaner

name="filter-value"
ref={ref =>
focusComparator(
ref as HTMLInputElement | null,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ideally we don't need to force the typing here, but it might be tricky

import { EXPRESSION_TYPES, CLAUSES } from './AdhocFilter';

export default PropTypes.oneOfType([
PropTypes.shape({
expressionType: PropTypes.oneOf([EXPRESSION_TYPES.SIMPLE]).isRequired,
clause: PropTypes.oneOf([CLAUSES.HAVING, CLAUSES.WHERE]).isRequired,
subject: PropTypes.string.isRequired,
operator: PropTypes.oneOf(Object.keys(OPERATORS)).isRequired,
// TODO: Fix the type
// operator: PropTypes.oneOf(Object.keys(OPERATORS)).isRequired,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like we need to fix something here?

@@ -51,5 +51,6 @@ export default function FilterDefinitionOption({ option }) {
/>
);
}
return null;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice catch

@m-ajay m-ajay requested a review from etr2460 June 9, 2021 15:44
@m-ajay m-ajay changed the title fix(explore): Explore page boolean filter is broken for Presto DB [WIP] fix(explore): Explore page boolean filter is broken for Presto DB Jun 9, 2021
@m-ajay m-ajay changed the title [WIP] fix(explore): Explore page boolean filter is broken for Presto DB fix(explore): Explore page boolean filter is broken for Presto DB Jun 9, 2021
Copy link
Member

@etr2460 etr2460 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no more code review comments, but it looks like there are some frontend lint errors still? I believe running npm run lint-fix locally will help you find/autofix them

Copy link
Member

@etr2460 etr2460 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

woohoo!

@etr2460 etr2460 merged commit f8b270d into apache:master Jun 10, 2021
cccs-RyanS pushed a commit to CybercentreCanada/superset that referenced this pull request Dec 17, 2021
…ache#14952)

* Front end update - modify OPERATORS, to have SQL operation and display value

* Updated tests

* More tests

* Remove OPERATOR imports

* Fix break tests

* PR comments

* fix issue with comparator loading

* rename a variable

* Linting
QAlexBall pushed a commit to QAlexBall/superset that referenced this pull request Dec 29, 2021
…ache#14952)

* Front end update - modify OPERATORS, to have SQL operation and display value

* Updated tests

* More tests

* Remove OPERATOR imports

* Fix break tests

* PR comments

* fix issue with comparator loading

* rename a variable

* Linting
cccs-rc pushed a commit to CybercentreCanada/superset that referenced this pull request Mar 6, 2024
…ache#14952)

* Front end update - modify OPERATORS, to have SQL operation and display value

* Updated tests

* More tests

* Remove OPERATOR imports

* Fix break tests

* PR comments

* fix issue with comparator loading

* rename a variable

* Linting
@mistercrunch mistercrunch added the 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels label Mar 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels size/XXL 🚢 1.3.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants