Merge pull request #78 from agnosticeng/schema
feat: fallback schema from comment
This commit is contained in:
@@ -14,11 +14,9 @@
|
||||
<style>
|
||||
ul {
|
||||
margin: 0;
|
||||
list-style: none;
|
||||
padding: 0;
|
||||
list-style: none;
|
||||
font-family: monospace;
|
||||
padding-bottom: 3px;
|
||||
padding-left: 5px;
|
||||
color: lightgray;
|
||||
}
|
||||
|
||||
|
||||
@@ -18,6 +18,8 @@
|
||||
|
||||
<SearchBar bind:value={search} />
|
||||
|
||||
{#each tree as node}
|
||||
<Tree {node} />
|
||||
{/each}
|
||||
<div>
|
||||
{#each tree as node}
|
||||
<Tree {node} />
|
||||
{/each}
|
||||
</div>
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="node">
|
||||
<div class="node" style:opacity={expanded ? 1 : 0.7 + level}>
|
||||
<button
|
||||
type="button"
|
||||
class:folder={node.type === 'group'}
|
||||
@@ -40,13 +40,9 @@
|
||||
{/if}
|
||||
</button>
|
||||
{#if node.type === 'group' && node.children && expanded}
|
||||
<div class="children">
|
||||
{#each node.children as child}
|
||||
<div class="tree-line">
|
||||
<Tree node={child} level={level + 1} />
|
||||
</div>
|
||||
{/each}
|
||||
</div>
|
||||
{#each node.children as child}
|
||||
<Tree node={child} level={level + 1} />
|
||||
{/each}
|
||||
{/if}
|
||||
{#if node.type === 'dataset' && expanded}
|
||||
<div class="dataset">
|
||||
@@ -62,6 +58,10 @@
|
||||
color: lightgray;
|
||||
}
|
||||
|
||||
.node {
|
||||
margin-left: 4px;
|
||||
}
|
||||
|
||||
button {
|
||||
background: transparent;
|
||||
border: none;
|
||||
@@ -69,7 +69,7 @@
|
||||
}
|
||||
|
||||
.folder.name {
|
||||
margin-bottom: 5px;
|
||||
margin-top: 1px;
|
||||
}
|
||||
|
||||
.name {
|
||||
@@ -80,13 +80,4 @@
|
||||
.name span {
|
||||
margin-left: 3px;
|
||||
}
|
||||
|
||||
.tree-line {
|
||||
border-left: 1px solid #333;
|
||||
padding-left: 3px;
|
||||
}
|
||||
|
||||
.children {
|
||||
margin-left: 4px;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -1,9 +1,27 @@
|
||||
WITH
|
||||
raw AS (
|
||||
SELECT
|
||||
t.name AS name,
|
||||
IF(t.as_select LIKE '%s3(%', 'S3', t.engine) AS engine,
|
||||
groupArray(map('name', c.name, 'type', c.type)) AS columns,
|
||||
any(comment) as comment
|
||||
FROM system.tables AS t
|
||||
LEFT JOIN system.columns AS c
|
||||
ON t.name = c.table
|
||||
WHERE database = currentDatabase()
|
||||
GROUP BY name, engine
|
||||
ORDER BY name
|
||||
)
|
||||
|
||||
SELECT
|
||||
t.name AS name,
|
||||
IF(t.as_select LIKE '%s3(%', 'S3', t.engine) AS engine,
|
||||
groupArray(map('name', c.name, 'type', c.type)) AS columns
|
||||
FROM system.tables AS t
|
||||
INNER JOIN system.columns AS c
|
||||
ON t.name = c.table
|
||||
WHERE database = currentDatabase()
|
||||
GROUP BY name, engine
|
||||
name,
|
||||
engine,
|
||||
IF(
|
||||
length(columns) > 0 and length(raw.columns[1]['name']) > 0,
|
||||
columns,
|
||||
JSONExtract(comment, 'columns', 'Array(Map(String,String))')
|
||||
) as columns,
|
||||
JSONExtractString(comment, 'short') as short,
|
||||
JSONExtractString(comment, 'url') as url,
|
||||
JSONExtractString(comment, 'usage') as usage
|
||||
FROM raw
|
||||
|
||||
Reference in New Issue
Block a user