-
Notifications
You must be signed in to change notification settings - Fork 271
feat: update ChartFormData and QueryObject to support filters. #164
Conversation
Codecov Report
@@ Coverage Diff @@
## master #164 +/- ##
=====================================
Coverage 100% 100%
=====================================
Files 81 88 +7
Lines 1050 1095 +45
Branches 259 263 +4
=====================================
+ Hits 1050 1095 +45
Continue to review full report at Codecov.
|
Deploy preview for superset-ui ready! Built with commit 1e8853e |
row_limit?: number; | ||
/** Maximum number of series */ | ||
timeseries_limit?: number; | ||
/** TODO: Doc */ |
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.
The metric used to sort the returned result.
export default function convertFilter(filter: SimpleAdhocFilter): QueryObjectFilterClause { | ||
const { subject } = filter; | ||
if (isUnaryAdhocFilter(filter)) { | ||
const { operator } = filter; |
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.
We can put it outside the current block to reduce the duplication.
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.
Has to be inside the block to infer the correct Operator
type
@@ -0,0 +1,43 @@ | |||
/** List of operators that do not require another operand */ | |||
export const UNARY_OPERATORS = ['IS NOT NULL', 'IS NULL'] as const; |
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.
do we need to export UNARY_OPERATORS
etc? seems there is no other place to use them.
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.
Not being used at the moment. I will remove export
// TODO: Implement | ||
// utils.convert_legacy_filters_into_adhoc(self.form_data) | ||
|
||
// TODO: Implement |
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.
Will these two in the scope of this PR?
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.
These will be beyond the scope. Right now this PR will handle adhoc_filters
(which is the standard filters) correctly plus provide typings.
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.
do you think we should console.warn
if we see legacy filters? (fine if not)
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.
The legacy filters are using fields filters
and having_filters
which do not exist on type ChartFormData
, so typescript would complain.
I am wondering if we want to support this utils.convert_legacy_filters_into_adhoc(self.form_data)
going forward. Not sure how long since we have moved from the legacy filters.
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.
Thanks for adding this and refactoring the code overall! it looks good overall
order_desc: orderDesc, | ||
is_timeseries: groupbySet.has(DTTM_ALIAS), | ||
metrics: processMetrics(formData), | ||
order_desc: order_desc === undefined ? true : order_desc, |
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.
typeof order_desc === 'undefined'
?
@@ -0,0 +1,43 @@ | |||
/** List of operators that do not require another operand */ |
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.
wow these are great!
// TODO: Implement | ||
// merge_extra_filters(self.form_data) | ||
|
||
// utils.split_adhoc_filters_into_base_filters(self.form_data) |
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.
is this just indicating what the logic below mapped to? (i.e., it's not part of the TODOs above) should we remove it or keep for context?
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.
Will remove or change to simple sentence. Seem not necessary any more
// eslint-disable-next-line camelcase | ||
const { adhoc_filters } = formData; | ||
if (Array.isArray(adhoc_filters)) { | ||
const simpleWhere: QueryObjectFilterClause[] = []; |
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.
(not blocking) the type helps but I find these a little confusing name-wise, not sure what to expect simple
to mean, maybe whereFilter
<> whereFreeform
and havingFilter
<> havingFreeform
?
SIMPLE = 'SIMPLE', | ||
SQL = 'SQL', | ||
} | ||
export type Aggregate = 'AVG' | 'COUNT' | 'COUNT_DISTINCT' | 'MAX' | 'MIN' | 'SUM'; |
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.
nice 👌
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.
really solid! Hard to find anything to improve significantly I had only nit/non-blocking thoughts 😍 👏 💯
Updates the requirements on [@data-ui/event-flow](https://github.com/williaster/data-ui) to permit the latest version. - [Release notes](https://github.com/williaster/data-ui/releases) - [Changelog](https://github.com/williaster/data-ui/blob/master/CHANGELOG.md) - [Commits](williaster/data-ui@v0.0.79...v0.0.80) Signed-off-by: dependabot-preview[bot] <[email protected]>
💔 Breaking Changes
Rename types to make it clearer. The metric types in
ChartFormData
andQueryObject
are different.FormDataMetric
=>ChartFormDataMetric
Metrics
=>ChartFormDataMetrics
Metric
=>QueryObjectMetric
This is pretty mild breaking change as these are internally used types so I would incline to not bump major version.
🏆 Enhancements
ChartFormData
andQueryObject
to support filters.buildQueryObject
to convert filters fromChartFormData
and put into corresponding fields inQueryObject
. SeeprocessFilters.ts
andconvertFilter.ts
.QueryObject
fields.📜 Documentation
QueryObject
🏠 Internal
Metrics
class and replace with two functionsprocessMetrics
andconvertMetric
.