rhunwicks commented on issue #3302: Create a PandasDatasource URL: https://github.com/apache/incubator-superset/issues/3302#issuecomment-329083264 @xrmx the code is still very rough - I haven't pushed it to GitHub yet - partially because I want to make sure the directory structure matches your expectations in order to get it merged! I am also not planning to push it to GitHun until I have an actual working implementation that can do filtering and grouping, and we haven't got that far yet. However, we need to store metadata about the DataSources and the associated Columns and Metrics. The required metadata is very similar to that required for SqlaTable datasources, but not identical. So the migration just adds three new tables. Currently the migration looks like: ``` """Add PandasDatasource Revision ID: b2cd059e8803 Revises: ca69c70ec99b Create Date: 2017-08-30 09:33:40.431377 """ # revision identifiers, used by Alembic. revision = 'b2cd059e8803' down_revision = 'ca69c70ec99b' from alembic import op import sqlalchemy as sa import sqlalchemy_utils FORMATS = [ ('csv', 'CSV'), ('html', 'HTML') ] def upgrade(): # ### commands auto generated by Alembic - please adjust! ### op.create_table('pandasdatasources', sa.Column('created_on', sa.DateTime(), nullable=True), sa.Column('changed_on', sa.DateTime(), nullable=True), sa.Column('id', sa.Integer(), nullable=False), sa.Column('description', sa.Text(), nullable=True), sa.Column('default_endpoint', sa.Text(), nullable=True), sa.Column('is_featured', sa.Boolean(), nullable=True), sa.Column('filter_select_enabled', sa.Boolean(), nullable=True), sa.Column('offset', sa.Integer(), nullable=True), sa.Column('cache_timeout', sa.Integer(), nullable=True), sa.Column('params', sa.String(length=1000), nullable=True), sa.Column('perm', sa.String(length=1000), nullable=True), sa.Column('name', sa.String(length=100), nullable=False), sa.Column('source_url', sa.String(length=1000), nullable=False), sa.Column('format', sqlalchemy_utils.types.choice.ChoiceType(FORMATS), nullable=False), sa.Column('additional_parameters', sqlalchemy_utils.types.json.JSONType(), nullable=True), sa.Column('user_id', sa.Integer(), nullable=True), sa.Column('fetch_values_predicate', sa.String(length=1000), nullable=True), sa.Column('main_dttm_col', sa.String(length=250), nullable=True), sa.Column('created_by_fk', sa.Integer(), nullable=True), sa.Column('changed_by_fk', sa.Integer(), nullable=True), sa.ForeignKeyConstraint(['changed_by_fk'], ['ab_user.id'], ), sa.ForeignKeyConstraint(['created_by_fk'], ['ab_user.id'], ), sa.ForeignKeyConstraint(['user_id'], ['ab_user.id'], ), sa.PrimaryKeyConstraint('id') ) op.create_table('pandascolumns', sa.Column('created_on', sa.DateTime(), nullable=True), sa.Column('changed_on', sa.DateTime(), nullable=True), sa.Column('column_name', sa.String(length=255), nullable=True), sa.Column('verbose_name', sa.String(length=1024), nullable=True), sa.Column('is_active', sa.Boolean(), nullable=True), sa.Column('type', sa.String(length=32), nullable=True), sa.Column('groupby', sa.Boolean(), nullable=True), sa.Column('count_distinct', sa.Boolean(), nullable=True), sa.Column('sum', sa.Boolean(), nullable=True), sa.Column('avg', sa.Boolean(), nullable=True), sa.Column('max', sa.Boolean(), nullable=True), sa.Column('min', sa.Boolean(), nullable=True), sa.Column('filterable', sa.Boolean(), nullable=True), sa.Column('description', sa.Text(), nullable=True), sa.Column('id', sa.Integer(), nullable=False), sa.Column('pandasdatasource_id', sa.Integer(), nullable=True), sa.Column('created_by_fk', sa.Integer(), nullable=True), sa.Column('changed_by_fk', sa.Integer(), nullable=True), sa.ForeignKeyConstraint(['changed_by_fk'], ['ab_user.id'], ), sa.ForeignKeyConstraint(['created_by_fk'], ['ab_user.id'], ), sa.ForeignKeyConstraint(['pandasdatasource_id'], ['pandasdatasources.id'], ), sa.PrimaryKeyConstraint('id') ) op.create_table('pandasmetrics', sa.Column('created_on', sa.DateTime(), nullable=True), sa.Column('changed_on', sa.DateTime(), nullable=True), sa.Column('metric_name', sa.String(length=512), nullable=True), sa.Column('verbose_name', sa.String(length=1024), nullable=True), sa.Column('metric_type', sa.String(length=32), nullable=True), sa.Column('description', sa.Text(), nullable=True), sa.Column('is_restricted', sa.Boolean(), nullable=True), sa.Column('d3format', sa.String(length=128), nullable=True), sa.Column('id', sa.Integer(), nullable=False), sa.Column('pandasdatasource_id', sa.Integer(), nullable=True), sa.Column('source', sa.Text(), nullable=True), sa.Column('expression', sa.Text(), nullable=True), sa.Column('created_by_fk', sa.Integer(), nullable=True), sa.Column('changed_by_fk', sa.Integer(), nullable=True), sa.ForeignKeyConstraint(['changed_by_fk'], ['ab_user.id'], ), sa.ForeignKeyConstraint(['created_by_fk'], ['ab_user.id'], ), sa.ForeignKeyConstraint(['pandasdatasource_id'], ['pandasdatasources.id'], ), sa.PrimaryKeyConstraint('id') ) # ### end Alembic commands ### def downgrade(): # ### commands auto generated by Alembic - please adjust! ### op.drop_table('pandasmetrics') op.drop_table('pandascolumns') op.drop_table('pandasdatasources') # ### end Alembic commands ### ``` ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org
With regards, Apache Git Services