diff --git a/lib/cartodb/backends/layer-stats/mapnik-layer-stats.js b/lib/cartodb/backends/layer-stats/mapnik-layer-stats.js index d1e292de..a04d68bc 100644 --- a/lib/cartodb/backends/layer-stats/mapnik-layer-stats.js +++ b/lib/cartodb/backends/layer-stats/mapnik-layer-stats.js @@ -201,12 +201,17 @@ function _columnStats(ctx, columns) { ); if (columns[name].type === 'string') { const topN = ctx.metaOptions.columnStats.topCategories || 1024; + let includeNulls = true; + if (ctx.metaOptions.columnStats.hasOwnProperty('includeNulls')) { + includeNulls = ctx.metaOptions.columnStats.includeNulls; + } + // TODO: ctx.metaOptions.columnStats.maxCategories // => use PG stats to dismiss columns with more distinct values queries.push( queryPromise( ctx.dbConnection, - _getSQL(ctx, sql => queryUtils.getQueryTopCategories(sql, name, topN)), + _getSQL(ctx, sql => queryUtils.getQueryTopCategories(sql, name, topN, includeNulls)), res => ({ [name]: { categories: res.rows } }) ) );