mirror of https://github.com/apache/superset.git
Adding support for Druid post aggregations
This commit is contained in:
parent
e39d6dbc3d
commit
86e354fa70
|
@ -0,0 +1,32 @@
|
|||
"""post_aggs
|
||||
|
||||
Revision ID: b4a0abe21630
|
||||
Revises: 430039611635
|
||||
Create Date: 2016-02-10 15:16:58.953042
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = 'b4a0abe21630'
|
||||
down_revision = '430039611635'
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.dialects import mysql
|
||||
|
||||
|
||||
def upgrade():
|
||||
op.create_table('post_aggregators',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('name', sa.String(length=512), nullable=True),
|
||||
sa.Column('verbose_name', sa.String(length=1024), nullable=True),
|
||||
sa.Column('datasource_name', sa.String(length=250), nullable=True),
|
||||
sa.Column('json', sa.Text(), nullable=True),
|
||||
sa.Column('description', sa.Text(), nullable=True),
|
||||
sa.ForeignKeyConstraint(['datasource_name'], ['datasources.datasource_name'], ),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
|
||||
|
||||
def downgrade():
|
||||
op.drop_table('post_aggregators')
|
|
@ -1170,3 +1170,16 @@ class DruidColumn(Model, AuditMixinNullable):
|
|||
if not m:
|
||||
session.add(metric)
|
||||
session.commit()
|
||||
|
||||
|
||||
class DruidPostAggregator(Model):
|
||||
__tablename__ = 'post_aggregators'
|
||||
id = Column(Integer, primary_key=True)
|
||||
name = Column(String(512))
|
||||
verbose_name = Column(String(1024))
|
||||
datasource_name = Column(
|
||||
String(250),
|
||||
ForeignKey('datasources.datasource_name'))
|
||||
datasource = relationship('DruidDatasource', backref='post_aggregators')
|
||||
json = Column(Text)
|
||||
description = Column(Text)
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
px.registerViz('helloworld', function(slice) {
|
||||
|
||||
function refresh() {
|
||||
$('#code').attr('rows', '15')
|
||||
$.getJSON(slice.jsonEndpoint(), function(payload) {
|
||||
slice.container.html(
|
||||
'<h1>HELLOW '+ payload.form_data.username +' !!!</h1>');
|
||||
console.log(payload);
|
||||
slice.done();
|
||||
})
|
||||
.fail(function(xhr) {
|
||||
slice.error(xhr.responseText);
|
||||
});
|
||||
};
|
||||
return {
|
||||
render: refresh,
|
||||
resize: refresh,
|
||||
};
|
||||
});
|
|
@ -114,6 +114,19 @@ class DruidMetricInlineView(CompactCRUDMixin, PanoramixModelView):
|
|||
appbuilder.add_view_no_menu(DruidMetricInlineView)
|
||||
|
||||
|
||||
class DruidPostAggregatorInlineView(CompactCRUDMixin, PanoramixModelView):
|
||||
datamodel = SQLAInterface(models.DruidPostAggregator)
|
||||
list_columns = ['name', 'verbose_name']
|
||||
edit_columns = [
|
||||
'name', 'description', 'verbose_name', 'datasource', 'json']
|
||||
add_columns = edit_columns
|
||||
page_size = 500
|
||||
validators_columns = {
|
||||
'json': [validate_json],
|
||||
}
|
||||
appbuilder.add_view_no_menu(DruidPostAggregatorInlineView)
|
||||
|
||||
|
||||
class DatabaseView(PanoramixModelView, DeleteMixin):
|
||||
datamodel = SQLAInterface(models.Database)
|
||||
list_columns = ['database_name', 'sql_link', 'created_by', 'changed_on_']
|
||||
|
@ -284,10 +297,13 @@ class DruidDatasourceModelView(PanoramixModelView, DeleteMixin):
|
|||
'created_by', 'created_on',
|
||||
'changed_by_', 'changed_on',
|
||||
'offset']
|
||||
related_views = [DruidColumnInlineView, DruidMetricInlineView]
|
||||
related_views = [
|
||||
DruidColumnInlineView, DruidMetricInlineView,
|
||||
DruidPostAggregatorInlineView]
|
||||
edit_columns = [
|
||||
'datasource_name', 'cluster', 'description', 'owner',
|
||||
'is_featured', 'is_hidden', 'default_endpoint', 'offset']
|
||||
add_columns = edit_columns
|
||||
page_size = 500
|
||||
base_order = ('datasource_name', 'asc')
|
||||
description_columns = {
|
||||
|
|
Loading…
Reference in New Issue