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
8e37a2eb
Unverified
Commit
8e37a2eb
authored
8 years ago
by
Cam Saül
Browse files
Options
Downloads
Patches
Plain Diff
Cleanup #2872
parent
d318df41
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/druid/query_processor.clj
+25
-26
25 additions, 26 deletions
src/metabase/driver/druid/query_processor.clj
with
25 additions
and
26 deletions
src/metabase/driver/druid/query_processor.clj
+
25
−
26
View file @
8e37a2eb
...
...
@@ -225,20 +225,18 @@
"}"
)
:year
(
extract
:timeFormat
"yyyy"
)))
(
defn-
unit->granularity
[
unit
]
(
let
[
iso-period
(
case
unit
:minute
"PT1M"
:hour
"PT1H"
:day
"P1D"
:week
"P1W"
:month
"P1M"
:quarter
"P3M"
:year
"P1Y"
)]
{
:type
"period"
:period
iso-period
:timeZone
(
or
(
get-in
*query*
[
:settings
:report-timezone
])
"UTC"
)}))
(
defn-
unit->granularity
[
unit
]
{
:type
"period"
:period
(
case
unit
:minute
"PT1M"
:hour
"PT1H"
:day
"P1D"
:week
"P1W"
:month
"P1M"
:quarter
"P3M"
:year
"P1Y"
)
:timeZone
(
or
(
get-in
*query*
[
:settings
:report-timezone
])
"UTC"
)})
(
def
^
:private
^
:const
units-that-need-post-processing-int-parsing
"`extract:timeFormat` always returns a string; there are cases where we'd like to return an integer instead, such as `:day-of-month`.
...
...
@@ -445,7 +443,8 @@
(
let
[
field
(
->rvalue
field
)
breakout-field
(
->rvalue
breakout-field
)
sort-by-breakout?
(
=
field
breakout-field
)]
(
if
(
and
sort-by-breakout?
(
=
direction
:descending
))
(
if
(
and
sort-by-breakout?
(
=
direction
:descending
))
(
assoc
druid-query
:descending
true
)
druid-query
)))
...
...
@@ -507,20 +506,20 @@
;;; ## Build + Log + Process Query
(
def
^
:private
^
:const
timeseries-units
#
{
:minute
:hour
:day
:week
:month
:quarter
:year
})
(
defn-
druid-query-type
"What type of Druid query type should we perform?"
[{
breakout-fields
:breakout,
{
ag-type
:aggregation-type
}
:aggregation,
limit
:limit
}]
(
let
[
breakouts
(
condp
=
(
count
breakout-fields
)
0
:none
1
:one
:many
)
agg?
(
boolean
(
and
ag-type
(
not=
ag-type
:rows
)))
period-set
#
{
:minute
:hour
:day
:week
:month
:quarter
:year
}
ts?
(
and
(
instance?
DateTimeField
(
first
breakout-fields
))
;; Checks whether the query is a timeseries
(
contains?
period-set
(
:unit
(
first
breakout-fields
)))
;; (excludes x-of-y type breakouts)
(
nil?
limit
))]
;; (excludes queries with LIMIT)
(
let
[
breakouts
(
condp
=
(
count
breakout-fields
)
0
:none
1
:one
:many
)
agg?
(
boolean
(
and
ag-type
(
not=
ag-type
:rows
)))
ts?
(
and
(
instance?
DateTimeField
(
first
breakout-fields
))
; Checks whether the query is a timeseries
(
contains?
timeseries-units
(
:unit
(
first
breakout-fields
)))
; (excludes x-of-y type breakouts)
(
nil?
limit
))]
; (excludes queries with LIMIT)
(
match
[
breakouts
agg?
ts?
]
[
:none
false
_
]
::select
[
:none
true
_
]
::total
...
...
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