How to push down a function that is not recognized by the TIBCO Data Virtualization parser?
book
Article ID: KB0072297
calendar_today
Updated On:
Products
Versions
TIBCO Data Virtualization
All supported versions
Description
There are a few functions that are not identified by the TIBCO Data Virtualization parser and because of that reason, you may come across situations where a function that works well for a database does not work in TDV.
For example, WEEKDAY is a recognized function in a MySQL database but if it is run in the TDV Studio as below: --------------- SELECT WEEKDAY(DOJ)Weekday from /shared/Test/WD/mysql/test_weekday --------------- The user may see the below error for the above query in TDV: ---------------- 'WEEKDAY' is not a recognized function. On line 1, column 8. [parser-2909505] [Log ID: 43dd8cf3-e660-417a-a9b5-5b37587e07aa] ----------------
If the logs are to be checked, the below error message can be seen coming from the TDV parser: ============ ERROR [jetty thread pool-400] 2022-02-21 15:08:19.235 +0530 Util - User Exception Occurred com.compositesw.common.UserException: 'WEEKDAY' is not a recognized function. On line 1, column 8. [parser-2909505] [Log ID: 43dd8cf3-e660-417a-a9b5-5b37587e07aa] at com.compositesw.common.UserException$Builder.build(UserException.java:161)
Caused by: 'WEEKDAY' is not a recognized function. On line 1, column 8. [parser-2909505] at com.compositesw.cdms.services.parser.ResolveFunctionSelectableVisitor.visitFunction(ResolveFunctionSelectableVisitor.java:644) at com.compositesw.cdms.services.parser.ResolveFunctionSelectableVisitor.traverseFunction(ResolveFunctionSelectableVisitor.java:155) at com.compositesw.cdms.services.parser.Function.accept(Function.java:437) at com.compositesw.server.qe.QueryEngine.a(SourceFile:1634) at com.compositesw.server.qe.QueryEngine.a(SourceFile:272) ============
Environment
All supported environment.
Resolution
The DV user needs to follow the below steps so that the TIBCO Data Virtualization's parser can recognize the function and the function can be pushed down to the Query engine:
(1) Add the following lines to <TDV_SERVER_DIR>\apps\dlm\cis_ds_mysql\conf\mysql_5_5.mysql.capabilities ============================== WEEKDAY(~string): WEEKDAY($1) WEEKDAY(~date): WEEKDAY($1) WEEKDAY(~any): WEEKDAY($1) ==============================
Appending the property in the capabilities file would only work if the parser can recognize the function and the function is not being pushed down to the Query Engine. However, in this case, the TDV parser does not recognize the function WEEKDAY therefore simply appending the properties in the capabilities file would not help since the TIBCO Data Virtualization Query Engine won't recognize the function in the first place.
(2) Restart the TDV server.
(3) Create a Procedure in TDV by right-clicking on any folder under shared and opting for 'Script' ============================== PROCEDURE WEEKDAY(IN somedate VARCHAR, OUT result INTEGER) BEGIN set result = 1; END ==============================
This step will help the TDV Parser to recognize the function. Creating a procedure named WEEKDAY and promoting it as a Custom function helps TDV recognize the function WEEKDAY. Now, if we append the properties to the capabilities file then TDV would push down the function as well.
(4) Go to Studio >> Adminisration >> Custom Functions and select '/shared/../WEEKDAY'
(5) Run the following: -------------------------------- SELECT WEEKDAY('2017-06-15') from /shared/CUSt/mysql_test_anubhav/mysql_ds/customers; -------------------------------- -------------------------------- SELECT WEEKDAY(DOJ) Weekday from /shared/Test/WD/mysql/test_weekday; --------------------------------
Issue/Introduction
This article explains the steps that need to be performed if a function is not recognized by the TIBCO Data Virtualization parser?