|
|
@ -52,10 +52,18 @@ Numeric histogram:
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
module.exports = class NumericHistogram extends BaseHistogram {
|
|
|
|
module.exports = class NumericHistogram extends BaseHistogram {
|
|
|
|
_buildQuery (psql, override, callback) {
|
|
|
|
_buildQuery (psql, override, callback) {
|
|
|
|
|
|
|
|
let column = this.column;
|
|
|
|
|
|
|
|
let query = this.query;
|
|
|
|
|
|
|
|
// for date type we have to cast the column using an alias
|
|
|
|
|
|
|
|
// and using that alias to prevent multiple calls to the cast
|
|
|
|
|
|
|
|
if (this._columnType === 'date') {
|
|
|
|
|
|
|
|
query = `(SELECT *, ${utils.columnCastTpl({ column })} as __cdb_cast_date FROM (${this.query}) __cdb_original_query)`;
|
|
|
|
|
|
|
|
column = '__cdb_cast_date';
|
|
|
|
|
|
|
|
}
|
|
|
|
const histogramSql = this._buildQueryTpl({
|
|
|
|
const histogramSql = this._buildQueryTpl({
|
|
|
|
column: this._columnType === 'date' ? utils.columnCastTpl({ column: this.column }) : this.column,
|
|
|
|
column,
|
|
|
|
isFloatColumn: this._columnType === 'float',
|
|
|
|
isFloatColumn: this._columnType === 'float',
|
|
|
|
query: this.query,
|
|
|
|
query,
|
|
|
|
start: this._getBinStart(override),
|
|
|
|
start: this._getBinStart(override),
|
|
|
|
end: this._getBinEnd(override),
|
|
|
|
end: this._getBinEnd(override),
|
|
|
|
bins: this._getBinsCount(override),
|
|
|
|
bins: this._getBinsCount(override),
|
|
|
|