@qrvey/formula-lang
Version:
QFormula support for qrvey projects
40 lines • 910 B
JavaScript
import { dayScript } from '../utils/elasticsearch/scripts';
import { isDateParam } from '../utils';
import { AST_PRIMITIVES } from '../constants';
/**
* Returns the number of the DAY in a Date.
*/
export const DAY = {
identifier: 'DAY',
parameters: [
{
identifier: 'DATE',
optional: false,
expectedPrimitive: AST_PRIMITIVES.DATE,
validator: [isDateParam],
},
],
transpiler: {
elasticsearch,
snowflake,
redshift,
postgresql,
},
primitiveResult: AST_PRIMITIVES.NUMBER,
};
function elasticsearch(value) {
return dayScript(value);
}
function SQL(value) {
return `DATE_PART('day', ${value})`;
}
function snowflake(value) {
return SQL(value);
}
function redshift(value) {
return SQL(value);
}
function postgresql(value) {
return SQL(value);
}
//# sourceMappingURL=day.js.map