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
b424ddba
Unverified
Commit
b424ddba
authored
2 years ago
by
Case Nelson
Committed by
GitHub
2 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Add current-limit setter for a query limit (#29376)
* Add current-limit setter for a query limit * Add docstring
parent
3b69bba3
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/metabase/lib/core.cljc
+1
-0
1 addition, 0 deletions
src/metabase/lib/core.cljc
src/metabase/lib/limit.cljc
+8
-0
8 additions, 0 deletions
src/metabase/lib/limit.cljc
test/metabase/lib/limit_test.cljc
+16
-0
16 additions, 0 deletions
test/metabase/lib/limit_test.cljc
with
25 additions
and
0 deletions
src/metabase/lib/core.cljc
+
1
−
0
View file @
b424ddba
...
...
@@ -89,6 +89,7 @@
join-clause
joins
]
[
lib.limit
current-limit
limit
]
[
lib.order-by
order-by
...
...
This diff is collapsed.
Click to expand it.
src/metabase/lib/limit.cljc
+
8
−
0
View file @
b424ddba
...
...
@@ -24,3 +24,11 @@
(
if
n
(
assoc
stage
:limit
n
)
(
dissoc
stage
:limit
))))))
(
mu/defn
current-limit
:-
[
:maybe
::lib.schema.common/int-greater-than-zero
]
"Get the maximum number of rows to be returned by a stage of a query. `nil` indicates there is no limit"
([
query
:-
::lib.schema/query
]
(
current-limit
query
-1
))
([
query
:-
::lib.schema/query
stage-number
:-
:int
]
(
:limit
(
lib.util/query-stage
query
stage-number
))))
This diff is collapsed.
Click to expand it.
test/metabase/lib/limit_test.cljc
+
16
−
0
View file @
b424ddba
...
...
@@ -18,3 +18,19 @@
(
is
(
=
::not-found
(
limit
(
->
query
(
lib/limit
nil
)))))))))
(
deftest
^
:parallel
current-limit-test
(
testing
"Last stage"
(
let
[
query
(
lib/query-for-table-name
meta/metadata-provider
"VENUES"
)]
(
is
(
nil?
(
lib/current-limit
query
)))
(
is
(
nil?
(
lib/current-limit
query
-1
)))
(
is
(
=
100
(
lib/current-limit
(
lib/limit
query
100
))))
(
is
(
=
100
(
lib/current-limit
(
lib/limit
query
100
)
-1
)))))
(
testing
"First stage"
(
let
[
query
(
lib/query
meta/metadata-provider
{
:database
(
meta/id
)
:type
:query
:query
{
:source-query
{
:source-table
(
meta/id
:venues
)}}})]
(
is
(
nil?
(
lib/current-limit
query
0
)))
(
is
(
nil?
(
lib/current-limit
query
1
)))
(
is
(
=
100
(
lib/current-limit
(
lib/limit
query
0
100
)
0
)))
(
is
(
nil?
(
lib/current-limit
query
1
))))))
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