Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function get_aggregates_with_defaults(aggregate_attribute, schema, cols) {
const found = new Set();
const aggregates = [];
for (const col of aggregate_attribute) {
const type = schema[col.column];
const type_config = get_type_config(type);
found.add(col.column);
if (type_config.type || type) {
if (col.op === "" || perspective.TYPE_AGGREGATES[type_config.type || type].indexOf(col.op) === -1) {
col.op = type_config.aggregate;
}
aggregates.push(col);
} else {
console.warn(`No column "${col.column}" found (specified in aggregates attribute).`);
}
}
// Add columns detected from dataset.
for (const col of cols) {
if (!found.has(col)) {
aggregates.push({
column: col,
op: get_type_config(schema[col]).aggregate
});
}