我有一个相对简单的MDX查询,它在结果集中创建超过10,000行(大多数是空的),但它生成的SQL在结果集中创建的行数相对较少。这是MDX查询:
SELECT
NON EMPTY CrossJoin({([employmentDate.yearQuarterMonth].[2012]:[employmentDate.yearQuarterMonth].[2014])}, {[Measures].[headCount]}) ON COLUMNS,
NON EMPTY {[residenceLocation].[iso_region].Members} ON ROWS
FROM workforce
这是一个它返回的作用:
| | 2012 | 2013 | 2014 |
| | %{measure.headCount} | %{measure.headCount} | %{measure.headCount} |
+--------------------------+----------------------+----------------------+----------------------+----------------------+
| Germany | #null | 138 | 241 | 238 |
| France | #null | 49 | 40 | 66 |
| United Kingdom | #null | 46 | 20 | 33 |
| Japan | #null | 67 | 135 | 140 |
| Russian Federation | #null | 84 | 105 | 78 |
| United States of America | California | 38 | 43 | 36 |
| | | 38 | 43 | 36 |
| | | 38 | 43 | 36 |
| | | 38 | 43 | 36 |
| | | 38 | 43 | 36 |
| | | 38 | 43 | 36 |
| | | 38 | 43 | 36 |
您可以看到它会生成像加利福尼亚这样的状态,但会使用空的区域名称反复重复该统计信息。
生成的SQL是,它只返回39行:
select
"TIME"."YEAR" as "Year",
"REGIONS_1"."ISO_COUNTRY_CODE" as "Country",
"REGIONS_1"."ISO_REGION" as "Region",
sum("EMPLOYMENT"."HEADCOUNT") as "Headcount"
from
"TIME" "TIME",
"EMPLOYMENT" "EMPLOYMENT",
"REGIONS" "REGIONS_1"
where
"EMPLOYMENT"."EMPLOYMENT_DATE_ID" = "TIME"."ID"
and
"TIME"."YEAR" in (2012, 2013, 2014)
and
"EMPLOYMENT"."RESIDENCE_REGION_ID" = "REGIONS_1"."ID"
group by
"TIME"."YEAR",
"REGIONS_1"."ISO_COUNTRY_CODE",
"REGIONS_1"."ISO_REGION";
然后这个SQL用于加载的属性,它返回超过20,000 +:
select
"REGIONS_1"."ISO_COUNTRY_CODE" as "Country Code",
"REGIONS_1"."COUNTRY_NAME" as "Country",
"REGIONS_1"."ISO_COUNTRY_CODE" as "Country Code",
"REGIONS_1"."LATITUDE" as "Latitude",
"REGIONS_1"."LONGITUDE" as "Longitude",
"REGIONS_1"."ISO_REGION" as "Region",
"REGIONS_1"."REGION_NAME" as "Region Name",
"REGIONS_1"."STATE_FIPS" as "State FIPS",
"REGIONS_1"."LATITUDE" as "Latitude",
"REGIONS_1"."LONGITUDE" as "Longitude"
from
"REGIONS" "REGIONS_1"
group by
"REGIONS_1"."ISO_COUNTRY_CODE",
"REGIONS_1"."COUNTRY_NAME",
"REGIONS_1"."LATITUDE",
"REGIONS_1"."LONGITUDE",
"REGIONS_1"."ISO_REGION",
"REGIONS_1"."REGION_NAME",
"REGIONS_1"."STATE_FIPS"
order by
"REGIONS_1"."ISO_COUNTRY_CODE" ASC NULLS LAST,
"REGIONS_1"."ISO_REGION" ASC NULLS LAST;
所以我不确定为什么Mondrian在创建CellSet时会发疯。 Region表由这些列组成(但不是全部):
Country,
Region (ISO Code),
State_FIPS,
Postal_Code,
Latitude,
Longitude,
County,
MSA,
CBSA, etc.
这是一个相当低级别的区域数据。 Dimension的层次结构如下所示:
iso_country
iso_region
county
我应该补充说,当使用[residenceLocation]时,它也会发生,但不是这种程度。[country]其中USA被吹出了几个空行。它可能包含10-20个额外行,但不包括10,000行。所以我认为在这两种情况下都是同样的问题。
更新我想出了额外行的来源。当我将纬度和经度作为属性添加到Country,Region和County时,行开始爆炸。把它们带走,没关系。那么是否有一种方法可以添加这些属性,这些属性可能在行之间有所不同而不会影响返回的CellSet?