mirror of
https://github.com/apache/superset.git
synced 2026-04-23 18:14:56 +00:00
[SIP-5] QueryBuilder in the client for granularity and groupby in word cloud (#6377)
* [SIP-5] QueryBuilder in the client for groupby field - Lay the structure of the QueryContext builder in the client - QueryContext builder composes different portions of the queryContext object (to be sent to server from the client) from the datasourceBuilder and the queryObjectBuilder. - The datasourceBuilder builds the datasource id and type by parsing them from the datasource field in formdata - The queryObjectBuilder currently only builds the groupby field. It will further compose the queryObject from sub query builders in future PRs. - Create a buildQuery method for WordCloud and override the groupby value with the value of series from formdata. * Addressing PR comments - Rename query builder files and their default exports - Move tests into spec/javascripts/superset-ui for easy mass migration to superset-uiin the future - Define viz specific formData and export formData for each viz type as intersection type of the generic formData and the viz specific one - Specify the type signature for sqla and druid based data sources * Addressing additional PR comments. - Introduce a Datasource class and leverage Typescript's declaration merging of the interface by the same name. - Let Typescript infer the return type of various builders instead of specifying them explicitly * Further tweaking the generic buildQueryContext method and viz speicific buildQuery methodes per PR comments. * git mv a renamed file. * addressing additional pr comments
This commit is contained in:
committed by
Chris Williams
parent
c42bcf81bc
commit
8b2cae007d
18
superset/assets/src/query/buildQueryObject.ts
Normal file
18
superset/assets/src/query/buildQueryObject.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import FormData, { getGranularity } from './FormData';
|
||||
|
||||
// TODO: fill out the rest of the query object
|
||||
export interface QueryObject {
|
||||
granularity: string;
|
||||
groupby?: string[];
|
||||
}
|
||||
|
||||
// Build the common segments of all query objects (e.g. the granularity field derived from
|
||||
// either sql alchemy or druid). The segments specific to each viz type is constructed in the
|
||||
// buildQuery method for each viz type (see `wordcloud/buildQuery.ts` for an example).
|
||||
// Note the type of the formData argument passed in here is the type of the formData for a
|
||||
// specific viz, which is a subtype of the generic formData shared among all viz types.
|
||||
export default function buildQueryObject<T extends FormData>(formData: T): QueryObject {
|
||||
return {
|
||||
granularity: getGranularity(formData),
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user