UNPKG

@qrvey/formula-lang

Version:

QFormula support for qrvey projects

62 lines 1.78 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.CONCATENATE = void 0; const constants_1 = require("../constants"); const utils_1 = require("../utils"); /** * `CONCATENATE` Joins two or more strings into one string. */ exports.CONCATENATE = { identifier: 'CONCATENATE', operationScope: constants_1.OPERATION_SCOPE.RAW, functionScope: [constants_1.OPERATION_SCOPE.RAW], recursiveStartIn: 1, parameters: [ { identifier: 'STRING_1', optional: false, expectedPrimitive: constants_1.AST_PRIMITIVES.STRING, validator: [utils_1.isStringParam], }, { identifier: 'STRING_2', optional: false, expectedPrimitive: constants_1.AST_PRIMITIVES.STRING, validator: [utils_1.isStringParam], }, { identifier: 'STRING_N', optional: true, expectedPrimitive: constants_1.AST_PRIMITIVES.STRING, validator: [utils_1.isStringParam], }, ], transpiler: { elasticsearch, snowflake, redshift, postgresql, databricks, }, primitiveResult: constants_1.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); } function databricks(...args) { return sql(...args); } //# sourceMappingURL=concatenate.js.map