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