UNPKG

@qrvey/formula-lang

Version:

QFormula support for qrvey projects

51 lines 1.43 kB
import { AST_PRIMITIVES, OPERATION_SCOPE } from '../constants'; import { isStringParam } from '../utils'; /** * `INCLUDE` Returns true if a string contains a specified sequence of characters. */ export const INCLUDE = { identifier: 'INCLUDE', operationScope: OPERATION_SCOPE.RAW, functionScope: [OPERATION_SCOPE.RAW], parameters: [ { identifier: 'STRING', optional: false, expectedPrimitive: AST_PRIMITIVES.STRING, validator: [isStringParam], }, { identifier: 'TARGET_SEARCH', optional: false, expectedPrimitive: AST_PRIMITIVES.STRING, validator: [isStringParam], }, ], transpiler: { elasticsearch, snowflake, redshift, postgresql, databricks, }, primitiveResult: AST_PRIMITIVES.BOOLEAN, }; function elasticsearch(str, targetSearch) { return `INCLUDE(${str}, ${targetSearch})`; } function SQL(str, targetSearch) { return `(${str} LIKE ('%' || ${targetSearch} || '%'))`; } function snowflake(str, targetSearch) { return SQL(str, targetSearch); } function redshift(str, targetSearch) { return SQL(str, targetSearch); } function postgresql(str, targetSearch) { return SQL(str, targetSearch); } function databricks(str, targetSearch) { return SQL(str, targetSearch); } //# sourceMappingURL=include.js.map