UNPKG

@qrvey/formula-lang

Version:

QFormula support for qrvey projects

53 lines 1.43 kB
import { AST_PRIMITIVES } from '../constants'; import { isStringParam } from '../utils'; /** * `CONCATENATE` Joins two or more strings into one string. */ export const CONCATENATE = { identifier: 'CONCATENATE', recursiveStartIn: 1, parameters: [ { identifier: 'STRING_1', optional: false, expectedPrimitive: AST_PRIMITIVES.STRING, validator: [isStringParam], }, { identifier: 'STRING_2', optional: false, expectedPrimitive: AST_PRIMITIVES.STRING, validator: [isStringParam], }, { identifier: 'STRING_N', optional: true, expectedPrimitive: AST_PRIMITIVES.STRING, validator: [isStringParam], }, ], transpiler: { elasticsearch, snowflake, redshift, postgresql, }, primitiveResult: AST_PRIMITIVES.STRING, }; function elasticsearch(...args) { return `(${args.join(' + ')})`; } function sql(...args) { return `CONCAT(${args.join(', ')})`; } function snowflake(...args) { return sql(...args); } // Redshift also support CONCAT function but when the string to concatenate is a space only thrown an error function redshift(...args) { return `(${args.join(' || ')})`; } function postgresql(...args) { return sql(...args); } //# sourceMappingURL=concatenate.js.map