Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding support for Druid post aggregations #133

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions panoramix/migrations/versions/b4a0abe21630_post_aggs.py
Original file line number Diff line number Diff line change
@@ -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')
13 changes: 13 additions & 0 deletions panoramix/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1170,3 +1170,16 @@ def generate_metrics(self):
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)
19 changes: 19 additions & 0 deletions panoramix/static/widgets/viz_helloworld.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
px.registerViz('helloworld', function(slice) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this? unrelated code?


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,
};
});
18 changes: 17 additions & 1 deletion panoramix/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,19 @@ class DruidMetricInlineView(CompactCRUDMixin, PanoramixModelView):
appbuilder.add_view_no_menu(DruidMetricInlineView)


class DruidPostAggregatorInlineView(CompactCRUDMixin, PanoramixModelView):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a new table? why not a column from the existing table?

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_']
Expand Down Expand Up @@ -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 = {
Expand Down