This repository has been archived by the owner on May 17, 2022. It is now read-only.
forked from getredash/redash
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Schema Viewer Drawer (getredash#3291)
* Process extra column metadata for a few sql-based data sources. * Add Table and Column metadata tables. * Periodically update table and column schema tables in a celery task. * Fetching schema returns data from table and column metadata tables. * Add tests for backend changes. * Front-end shows extra table metadata and uses new schema response. * Delete datasource schema data when deleting a data source. * Process and store data source schema when a data source is first created or after a migration. * Tables should have a unique name per datasource. * Addressing review comments. * Update migration file for mixins. * Appease PEP8 * Upgrade migration file for rebase. * Cascade delete. * Adding org_id * Remove redundant column and table prefixes. * Non-existing tables and columns should be filtered out on the server side not client side. * Fetching table samples should be optional and should happen in a separate task per table. * Allow users to force a schema refresh. * Use updated_at to help prune old schema metadata periodically. * Using settings.SCHEMAS_REFRESH_QUEUE
- Loading branch information
Showing
24 changed files
with
765 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { react2angular } from 'react2angular'; | ||
import Drawer from 'antd/lib/drawer'; | ||
import Table from 'antd/lib/table'; | ||
|
||
import { DataSourceMetadata } from '@/components/proptypes'; | ||
|
||
class SchemaData extends React.PureComponent { | ||
static propTypes = { | ||
show: PropTypes.bool.isRequired, | ||
onClose: PropTypes.func.isRequired, | ||
tableName: PropTypes.string, | ||
tableMetadata: PropTypes.arrayOf(DataSourceMetadata), | ||
}; | ||
|
||
static defaultProps = { | ||
tableName: '', | ||
tableMetadata: [], | ||
}; | ||
|
||
render() { | ||
const columns = [{ | ||
title: 'Column Name', | ||
dataIndex: 'name', | ||
width: 400, | ||
key: 'name', | ||
}, { | ||
title: 'Column Type', | ||
dataIndex: 'type', | ||
width: 400, | ||
key: 'type', | ||
}, { | ||
title: 'Example', | ||
dataIndex: 'example', | ||
width: 400, | ||
key: 'example', | ||
}]; | ||
|
||
return ( | ||
<Drawer | ||
title={this.props.tableName} | ||
closable={false} | ||
placement="bottom" | ||
height={500} | ||
onClose={this.props.onClose} | ||
visible={this.props.show} | ||
> | ||
<Table | ||
dataSource={this.props.tableMetadata} | ||
pagination={false} | ||
scroll={{ y: 350 }} | ||
size="small" | ||
columns={columns} | ||
/> | ||
</Drawer> | ||
); | ||
} | ||
} | ||
|
||
export default function init(ngModule) { | ||
ngModule.component('schemaData', react2angular(SchemaData, null, [])); | ||
} | ||
|
||
init.init = true; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
"""Add column metadata and table metadata | ||
Revision ID: 280daa582976 | ||
Revises: e5c7a4e2df4d | ||
Create Date: 2019-01-24 18:23:53.040608 | ||
""" | ||
from alembic import op | ||
import sqlalchemy as sa | ||
|
||
|
||
# revision identifiers, used by Alembic. | ||
revision = '280daa582976' | ||
down_revision = 'e5c7a4e2df4d' | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade(): | ||
op.create_table( | ||
'table_metadata', | ||
sa.Column('updated_at', sa.DateTime(timezone=True), nullable=False), | ||
sa.Column('created_at', sa.DateTime(timezone=True), nullable=False), | ||
sa.Column('id', sa.Integer(), nullable=False), | ||
sa.Column('org_id', sa.Integer(), nullable=False), | ||
sa.Column('data_source_id', sa.Integer(), nullable=False), | ||
sa.Column('exists', sa.Boolean(), nullable=False), | ||
sa.Column('name', sa.String(length=255), nullable=False), | ||
sa.Column('description', sa.String(length=4096), nullable=True), | ||
sa.Column('column_metadata', sa.Boolean(), nullable=False), | ||
sa.Column('sample_query', sa.Text(), nullable=True), | ||
sa.ForeignKeyConstraint(['data_source_id'], ['data_sources.id'], ondelete="CASCADE"), | ||
sa.ForeignKeyConstraint(['org_id'], ['organizations.id.id']), | ||
sa.PrimaryKeyConstraint('id') | ||
) | ||
op.create_table( | ||
'column_metadata', | ||
sa.Column('updated_at', sa.DateTime(timezone=True), nullable=False), | ||
sa.Column('created_at', sa.DateTime(timezone=True), nullable=False), | ||
sa.Column('id', sa.Integer(), nullable=False), | ||
sa.Column('org_id', sa.Integer(), nullable=False), | ||
sa.Column('table_id', sa.Integer(), nullable=False), | ||
sa.Column('name', sa.String(length=255), nullable=False), | ||
sa.Column('type', sa.String(length=255), nullable=True), | ||
sa.Column('example', sa.String(length=4096), nullable=True), | ||
sa.Column('exists', sa.Boolean(), nullable=False), | ||
sa.ForeignKeyConstraint(['table_id'], ['table_metadata.id'], ondelete="CASCADE"), | ||
sa.ForeignKeyConstraint(['org_id'], ['organizations.id.id']), | ||
sa.PrimaryKeyConstraint('id') | ||
) | ||
|
||
|
||
def downgrade(): | ||
op.drop_table('column_metadata') | ||
op.drop_table('table_metadata') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.