Home Database Mysql Tutorial AMO olap Test C# generate tsql and mdx

AMO olap Test C# generate tsql and mdx

Jun 07, 2016 pm 05:37 PM
test

通过AMO访问online的cube,生成等值的TSql和mdx 自动生成等值的TSQL和MDX进行Cube测试.其中难度比较大的部分是拼接TSQL. 暂时不处理calculations,只除理metrics和Regular Type的dimension Usage. metric的聚合方法只处理(max,min,sum,count,distinct count)

通过AMO访问online的cube,生成等值的TSql和mdx

自动生成等值的TSQL和MDX进行Cube测试.其中难度比较大的部分是拼接TSQL.

暂时不处理calculations,只除理metrics和Regular Type的dimension Usage.

metric的聚合方法只处理(max,min,sum,count,distinct count)

以下是问题的记录与处理情况.

1.adventureworks示例cube中,会把Date dimension的attributes的表名取成dimtime. 未解决 已经解决此问题

2.如果dimension 表中的attributes引用了其他表的字段,则暂时没有解决这个问题. 解决

使用TableJoin和TableLinks方法来解决这个问题.

Tablelinks方法获取dimensionattributes中使用到的字段所在的表与主表的关系链.

Tablejoin:生成连接的语句.

或许不完善.

3.新问题 如果hierarchy的level的source attribute用的是calculation,那么现在仍然会报错,我应该判断

这个字段是不是计算成员,如果是计算成员,则要去取计算成员的定义.

4.没有考虑dimension attribute的orderby 属性与name column. 未解决(尽快解决 已经解决此问题)

5.问题 自连接的情况 如果dimension usage 当中事实表和维度表是一个表的话,需要给表加别名.

现在只考虑事实表与维度表相同的情况,其他的暂时不考虑.

6.在某些情况下,sum出来的结果会发生溢出,所以需要提前把它转化为bigint.

可以在判断其列的类型为int时自动将其转化成bigint. 未解决

7.遇到父子dimension会形成死循环,或者类似存在回链关系的DSV维度,忽略掉. 解决:第二次出现的时候直接断开.

以下是生成等值TSQL与MDX的运行情况,使用Adventurework示例数据仓库SSAS进行测试,除了提到的第一个问题外,

生成的TSQL均可以运行.

   

界面介绍:填入OLAP CUBE的连接字符串,选择DB,CUBE与dimensions.直接点击生成mdxtsql.

以下贴一些主要的方法(代码)

由于dimension可能引用多个表,所以要把这几个表关联起来,有了以下代码:   

private string TableJoin(DimensionAttribute da) { //根据l找到sourcetable morejoin = ""; string tablelinks = GetTableLinks(da.Parent); ).Length3) return ""; )[; if (tablelinks.IndexOf(TableName).Equals(0)) return ""; string strUsedTables = tablelinks.Substring(0, tablelinks.IndexOf(TableName)-1); Liststring>(); usedTables.Remove(""); DataSet ds = da.Parent.DataSourceView.Schema; for (int i = 0; i 0; i++) { string childTable = usedTables[0]; DataRelation dr = ds.Relations[i]; if (dr.ChildTable.TableName.Equals(childTable)) { morejoin = morejoin.Append(+ GetSourceQueryDefinition(da.Parent,dr.ParentTable.TableName.ReplaceFirstUnderLineWithDot()) ).AppendNewLine().Append(); for (int j = 0; j ) { morejoin = morejoin.Append( dr.ParentTable.TableName.ReplaceFirstUnderLineWithDot()++ dr.ParentColumns[j].ColumnName + + dr.ChildTable.TableName.ReplaceFirstUnderLineWithDot() ++ dr.ChildColumns[j].ColumnName ).AppendNewLine(); } usedTables.RemoveAt(0); i = 0; } } return morejoin; } private string GetTableLinks(Dimension dim) { HashSetstring> tables = new HashSetstring>(); string MainTable = ""; string tablelinks = string.Empty; DataSet ds = dim.DataSourceView.Schema; MainTable= dim.KeyAttribute.KeyColumns[)[0]; tablelinks = tablelinks.Append(MainTable+); for (int i = 0; i ) { DataRelation dr = ds.Relations[i]; if (dr.ChildTable.TableName.Equals(MainTable)) { tablelinks = tablelinks.Append(dr.ParentTable.TableName + ); MainTable = dr.ParentTable.TableName; if (tables.Contains(MainTable)) break; else tables.Add(MainTable); i = 0; } } return tablelinks; }

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Huawei Watch GT 5 smartwatch gets update with new features Huawei Watch GT 5 smartwatch gets update with new features Oct 03, 2024 am 06:25 AM

Huawei is rolling out software version 5.0.0.100(C00M01) for the Watch GT 5 and the Watch GT 5 Prosmartwatchesglobally. These two smartwatches recently launched in Europe, with the standard model arriving as the company’s cheapest model. This Harmony

Tekken\'s Colonel Sanders dream fried by KFC Tekken\'s Colonel Sanders dream fried by KFC Oct 02, 2024 am 06:07 AM

Katsuhiro Harada, the Tekken series director, once seriously tried to bring Colonel Sanders into the iconic fighting game. In an interview with TheGamer, Harada revealed that he pitched the idea to KFC Japan, hoping to add the fast-food legend as a g

Cybertruck FSD reviews praise quick lane switching and full-screen visualizations Cybertruck FSD reviews praise quick lane switching and full-screen visualizations Oct 01, 2024 am 06:16 AM

Tesla is rolling out the latest Full Self-Driving (Supervised) version 12.5.5 and with it comes the promised Cybertruck FSD option at long last, ten months after the pickup went on sale with the feature included in the Foundation Series trim price. F

First look: Leaked unboxing video of upcoming Anker Zolo 4-port 140W wall charger with display First look: Leaked unboxing video of upcoming Anker Zolo 4-port 140W wall charger with display Oct 01, 2024 am 06:32 AM

Earlier in September 2024, Anker's Zolo 140W charger was leaked, and it was a big deal since it was the first-ever wall charger with a display from the company. Now, a new unboxing video from Xiao Li TV on YouTube gives us a first-hand look at the hi

New Xiaomi Mijia Graphene Oil Heater with HyperOS arrives New Xiaomi Mijia Graphene Oil Heater with HyperOS arrives Oct 02, 2024 pm 09:02 PM

Xiaomi will shortly launch the Mijia Graphene Oil Heater in China. The company recently ran a successful crowdfunding campaign for the smart home product, hosted on its Youpin platform. According to the page, the device has already started to ship to

Garmin releases Adventure Racing activity improvements for multiple smartwatches via new update Garmin releases Adventure Racing activity improvements for multiple smartwatches via new update Oct 01, 2024 am 06:40 AM

Garmin is ending the month with a new set of stable updates for its latest high-end smartwatches. To recap, the company released System Software 11.64 to combat high battery drain across the Enduro 3, Fenix E and Fenix 8 (curr. $1,099.99 on Amazon).

Samsung Galaxy Z Fold Special Edition revealed to land in late October as conflicting name emerges Samsung Galaxy Z Fold Special Edition revealed to land in late October as conflicting name emerges Oct 01, 2024 am 06:21 AM

The launch of Samsung's long-awaited 'Special Edition' foldable has taken another twist. In recent weeks, rumours about the so-called Galaxy Z Fold Special Edition went rather quiet. Instead, the focus has shifted to the Galaxy S25 series, including

Manjaro 24.1 \'Xahea\' launches with KDE Plasma 6.1.5, VirtualBox 7.1, and more Manjaro 24.1 \'Xahea\' launches with KDE Plasma 6.1.5, VirtualBox 7.1, and more Oct 02, 2024 am 06:06 AM

With a history of over one decade, Manjaro is regarded as one of the most user-friendly Linux distros suitable for both beginners and power users, being easy to install and use. Mostly developed in Austria, Germany, and France, this Arch-based distro

See all articles