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
ba070a07
Commit
ba070a07
authored
10 years ago
by
Cam Saul
Browse files
Options
Downloads
Patches
Plain Diff
Structured QP now returns useful error responses
parent
dea93ca6
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/generic_sql/query_processor.clj
+10
-4
10 additions, 4 deletions
src/metabase/driver/generic_sql/query_processor.clj
test/metabase/driver/generic_sql/query_processor_test.clj
+15
-0
15 additions, 0 deletions
test/metabase/driver/generic_sql/query_processor_test.clj
with
25 additions
and
4 deletions
src/metabase/driver/generic_sql/query_processor.clj
+
10
−
4
View file @
ba070a07
...
...
@@ -47,10 +47,16 @@
{
:pre
[(
integer?
(
:database
query
))
; double check that the query being passed is valid
(
map?
(
:query
query
))
(
=
(
name
(
:type
query
))
"query"
)]}
(
->>
(
process
query
)
eval
(
post-process
query
)
(
annotate/annotate
query
)))
(
try
(
->>
(
process
query
)
eval
(
post-process
query
)
(
annotate/annotate
query
))
(
catch
java.sql.SQLException
e
{
:status
:failed
:error
(
->>
(
.getMessage
e
)
; error message comes back like "Error message ... [status-code]
(
re-find
#
"(?s)(^.*)\s+\[[\d-]+\]$"
)
; status code isn't useful and makes unit tests hard to write so strip it off
second
)})))
; (?s) = Pattern.DOTALL - tell regex `.` to match newline characters as well
(
defn
process-and-run
...
...
This diff is collapsed.
Click to expand it.
test/metabase/driver/generic_sql/query_processor_test.clj
+
15
−
0
View file @
ba070a07
...
...
@@ -436,3 +436,18 @@
;; Rows come back like `[value timestamp]` but it is hard to compare timestamps directly since the values that come back are casted
;; to Dates and the exact value depends on the locale of the machine running the tests. So just drop the timestamps from the results.
(
update-in
[
:data
:rows
]
(
partial
map
first
))))
;; # ERROR RESPONSES
;; Check that we get an error response formatted the way we'd expect
(
expect
{
:status
:failed
:error
"Column \"CHECKINS.NAME\" not found; SQL statement:\nSELECT \"CHECKINS\".* FROM \"CHECKINS\" WHERE (\"CHECKINS\".\"NAME\" = ?)"
}
(
process-and-run
{
:database
@
db-id
:type
:query
:query
{
:source_table
(
table->id
:checkins
)
:filter
[
"="
(
field->id
:venues
:name
)
1
]
; wrong Field
:aggregation
[
"rows"
]
:breakout
[
nil
]
:limit
nil
}}))
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