You can translate the question and the replies:

Microstrategy report running against Denodo

When we run a Microstrategy report that is pointing to Denodo, we are not getting the correct results and SQL. The report needs the top 3 records. When the report is run against DB2, the SQL contains a Rank function. When the same report is run against Denodo, we are seeing SQL statements as shown below. We are not able to explain where the number 6865898.22999999 came from. Is Denodo doing the Ranking on the Denodo server and substituing the number 6865898.22999999 in the SQL statement ? Even if it is, the number 6865898.22999999 is incorrect because we are not getting the correct top 3 records. Denodo SQLin Microstrategy report insert into TTQHUS61WMR000 select ctry_cd , sum(a11.amt_xb) WJXBFS1 from dpd.iv_issr_qtr a11 where ( a11.bus_id in (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 10000000, 10000001, 10000002) and a11.prod_srce_cd_vcis in ('C', 'D', ' ', '-', 'H', 'M', 'N', 'P', 'R') ) group by a11.ctry_cd select pa11.WJXBFS1 WJXBFS1 from TTQHUS61WMR000 pa11 order by 1 desc insert into TMQ5EDHT8MQ001 select pa11.ctry_cd ctry_cd from TTQHUS61WMR000 pa11 where (pa11.WJXBFS1 >= 6865898.22999999)
user
03-01-2018 12:49:32 -0500
code

3 Answers

Hi, If you are using a *RANK* function in the SQL when running your report against DB2 directly, then I would suggest doing the same in the VQL when running the report against Denodo. In the report VQL, I'd make sure the *RANK* call with *ORDER BY* is inside a subquery, and that the filter for the top three in the main query uses that value, such as *WHERE rank <=3*. You can work with your VQL statement in the [VQL Shell](https://community.denodo.com/docs/html/browse/6.0/vdp/administration/installation_and_execution/launching_the_virtual_dataport_administration_tool/using_the_vql_shell) of the Administration Tool to verify that you are getting the intended results before moving that query over to MicroStrategy to implement in your report. To see what is happening when the report is executed, I'd use the [Diagnostic & Monitoring Tool](https://community.denodo.com/docs/html/browse/6.0/vdp/dmt/monitoring/monitoring_servers/monitoring_requests) to find the exact VQL query as it is being received from MicroStrategy and use the [Execution Trace](https://community.denodo.com/docs/html/browse/6.0/vdp/administration/creating_views/querying_views/execution_trace_of_a_statement) to dig in to each node of the Denodo optimization and simplification. This will help isolate where the errant 6865898.22999999 value is coming from. To your specific question about Denodo handling the *RANK* function execution; that is not the case, as with all [Analytic Functions](https://community.denodo.com/docs/html/browse/6.0/vdp/vql/appendix/syntax_of_condition_functions/analytic_functions_window_functions) Denodo can not execute this function itself, and a query will fail if *RANK* can not be delegated to the data source. If you're not seeing a *RANK* call in the VQL received from MicroStrategy, then MicroStrategy is handling the ranking. Hope this helps!
Denodo Team
03-01-2018 16:44:10 -0500
code
Thanks for the quick response. It is not possible for us to add the RANK function to the SQL because the SQL gets generated behind the scenes when the Microstrategy report runs. Please note that Microstrategy is dependent on the driver supplied by Denodo to generate the SQL. When the Microstrategy report runs against DB2, it generates the SQL with the RANK function. When the same Microstrategy report runs against Denodo, it generates the SQL differently. Based on my analyis, if we need the top 3 records based on an amount as shows in the SQL in my first post, Denodo is trying to determine the 3rd highest amount by running the query below. select pa11.WJXBFS1 WJXBFS1 from TTQHUS61WMR000 pa11 order by 1 desc It is then substituting that amount in the query below, to get the records with the top 3 amounts insert into TMQ5EDHT8MQ001 select pa11.ctry_cd ctry_cd from TTQHUS61WMR000 pa11 where (pa11.WJXBFS1 >= 6865898.22999999) So Denodo is not generating the SQL with a RANK function that can be delegated to the Database and is using another approach to do the ranking. This is causing many of our Microstrategy reports to time out. This is a big issue for us. Hence I request you to apply a patch to the Denodo driver so that a SQL with a RANK function gets generated when we run the report.
user
05-01-2018 07:08:17 -0500
Hi again, It looks like MicroStrategy has the ability to create [Freeform SQL Reports](https://www2.microstrategy.com/producthelp/10.7/ReportDesigner/WebHelp/Lang_1033/Content/ReportDesigner/overview_of_freeform_sql_reports.htm) from their Developer tool if you have a situation like this where the automatically generated SQL doesn't meet your needs. If you don't have access to the Developer tool, you could look in to creating a derived view in Denodo that leverages the RANK function to ensure it gets delegated to the underlying data source as you are expecting. This is likely the better solution from a performance perspective either way. Regarding the driver, MicroStrategy has two different ways to connect to Denodo, and the method you are using may be very relevant to this scenario. MicroStrategy provides a [Denodo Connector](https://www.microstrategy.com/us/services/technical-support/drivers-and-connectors), but this uses a PostgreSQL ODBC driver instead of Denodo's provided drivers. Newer versions of MicroStrategy also support creating your own [JDBC connection](https://community.microstrategy.com/s/article/KB250923-Connecting-to-Databases-using-JDBC-Drivers-in), which should allow you to use Denodo's latest [JDBC driver](https://community.denodo.com/tutorials/browse/basics/4connect1jdbcclient). Keep in mind that the Denodo drivers only handle the connectivity to the VDP server, and don't generate or make any changes to the SQL statements being submitted. Query optimization is handled by the server *after* the request is received. This is why I was suggesting you look at the Diagnostic & Monitoring tool to validate exactly what is being generated by MicroStrategy. This would be an important first step before changing any data source definitions. In order to consider a change to the behavior of the RANK function, we would need to better understand the specifics of your situation. I would like to help ensure you find the right solution to this problem, and believe it would be beneficial for you to open a support case where you can work directly with an agent that can help review your logs and isolate the variables at work.
Denodo Team
16-01-2018 16:11:36 -0500
code
You must sign in to add an answer. If you do not have an account, you can register here