This commit is contained in:
Tutur33
2023-11-24 22:35:41 +01:00
parent 3c0b507a93
commit 7644b2a0f7
45165 changed files with 4803356 additions and 3 deletions
+52
View File
@@ -0,0 +1,52 @@
const assert = require('assert');
// Analytic
// -------
// The "Analytic" is an object holding any necessary info about a analytic function
// e.g row_number, rank, dense_rank,
class Analytic {
constructor(method, schema, alias, orderBy, partitions) {
this.schema = schema;
this.type = 'analytic';
this.method = method;
this.order = orderBy || [];
this.partitions = partitions || [];
this.alias = alias;
this.and = this;
this.grouping = 'columns';
}
partitionBy(column, direction) {
assert(
Array.isArray(column) || typeof column === 'string',
`The argument to an analytic partitionBy function must be either a string
or an array of string.`
);
if (Array.isArray(column)) {
this.partitions = this.partitions.concat(column);
} else {
this.partitions.push({ column: column, order: direction });
}
return this;
}
orderBy(column, direction) {
assert(
Array.isArray(column) || typeof column === 'string',
`The argument to an analytic orderBy function must be either a string
or an array of string.`
);
if (Array.isArray(column)) {
this.order = this.order.concat(column);
} else {
this.order.push({ column: column, order: direction });
}
return this;
}
}
module.exports = Analytic;