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
047ab069
Commit
047ab069
authored
8 years ago
by
Cam Saül
Browse files
Options
Downloads
Patches
Plain Diff
Minor style tweaks for metabase.driver.redshift
parent
2dadec61
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/metabase/driver/redshift.clj
+12
-12
12 additions, 12 deletions
src/metabase/driver/redshift.clj
with
12 additions
and
12 deletions
src/metabase/driver/redshift.clj
+
12
−
12
View file @
047ab069
...
...
@@ -10,24 +10,24 @@
[
metabase.util
:as
u
]
[
metabase.util.korma-extensions
:as
kx
]))
(
defn-
connection-details->spec
[
_
details
]
(
defn-
connection-details->spec
[
details
]
(
kdb/postgres
(
merge
details
postgres/ssl-params
)))
; always connect to redshift over SSL
(
defn-
date-interval
[
_
unit
amount
]
(
defn-
date-interval
[
unit
amount
]
(
k/raw
(
format
"(GETDATE() + INTERVAL '%d %s')"
(
int
amount
)
(
name
unit
))))
(
defn-
unix-timestamp->timestamp
[
_
expr
seconds-or-milliseconds
]
(
defn-
unix-timestamp->timestamp
[
expr
seconds-or-milliseconds
]
(
case
seconds-or-milliseconds
:seconds
(
kx/+
(
k/raw
"TIMESTAMP '1970-01-01T00:00:00Z'"
)
(
kx/*
expr
(
k/raw
"INTERVAL '1 second'"
)))
:milliseconds
(
recur
nil
(
kx//
expr
1000
)
:seconds
)))
:milliseconds
(
recur
(
kx//
expr
1000
)
:seconds
)))
;; The Postgres JDBC .getImportedKeys method doesn't work for Redshift, and we're not allowed to access information_schema.constraint_column_usage,
;; so we'll have to use this custom query instead
;; See also: [Related Postgres JDBC driver issue on GitHub](https://github.com/pgjdbc/pgjdbc/issues/79)
;; [How to access the equivalent of information_schema.constraint_column_usage in Redshift](https://forums.aws.amazon.com/thread.jspa?threadID=133514)
(
defn-
describe-table-fks
[
_
database
table
]
(
defn-
describe-table-fks
[
database
table
]
(
set
(
for
[
fk
(
jdbc/query
(
sql/db->jdbc-connection-spec
database
)
[
"SELECT source_column.attname AS \"fk-column-name\",
dest_table.relname AS \"dest-table-name\",
...
...
@@ -47,9 +47,9 @@
AND dest_column.attnum = ANY(c.confkey)"
(
:name
table
)
(
:schema
table
)])]
{
:fk-column-name
(
:fk-column-name
fk
)
:dest-table
{
:name
(
:dest-table-name
fk
)
:schema
(
:dest-table-schema
fk
)}
{
:fk-column-name
(
:fk-column-name
fk
)
:dest-table
{
:name
(
:dest-table-name
fk
)
:schema
(
:dest-table-schema
fk
)}
:dest-column-name
(
:dest-column-name
fk
)})))
(
defrecord
RedshiftDriver
[]
...
...
@@ -59,8 +59,8 @@
(
u/strict-extend
RedshiftDriver
driver/IDriver
(
merge
(
sql/IDriverSQLDefaultsMixin
)
{
:date-interval
date-interval
:describe-table-fks
describe-table-fks
{
:date-interval
(
u/drop-first-arg
date-interval
)
:describe-table-fks
(
u/drop-first-arg
describe-table-fks
)
:details-fields
(
constantly
[{
:name
"host"
:display-name
"Host"
:placeholder
"my-cluster-name.abcd1234.us-east-1.redshift.amazonaws.com"
...
...
@@ -85,10 +85,10 @@
sql/ISQLDriver
(
merge
postgres/PostgresISQLDriverMixin
{
:connection-details->spec
connection-details->spec
{
:connection-details->spec
(
u/drop-first-arg
connection-details->spec
)
:current-datetime-fn
(
constantly
(
k/sqlfn*
:GETDATE
))
:set-timezone-sql
(
constantly
nil
)
:unix-timestamp->timestamp
unix-timestamp->timestamp
}
:unix-timestamp->timestamp
(
u/drop-first-arg
unix-timestamp->timestamp
)
}
;; HACK ! When we test against Redshift we use a session-unique schema so we can run simultaneous tests against a single remote host;
;; when running tests tell the sync process to ignore all the other schemas
(
when
config/is-test?
...
...
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