mirror of https://github.com/apache/superset.git
Adding support for quoted field names
This commit is contained in:
parent
6a28ad3f4e
commit
4e21fb4285
2
TODO.md
2
TODO.md
|
@ -1,8 +1,6 @@
|
||||||
# TODO
|
# TODO
|
||||||
List of TODO items for Panoramix
|
List of TODO items for Panoramix
|
||||||
|
|
||||||
* fix directed
|
|
||||||
|
|
||||||
## Improvments
|
## Improvments
|
||||||
* dashboard controller + filters
|
* dashboard controller + filters
|
||||||
* Color hash in JS
|
* Color hash in JS
|
||||||
|
|
|
@ -12,7 +12,7 @@ from sqlalchemy import (
|
||||||
Column, Integer, String, ForeignKey, Text, Boolean, DateTime,
|
Column, Integer, String, ForeignKey, Text, Boolean, DateTime,
|
||||||
Table, create_engine, MetaData, desc, select, and_, func)
|
Table, create_engine, MetaData, desc, select, and_, func)
|
||||||
from sqlalchemy.orm import relationship
|
from sqlalchemy.orm import relationship
|
||||||
from sqlalchemy.sql import table, literal_column, text
|
from sqlalchemy.sql import table, literal_column, text, column
|
||||||
from sqlalchemy.sql.elements import ColumnClause
|
from sqlalchemy.sql.elements import ColumnClause
|
||||||
from sqlalchemy_utils import EncryptedType
|
from sqlalchemy_utils import EncryptedType
|
||||||
|
|
||||||
|
@ -420,9 +420,7 @@ class SqlaTable(Model, Queryable, AuditMixinNullable):
|
||||||
groupby_exprs = []
|
groupby_exprs = []
|
||||||
|
|
||||||
if groupby:
|
if groupby:
|
||||||
select_exprs = [literal_column(s) for s in groupby]
|
|
||||||
select_exprs = []
|
select_exprs = []
|
||||||
groupby_exprs = []
|
|
||||||
inner_select_exprs = []
|
inner_select_exprs = []
|
||||||
inner_groupby_exprs = []
|
inner_groupby_exprs = []
|
||||||
for s in groupby:
|
for s in groupby:
|
||||||
|
@ -432,8 +430,8 @@ class SqlaTable(Model, Queryable, AuditMixinNullable):
|
||||||
outer = ColumnClause(expr, is_literal=True).label(s)
|
outer = ColumnClause(expr, is_literal=True).label(s)
|
||||||
inner = ColumnClause(expr, is_literal=True).label('__' + s)
|
inner = ColumnClause(expr, is_literal=True).label('__' + s)
|
||||||
else:
|
else:
|
||||||
outer = literal_column(s).label(s)
|
outer = column(s).label(s)
|
||||||
inner = literal_column(s).label('__' + s)
|
inner = column(s).label('__' + s)
|
||||||
|
|
||||||
groupby_exprs.append(outer)
|
groupby_exprs.append(outer)
|
||||||
select_exprs.append(outer)
|
select_exprs.append(outer)
|
||||||
|
@ -473,7 +471,7 @@ class SqlaTable(Model, Queryable, AuditMixinNullable):
|
||||||
cond = ColumnClause(
|
cond = ColumnClause(
|
||||||
col_obj.expression, is_literal=True).in_(values)
|
col_obj.expression, is_literal=True).in_(values)
|
||||||
else:
|
else:
|
||||||
cond = literal_column(col).in_(values)
|
cond = column(col).in_(values)
|
||||||
if op == 'not in':
|
if op == 'not in':
|
||||||
cond = ~cond
|
cond = ~cond
|
||||||
where_clause_and.append(cond)
|
where_clause_and.append(cond)
|
||||||
|
@ -497,7 +495,7 @@ class SqlaTable(Model, Queryable, AuditMixinNullable):
|
||||||
on_clause = []
|
on_clause = []
|
||||||
for i, gb in enumerate(groupby):
|
for i, gb in enumerate(groupby):
|
||||||
on_clause.append(
|
on_clause.append(
|
||||||
groupby_exprs[i] == literal_column("__" + gb))
|
groupby_exprs[i] == column("__" + gb))
|
||||||
|
|
||||||
from_clause = from_clause.join(subq.alias(), and_(*on_clause))
|
from_clause = from_clause.join(subq.alias(), and_(*on_clause))
|
||||||
|
|
||||||
|
@ -558,33 +556,35 @@ class SqlaTable(Model, Queryable, AuditMixinNullable):
|
||||||
if not any_date_col and 'date' in datatype.lower():
|
if not any_date_col and 'date' in datatype.lower():
|
||||||
any_date_col = col.name
|
any_date_col = col.name
|
||||||
|
|
||||||
|
quoted = unicode(
|
||||||
|
column(dbcol.column_name).compile(dialect=db.engine.dialect))
|
||||||
if dbcol.sum:
|
if dbcol.sum:
|
||||||
metrics.append(M(
|
metrics.append(M(
|
||||||
metric_name='sum__' + dbcol.column_name,
|
metric_name='sum__' + dbcol.column_name,
|
||||||
verbose_name='sum__' + dbcol.column_name,
|
verbose_name='sum__' + dbcol.column_name,
|
||||||
metric_type='sum',
|
metric_type='sum',
|
||||||
expression="SUM({})".format(dbcol.column_name)
|
expression="SUM({})".format(quoted)
|
||||||
))
|
))
|
||||||
if dbcol.max:
|
if dbcol.max:
|
||||||
metrics.append(M(
|
metrics.append(M(
|
||||||
metric_name='max__' + dbcol.column_name,
|
metric_name='max__' + dbcol.column_name,
|
||||||
verbose_name='max__' + dbcol.column_name,
|
verbose_name='max__' + dbcol.column_name,
|
||||||
metric_type='max',
|
metric_type='max',
|
||||||
expression="MAX({})".format(dbcol.column_name)
|
expression="MAX({})".format(quoted)
|
||||||
))
|
))
|
||||||
if dbcol.min:
|
if dbcol.min:
|
||||||
metrics.append(M(
|
metrics.append(M(
|
||||||
metric_name='min__' + dbcol.column_name,
|
metric_name='min__' + dbcol.column_name,
|
||||||
verbose_name='min__' + dbcol.column_name,
|
verbose_name='min__' + dbcol.column_name,
|
||||||
metric_type='min',
|
metric_type='min',
|
||||||
expression="MIN({})".format(dbcol.column_name)
|
expression="MIN({})".format(quoted)
|
||||||
))
|
))
|
||||||
if dbcol.count_distinct:
|
if dbcol.count_distinct:
|
||||||
metrics.append(M(
|
metrics.append(M(
|
||||||
metric_name='count_distinct__' + dbcol.column_name,
|
metric_name='count_distinct__' + dbcol.column_name,
|
||||||
verbose_name='count_distinct__' + dbcol.column_name,
|
verbose_name='count_distinct__' + dbcol.column_name,
|
||||||
metric_type='count_distinct',
|
metric_type='count_distinct',
|
||||||
expression="COUNT(DISTINCT {})".format(dbcol.column_name)
|
expression="COUNT(DISTINCT {})".format(quoted)
|
||||||
))
|
))
|
||||||
dbcol.type = datatype
|
dbcol.type = datatype
|
||||||
db.session.merge(self)
|
db.session.merge(self)
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
var px = (function() {
|
var px = (function() {
|
||||||
|
|
||||||
var visualizations = [];
|
var visualizations = {};
|
||||||
var dashboard = undefined;
|
var dashboard = undefined;
|
||||||
|
|
||||||
var Slice = function(data, dashboard){
|
var Slice = function(data, dashboard){
|
||||||
|
@ -92,7 +92,7 @@ var px = (function() {
|
||||||
delete dashboard.clearFilter(slice_id);
|
delete dashboard.clearFilter(slice_id);
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
var viz = visualizations[name](slice);
|
var viz = visualizations[data.form_data.viz_type](slice);
|
||||||
slice['viz'] = viz;
|
slice['viz'] = viz;
|
||||||
return slice;
|
return slice;
|
||||||
}
|
}
|
||||||
|
@ -119,7 +119,6 @@ var px = (function() {
|
||||||
},
|
},
|
||||||
getSlice: function(slice_id) {
|
getSlice: function(slice_id) {
|
||||||
for(var i=0; i<this.slices.length; i++){
|
for(var i=0; i<this.slices.length; i++){
|
||||||
console.log([this.slices[i].data.slice_id, slice_id]);
|
|
||||||
if (this.slices[i].data.slice_id == slice_id)
|
if (this.slices[i].data.slice_id == slice_id)
|
||||||
return this.slices[i];
|
return this.slices[i];
|
||||||
}
|
}
|
||||||
|
@ -139,6 +138,7 @@ var px = (function() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function registerViz(name, initViz) {
|
function registerViz(name, initViz) {
|
||||||
|
|
||||||
visualizations[name] = initViz;
|
visualizations[name] = initViz;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -285,7 +285,6 @@ var px = (function() {
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
}).data('gridster');
|
}).data('gridster');
|
||||||
console.log(gridster);
|
|
||||||
$("div.gridster").css('visibility', 'visible');
|
$("div.gridster").css('visibility', 'visible');
|
||||||
$("#savedash").click(function() {
|
$("#savedash").click(function() {
|
||||||
var data = {
|
var data = {
|
||||||
|
|
|
@ -36,7 +36,7 @@ function viz_world_map(slice) {
|
||||||
element: slice.container.get(0),
|
element: slice.container.get(0),
|
||||||
data: json.data,
|
data: json.data,
|
||||||
fills: {
|
fills: {
|
||||||
defaultFill: 'grey'
|
defaultFill: 'white'
|
||||||
},
|
},
|
||||||
geographyConfig: {
|
geographyConfig: {
|
||||||
popupOnHover: true,
|
popupOnHover: true,
|
||||||
|
|
Loading…
Reference in New Issue