Extract template to filter out special numeric values

This commit is contained in:
Daniel García Aubert 2017-09-05 10:36:18 +02:00
parent 6373fe8652
commit c580600590

View File

@ -51,22 +51,23 @@ var MAX_INTERVAL_VALUE = 366;
var BIN_MIN_NUMBER = 6; var BIN_MIN_NUMBER = 6;
var BIN_MAX_NUMBER = 48; var BIN_MAX_NUMBER = 48;
const filterOutSpecialNumericValues = ctx => `
${ctx._column} != 'infinity'::float
AND
${ctx._column} != '-infinity'::float
AND
${ctx._column} != 'NaN'::float
`;
const filteredQueryTpl = ctx => ` const filteredQueryTpl = ctx => `
__cdb_filtered_source AS ( __cdb_filtered_source AS (
SELECT * SELECT *
FROM (${ctx._query}) __cdb_filtered_source_query FROM (${ctx._query}) __cdb_filtered_source_query
WHERE WHERE ${ctx._column} IS NOT NULL
${ctx._column} IS NOT NULL ${ctx._isFloatColumn ? `AND ${filterOutSpecialNumericValues(ctx)}` : ''}
${ctx._isFloatColumn ? `
AND
${ctx._column} != 'infinity'::float
AND
${ctx._column} != '-infinity'::float
AND
${ctx._column} != 'NaN'::float
` : ''}
) )
` `;
var basicsQueryTpl = dot.template([ var basicsQueryTpl = dot.template([
'__cdb_basics AS (', '__cdb_basics AS (',
' SELECT', ' SELECT',