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
cfbb8218
Commit
cfbb8218
authored
9 years ago
by
Cam Saül
Browse files
Options
Downloads
Patches
Plain Diff
squash! squash! Rework the way field flattening happens in annotate
parent
b8e5b17c
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/metabase/driver/query_processor/annotate.clj
+6
-6
6 additions, 6 deletions
src/metabase/driver/query_processor/annotate.clj
with
6 additions
and
6 deletions
src/metabase/driver/query_processor/annotate.clj
+
6
−
6
View file @
cfbb8218
...
...
@@ -83,12 +83,12 @@
"Flatten a group of fields, keeping those which are more important when duplicates exist."
[
fields
]
{
:pre
[(
every?
identity
fields
)]}
(
let
[
path-importance
(
fn
[{[
k
]
:path
}]
(
cond
(
=
k
:breakout
)
0
; lower number = higher importance, because `sort` is ascending
(
=
k
:fields
)
1
; more important versions of fields are the ones we'll actually see in results,
:else
2
))
]
; so look at each field's :path. For now, it's enough just to look at the first element.
(
distinct
(
sort-by
path-importance
fields
))))
; this is important so we don't use return the wrong version of a Field (e.g. with the wrong unit
)
(
distinct
(
sort-by
(
fn
[{[
k
]
:path
}]
; more important versions of fields are the ones we'll actually see in results,
(
cond
; this is important so we don't use return the wrong version of a Field (e.g. with the wrong unit)
(
=
k
:breakout
)
0
; so look at each field's :path. For now, it's enough just to look at the first element.
(
=
k
:fields
)
1
; (lower number = higher importance, because `sort` is ascending)
:else
2
))
fields
))
)
(
defn-
flatten-collect-fields
"Collect fields from COLL, and remove duplicates."
...
...
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