Skip to content
Snippets Groups Projects
Unverified Commit 7ecb2985 authored by Nemanja Glumac's avatar Nemanja Glumac Committed by GitHub
Browse files

[MLv2] Introduce a `queryDisplayInfo` abstraction (#37862)

* Introduce a `queryDisplayInfo` abstraction

* Address review comments

Call `ML.display_info` directly in a new abstraction,
and remove the additional function overload.

* Tidy up comments
parent 784759be
No related branches found
No related tags found
No related merge requests found
......@@ -140,18 +140,6 @@ declare function DisplayInfoFn(
stageIndex: number,
segment: SegmentMetadata,
): SegmentDisplayInfo;
/**
* Even though it seems weird to pass the same query two times,
* this function follows the same pattern as the other displayInfo functions.
* The first two parameters are always a query, and a stage.
* The third parameter is what you would like to have info about.
* It just only happens that the thing we're examining is (again) the query itself.
*/
declare function DisplayInfoFn(
_query: Query,
_stageIndex: number,
query: Query,
): QueryDisplayInfo;
// x can be any sort of opaque object, e.g. a clause or metadata map. Values returned depend on what you pass in, but it
// should always have display_name... see :metabase.lib.metadata.calculation/display-info schema
......@@ -202,3 +190,14 @@ export function fromLegacyColumn(
): ColumnMetadata {
return ML.legacy_column__GT_metadata(query, stageIndex, columnOrField);
}
export function queryDisplayInfo(query: Query): QueryDisplayInfo {
/**
* Even though it seems weird to pass the same query two times,
* this function follows the same pattern as the other display_info overloads.
* The first two parameters are always a query, and a stage index.
* The third parameter is what you would like to have the info about.
* It just only happens that the thing we're examining is (again) the query itself.
*/
return ML.display_info(query, -1, query);
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment