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
0b41143b
Commit
0b41143b
authored
8 years ago
by
Michael Beer
Browse files
Options
Downloads
Patches
Plain Diff
fixup! wip: display nested object as columns
parent
dbed743e
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/crate.clj
+14
-15
14 additions, 15 deletions
src/metabase/driver/crate.clj
with
14 additions
and
15 deletions
src/metabase/driver/crate.clj
+
14
−
15
View file @
0b41143b
...
...
@@ -6,7 +6,7 @@
[
metabase.driver.generic-sql
:as
sql
]
[
metabase.util
:as
u
]
[
clojure.tools.logging
:as
log
])
(
:import
(
java.sql
DatabaseMetaData
)))
(
:import
(
java.sql
.
DatabaseMetaData
)))
(
def
^
:private
^
:const
column->base-type
"Map of Crate column types -> Field base types
...
...
@@ -59,17 +59,16 @@
(
defn-
describe-table-fields
[
database,
driver,
{
:keys
[
schema
name
]}]
(
set
(
doseq
[{
column_name
:column_name,
type_name
:type_name
}
(
jdbc/query
(
sql/db->jdbc-connection-spec
database
)
[(
format
"select column_name, data_type as type_name
from information_schema.columns
where table_name like '%s' and table_schema like '%s'"
name
schema
)])]
(
merge
{
:name
column_name
:custom
{
:column-type
type_name
}
:base-type
(
or
(
column->base-type
driver
(
keyword
type_name
))
(
do
(
log/warn
(
format
"Don't know how to map column type '%s' to a Field base_type, falling back to :type/*."
type_name
))
:type/*
))}))))
(
let
[
columns
(
jdbc/query
(
sql/db->jdbc-connection-spec
database
)
[(
format
"select column_name, data_type as type_name from information_schema.columns
where table_name like '%s' and table_schema like '%s'"
name
schema
)])]
(
set
(
for
[{
:keys
[
column_name
type_name
]}
columns
]
(
merge
{
:name
column_name
:custom
{
:column-type
type_name
}
:base-type
(
or
(
column->base-type
(
keyword
type_name
))
(
do
(
log/warn
(
format
"Don't know how to map column type '%s' to a Field base_type, falling back to :type/*."
type_name
))
:type/*
))})))))
(
defn-
add-table-pks
[
^
DatabaseMetaData
metadata,
table
]
...
...
@@ -85,9 +84,9 @@
(
defn-
describe-table
[
driver
database
table
]
(
sql/with-metadata
[
metadata
driver
database
]
(
->>
(
assoc
(
select-keys
table
[
:name
:schema
])
:fields
(
describe-table-fields
database
driver
table
))
;; find PKs and mark them
(
add-table-pks
metadata
))))
(
->>
(
assoc
(
select-keys
table
[
:name
:schema
])
:fields
(
describe-table-fields
database
driver
table
))
;; find PKs and mark them
(
add-table-pks
metadata
))))
(
defn-
field->alias
[
field
]
(
str
\"
(
name
field
)
\"
))
...
...
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