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
8911f653
Commit
8911f653
authored
9 years ago
by
Cam Saül
Browse files
Options
Downloads
Patches
Plain Diff
g2g
parent
610a119b
Branches
Branches containing commit
Tags
Tags containing commit
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
+28
-54
28 additions, 54 deletions
src/metabase/driver/query_processor/annotate.clj
with
28 additions
and
54 deletions
src/metabase/driver/query_processor/annotate.clj
+
28
−
54
View file @
8911f653
...
...
@@ -106,29 +106,6 @@
(
trace-lvars
"*"
out
)
(
==
out
ag-field
)))))
(
defn
y
[]
(
require
'metabase.driver
)
(
@
(
ns-resolve
'metabase.driver
'process-query
)
{
:database
320
,
:type
"query"
,
:query
{
:source_table
371
,
:aggregation
[
"rows"
]
,
:breakout
[]
,
:filter
[]}}))
;; (require '[metabase.test.data :refer [db-id id]])
(
defn
x
[]
(
@
(
ns-resolve
'metabase.driver
'process-query
)
{
:database
339
,
:type
"query"
,
:query
{
:source_table
820
,
:aggregation
[
"count"
]
,
:breakout
[[
"fk->"
8896
8855
]]}}))
(
defn
y*
[
n
]
(
dorun
(
repeatedly
n
y
)))
(
defn-
unknown-field
°
[
field-name
out
]
(
all
(
==
out
{
:base-type
:UnknownField
...
...
@@ -216,8 +193,34 @@
(
name<
f1
f2
)))
((
clause-pos<
f1
f2
)))))))))
(
defn-
fk-info-added
°
[
field
]
)
(
defn-
resolve+order-cols
[{
:keys
[
result-keys
]
,
:as
query
}]
(
when
(
seq
result-keys
)
(
first
(
let
[
fields
(
vec
(
lvars
(
count
result-keys
)))
known-field
°
(
field
°
query
)]
(
run
1
[
q
]
(
everyg
(
fn
[[
result-key
field
]]
(
conda
((
known-field
°
result-key
field
))
((
unknown-field
°
result-key
field
))))
(
zipmap
result-keys
fields
))
(
sorted-permutation
°
(
fields-sorted
°
query
)
fields
q
))))))
;;; # ---------------------------------------- COLUMN DETAILS ----------------------------------------
;; Format the results in the way the front-end expects.
(
defn-
format-col
[
col
]
(
merge
{
:description
nil
:id
nil
:table_id
nil
}
(
->
col
(
set/rename-keys
{
:base-type
:base_type
:field-id
:id
:field-name
:name
:special-type
:special_type
:table-id
:table_id
})
(
dissoc
:position
))))
(
defn-
add-fields-extra-info
"Add `:extra_info` about `ForeignKeys` to `Fields` whose `special_type` is `:fk`."
...
...
@@ -248,35 +251,6 @@
:extra_info
(
if-not
dest-field
{}
{
:target_table_id
(
:table_id
dest-field
)})))))))
(
defn-
resolve+order-cols
[{
:keys
[
result-keys
]
,
:as
query
}]
(
when
(
seq
result-keys
)
(
first
(
let
[
fields
(
vec
(
lvars
(
count
result-keys
)))
known-field
°
(
field
°
query
)]
(
run
1
[
q
]
(
everyg
(
fn
[[
result-key
field
]]
(
conda
((
known-field
°
result-key
field
))
((
unknown-field
°
result-key
field
))))
(
zipmap
result-keys
fields
))
(
sorted-permutation
°
(
fields-sorted
°
query
)
fields
q
))))))
;;; # ---------------------------------------- COLUMN DETAILS ----------------------------------------
;; Format the results in the way the front-end expects.
(
defn-
format-col
[
col
]
(
merge
{
:description
nil
:id
nil
:table_id
nil
}
(
->
col
(
set/rename-keys
{
:base-type
:base_type
:field-id
:id
:field-name
:name
:special-type
:special_type
:table-id
:table_id
})
(
dissoc
:position
))))
(
defn
post-annotate
[
qp
]
(
fn
[
query
]
(
let
[
results
(
qp
query
)
...
...
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