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
f0da2c16
Commit
f0da2c16
authored
9 years ago
by
Cam Saul
Browse files
Options
Downloads
Patches
Plain Diff
Limit max # of result rows returned to 2000
parent
dac4846b
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/metabase/driver/query_processor.clj
+21
-5
21 additions, 5 deletions
src/metabase/driver/query_processor.clj
test/metabase/driver/query_processor_test.clj
+9
-0
9 additions, 0 deletions
test/metabase/driver/query_processor_test.clj
with
30 additions
and
5 deletions
src/metabase/driver/query_processor.clj
+
21
−
5
View file @
f0da2c16
...
...
@@ -159,6 +159,20 @@
rows
values
)]
(
assoc
results
:rows
rows
))))
;; ### LIMIT-MAX-RESULT-ROWS
(
def
^
:const
max-result-rows
"Maximum number of rows the QP should ever return."
2000
)
(
defn
limit-max-result-rows
"Limit the number of rows returned in RESULTS to `max-result-rows`."
[
results
]
{
:pre
[(
map?
results
)
(
sequential?
(
:rows
results
))]}
(
assoc
results
:rows
(
take
max-result-rows
(
:rows
results
))))
;; ### ADD-ROW-COUNT-AND-STATUS
(
defn
add-row-count-and-status
...
...
@@ -177,11 +191,13 @@
(
defn
post-process
"Apply post-processing steps to the RESULTS of a QUERY, such as applying cumulative sum."
[
driver
query
results
]
(
->>
(
case
(
keyword
(
:type
query
))
:native
results
:query
(
let
[
query
(
:query
query
)]
(
->>
results
(
post-process-cumulative-sum
query
))))
{
:pre
[(
map?
query
)
(
map?
results
)]}
(
->>
results
limit-max-result-rows
(
#
(
case
(
keyword
(
:type
query
))
:native
%
:query
(
post-process-cumulative-sum
(
:query
query
)
%
)))
add-row-count-and-status
))
...
...
This diff is collapsed.
Click to expand it.
test/metabase/driver/query_processor_test.clj
+
9
−
0
View file @
f0da2c16
...
...
@@ -3,6 +3,7 @@
(
:require
[
expectations
:refer
:all
]
[
metabase.db
:refer
:all
]
[
metabase.driver
:as
driver
]
[
metabase.driver.query-processor
:refer
:all
]
(
metabase.models
[
table
:refer
[
Table
]])
[
metabase.test.data.datasets
:as
datasets
:refer
[
*dataset*
expect-with-all-datasets
]]))
...
...
@@ -519,6 +520,14 @@
;; # POST PROCESSING TESTS
;; ## LIMIT-MAX-RESULT-ROWS
;; Apply limit-max-result-rows to an infinite sequence and make sure it gets capped at `max-result-rows`
(
expect
max-result-rows
(
count
(
->>
{
:rows
(
repeat
[
:ok
])}
limit-max-result-rows
:rows
)))
;; ## CUMULATIVE SUM
;; TODO - Should we move this into IDataset? It's only used here, but the logic might get a little more compilcated when we add more drivers
...
...
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