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
0a17d1f7
Commit
0a17d1f7
authored
7 years ago
by
Cam Saül
Browse files
Options
Downloads
Plain Diff
Merge branch 'sort-druid-select' [ci drivers]
parents
4bdcdca5
8e70ad97
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/metabase/driver/druid/query_processor.clj
+9
-8
9 additions, 8 deletions
src/metabase/driver/druid/query_processor.clj
test/metabase/timeseries_query_processor_test.clj
+60
-0
60 additions, 0 deletions
test/metabase/timeseries_query_processor_test.clj
with
69 additions
and
8 deletions
src/metabase/driver/druid/query_processor.clj
+
9
−
8
View file @
0a17d1f7
...
...
@@ -577,15 +577,16 @@
{
:dimension
(
->rvalue
field
)
:direction
direction
}))))
(
defmethod
handle-order-by
::grouped-timeseries
[
_
{[
breakout-field
]
:breakout,
[{
field
:field,
direction
:direction
}]
:order-by
}
druid-query
]
(
let
[
field
(
->rvalue
field
)
breakout-field
(
->rvalue
breakout-field
)
sort-by-breakout?
(
=
field
breakout-field
)]
(
if
(
and
sort-by-breakout?
(
=
direction
:descending
))
(
assoc
druid-query
:descending
true
)
druid-query
)))
;; Handle order by timstamp field
(
defn-
handle-order-by-timestamp
[
field
direction
druid-query
]
(
assoc
druid-query
:descending
(
and
(
instance?
DateTimeField
field
)
(
=
direction
:descending
))))
(
defmethod
handle-order-by
::grouped-timeseries
[
_
{[{
field
:field,
direction
:direction
}]
:order-by
}
druid-query
]
(
handle-order-by-timestamp
field
direction
druid-query
))
(
defmethod
handle-order-by
::select
[
_
{[{
field
:field,
direction
:direction
}]
:order-by
}
druid-query
]
(
handle-order-by-timestamp
field
direction
druid-query
))
;;; ### handle-fields
...
...
This diff is collapsed.
Click to expand it.
test/metabase/timeseries_query_processor_test.clj
+
60
−
0
View file @
0a17d1f7
...
...
@@ -69,6 +69,44 @@
(
data
(
data/run-query
checkins
(
ql/limit
2
))))
;;; "bare rows" query, limit, order-by timestamp desc
(
expect-with-timeseries-dbs
{
:columns
[
"id"
"timestamp"
"count"
"user_last_login"
"user_name"
"venue_category_name"
"venue_latitude"
"venue_longitude"
"venue_name"
"venue_price"
]
:rows
[[
"693"
,
"2015-12-29T08:00:00.000Z"
,
1
,
"2014-07-03T19:30:00.000Z"
,
"Frans Hevel"
,
"Mexican"
,
"34.0489"
,
"-118.238"
,
"Señor Fish"
,
"2"
]
[
"570"
,
"2015-12-26T08:00:00.000Z"
,
1
,
"2014-07-03T01:30:00.000Z"
,
"Kfir Caj"
,
"Chinese"
,
"37.7949"
,
"-122.406"
,
"Empress of China"
,
"3"
]]}
(
data
(
data/run-query
checkins
(
ql/order-by
(
ql/desc
$timestamp
))
(
ql/limit
2
))))
;;; "bare rows" query, limit, order-by timestamp asc
(
expect-with-timeseries-dbs
{
:columns
[
"id"
"timestamp"
"count"
"user_last_login"
"user_name"
"venue_category_name"
"venue_latitude"
"venue_longitude"
"venue_name"
"venue_price"
]
:rows
[[
"931"
,
"2013-01-03T08:00:00.000Z"
,
1
,
"2014-01-01T08:30:00.000Z"
,
"Simcha Yan"
,
"Thai"
,
"34.094"
,
"-118.344"
,
"Kinaree Thai Bistro"
,
"1"
]
[
"285"
,
"2013-01-10T08:00:00.000Z"
,
1
,
"2014-07-03T01:30:00.000Z"
,
"Kfir Caj"
,
"Thai"
,
"34.1021"
,
"-118.306"
,
"Ruen Pair Thai Restaurant"
,
"2"
]]}
(
data
(
data/run-query
checkins
(
ql/order-by
(
ql/asc
$timestamp
))
(
ql/limit
2
))))
;;; fields clause
(
expect-with-timeseries-dbs
{
:columns
[
"venue_name"
"venue_category_name"
"timestamp"
]
,
...
...
@@ -78,6 +116,28 @@
(
ql/fields
$venue_name
$venue_category_name
)
(
ql/limit
2
))))
;;; fields clause, order by timestamp asc
(
expect-with-timeseries-dbs
{
:columns
[
"venue_name"
"venue_category_name"
"timestamp"
]
,
:rows
[[
"Kinaree Thai Bistro"
"Thai"
"2013-01-03T08:00:00.000Z"
]
[
"Ruen Pair Thai Restaurant"
"Thai"
"2013-01-10T08:00:00.000Z"
]]}
(
data
(
data/run-query
checkins
(
ql/fields
$venue_name
$venue_category_name
)
(
ql/order-by
(
ql/asc
$timestamp
))
(
ql/limit
2
))))
;;; fields clause, order by timestamp desc
(
expect-with-timeseries-dbs
{
:columns
[
"venue_name"
"venue_category_name"
"timestamp"
]
,
:rows
[[
"Señor Fish"
"Mexican"
"2015-12-29T08:00:00.000Z"
]
[
"Empress of China"
"Chinese"
"2015-12-26T08:00:00.000Z"
]]}
(
data
(
data/run-query
checkins
(
ql/fields
$venue_name
$venue_category_name
)
(
ql/order-by
(
ql/desc
$timestamp
))
(
ql/limit
2
))))
;;; count
(
expect-with-timeseries-dbs
[
1000
]
...
...
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