Databases Reference
In-Depth Information
LISTING 29.1
A Simple MDX Query
WITH member measures.growth as
[Measures].[Sales Count]-([Time].[Time].PrevMember,[Measures].[Sales Count])
SELECT [Product].[Products].[Product Family].members on COLUMNS,
[Time].[Time].[Month].&[6]&[1998] on ROWS FROM [Warehouse and Sales]
WHERE measures.growth
CELL PROPERTIES VALUE
In the second parsing phase, Analysis Services traverses an AST, performs semantic analysis
of the expression, resolves the names of the objects referenced in the query, and validates
the signatures of the functions. During this phase, Analysis Services also collects informa-
tion about all MDX calculations that can be used by the query and produces calculation
scopes. (We discuss calculation scopes in the next section of this chapter.) The semantic
analysis phase produces an expression tree. Each node on the expression tree is an object
that represents an MDX function or object in the UDM. For the sample query in Listing
29.1, Analysis Services generates the expression tree shown in Figure 29.3.
In the third phase, the formula engine iterates the expression tree, performs static binding
operations, and produces a normalized tree. Static tree normalization is a new feature of
Analysis Services 2008. It includes implicit type conversions (type conversions were
discussed in Chapter 10, “MDX Concepts”) of all the nodes in the tree and does another
static operation that we call constant folding—the conversion of a function to an MDX
object. One of the examples of the constant folding is conversion from the Time.Level(1)
expression to the equivalent Time.Year expression. In the preceding version, Analysis
Services performed type conversions during the cell calculation phase, which in some
queries could cause serious performance problems. Static normalization of MDX expres-
sions during parsing allows relatively inexpensive (before any data is retrieved or calcu-
lated) mapping between types of the objects used as function parameters and MDX
functions that accept those parameters. For the query in Listing 29.1, Analysis Services
generates the normalized expression tree shown in Figure 29.4.
As the result of the static type conversion, new nodes (shown in Figure 29.4 in gray) are
inserted into the tree: MDXValue() , MDXValue() , MDSet , and MDXCurrentMember . By adding
an MDXValue node to the normalized tree, Analysis Services implicitly converts the expres-
sion [Time].[Time].PrevMember to the [Time].[Time].CurrentMember.PrevMember ,
because the function .PrevMember operates on a member and not on the hierarchy
[Time].[Time] .
Creation of Calculation Scopes
After the second phase of parsing—semantical analysis—Analysis Services evaluates MDX
calculations that can be applied to the query. All calculations are stored in Scope objects.
A Scope object contains a collection of all kinds of calculations that Analysis Services
supports, such as calculated members, named sets, calculated cells (this collection stores
 
Search WWH ::




Custom Search