Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
Metabase
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Engineering Digital Service
Metabase
Commits
f0cc468f
Commit
f0cc468f
authored
6 years ago
by
Tom Robinson
Browse files
Options
Downloads
Patches
Plain Diff
Make query.fieldReferenceForColumn and fieldRefForColumn support aggregation indexes correctly
parent
7f517fb0
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
frontend/src/metabase-lib/lib/queries/StructuredQuery.js
+7
-5
7 additions, 5 deletions
frontend/src/metabase-lib/lib/queries/StructuredQuery.js
frontend/src/metabase/lib/dataset.js
+14
-3
14 additions, 3 deletions
frontend/src/metabase/lib/dataset.js
with
21 additions
and
8 deletions
frontend/src/metabase-lib/lib/queries/StructuredQuery.js
+
7
−
5
View file @
f0cc468f
...
...
@@ -816,17 +816,19 @@ export default class StructuredQuery extends AtomicQuery {
}
else
if
(
column
.
expression_name
!=
null
)
{
return
[
"
expression
"
,
column
.
expression_name
];
}
else
if
(
column
.
source
===
"
aggregation
"
)
{
const
aggregationIndex
=
_
.
findIndex
(
this
.
aggregationDimensions
(),
dimension
=>
dimension
.
columnName
()
===
column
.
name
,
// HACK: ideally column would include the aggregation index directly
const
columnIndex
=
_
.
findIndex
(
this
.
columnNames
(),
name
=>
name
===
column
.
name
,
);
if
(
aggregatio
nIndex
>=
0
)
{
return
[
"
aggregation
"
,
aggregationIndex
]
;
if
(
colum
nIndex
>=
0
)
{
return
this
.
columnDimensions
()[
columnIndex
].
mbql
()
;
}
}
return
null
;
}
// TODO: better name may be parseDimension?
parseFieldReference
(
fieldRef
):
?
Dimension
{
const
dimension
=
Dimension
.
parseMBQL
(
fieldRef
,
this
.
_metadata
);
if
(
dimension
)
{
...
...
This diff is collapsed.
Click to expand it.
frontend/src/metabase/lib/dataset.js
+
14
−
3
View file @
f0cc468f
...
...
@@ -41,9 +41,13 @@ export const rangeForValue = (
/**
* Returns a MBQL field reference (ConcreteField) for a given result dataset column
* @param {Column} column Dataset result column
* @param {?Column[]} columns Full array of columns, unfortunately needed to determine the aggregation index
* @return {?ConcreteField} MBQL field reference
*/
export
function
fieldRefForColumn
(
column
:
Column
):
?
ConcreteField
{
export
function
fieldRefForColumn
(
column
:
Column
,
columns
?:
Column
[],
):
?
ConcreteField
{
if
(
column
.
id
!=
null
)
{
if
(
Array
.
isArray
(
column
.
id
))
{
// $FlowFixMe: sometimes col.id is a field reference (e.x. nested queries), if so just return it
...
...
@@ -55,9 +59,16 @@ export function fieldRefForColumn(column: Column): ?ConcreteField {
}
}
else
if
(
column
.
expression_name
!=
null
)
{
return
[
"
expression
"
,
column
.
expression_name
];
}
else
{
return
null
;
}
else
if
(
column
.
source
===
"
aggregation
"
&&
columns
)
{
// HACK: find the aggregation index, preferably this would be included on the column
const
aggIndex
=
columns
.
filter
(
c
=>
c
.
source
===
"
aggregation
"
)
.
indexOf
(
column
);
if
(
aggIndex
>=
0
)
{
return
[
"
aggregation
"
,
aggIndex
];
}
}
return
null
;
}
export
const
keyForColumn
=
(
column
:
Column
):
string
=>
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment