UNPKG

@qrvey/formula-lang

Version:

QFormula support for qrvey projects

46 lines 1.1 kB
import { monthScript } from '../utils/elasticsearch/scripts'; import { isDateParam } from '../utils'; import { AST_PRIMITIVES, OPERATION_SCOPE } from '../constants'; /** * Returns the number of the MONTH in a Date. */ export const MONTH = { identifier: 'MONTH', operationScope: OPERATION_SCOPE.RAW, functionScope: [OPERATION_SCOPE.RAW], parameters: [ { identifier: 'DATE', optional: false, expectedPrimitive: AST_PRIMITIVES.DATE, validator: [isDateParam], }, ], transpiler: { elasticsearch, snowflake, redshift, postgresql, databricks, }, primitiveResult: AST_PRIMITIVES.NUMBER, }; function elasticsearch(value) { return monthScript(value); } function SQL(value) { return `DATE_PART('month', ${value})`; } function snowflake(value) { return SQL(value); } function redshift(value) { return SQL(value); } function postgresql(value) { return SQL(value); } function databricks(value) { return SQL(value); } //# sourceMappingURL=month.js.map