Skip to content

Commit

Permalink
MONDRIAN: Give each dialect control how literals of various datatypes…
Browse files Browse the repository at this point in the history
… are formatted.

	Widen the list of column types: was String, Numeric; add Integer, Date, Time, Timestamp, Boolean.

[git-p4: depot-paths = "//open/mondrian/": change = 8179]
  • Loading branch information
julianhyde committed Nov 18, 2006
1 parent 8b34c9f commit 6d5d857
Show file tree
Hide file tree
Showing 19 changed files with 471 additions and 271 deletions.
103 changes: 44 additions & 59 deletions doc/schema.html
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,8 @@ <h1>3.2 Measures<a name="Measures">&nbsp;</a></h1>

<p>The optional <code>datatype</code> attribute specifies how cell values are represented in Mondrian's
cache, and how they are returned via XML for Analysis. The <code>datatype</code> attribute can have
values "<code>String</code>", "<code>Integer</code>" and "<code>Numeric</code>".
values "<code>String</code>", "<code>Integer</code>", &quot;<code>Numeric</code>", &quot;<code>Boolean</code>&quot;,
&quot;<code>Date</code>&quot;, &quot;<code>Time</code>&quot;, and &quot;<code>Timestamp</code>&quot;.
The default is "<code>Numeric</code>", except for "<code>count</code>" and
"<code>distinct-count</code>" measures, which are "<code>Integer</code>".</p>

Expand Down Expand Up @@ -322,12 +323,12 @@ <h1>An example</h1>
<p>Let's look at a simple dimension. </p>
<blockquote>
<code>
&lt;<a href="#XML_Dimension">Dimension</a> name="Gender" foreignKey="customer_id"&gt;<br>
<span style="padding-left:10px;">&lt;<a href="#XML_Hierarchy">Hierarchy</a> hasAll="true" primaryKey="customer_id"&gt;</span><br>
<span style="padding-left:20px;">&lt;<a href="#XML_Table">Table</a> name="customer"/&gt;</span><br>
<span style="padding-left:20px;">&lt;<a href="#XML_Level">Level</a> name="Gender" column="gender" uniqueMembers="true"/&gt;</span><br>
<span style="padding-left:10px;">&lt;/<a href="#XML_Hierarchy">Hierarchy</a>&gt;</span><br>
&lt;/<a href="#XML_Dimension">Dimension</a>&gt;
&lt;<a href="#XML_Dimension">Dimension</a> name="Gender" foreignKey="customer_id"&gt;<br>
&nbsp; &lt;<a href="#XML_Hierarchy">Hierarchy</a> hasAll="true" primaryKey="customer_id"&gt;<br>
&nbsp; &lt;<a href="#XML_Table">Table</a> name="customer"/&gt;<br>
&nbsp;&nbsp;&nbsp; &lt;<a href="#XML_Level">Level</a> name="Gender" column="gender" uniqueMembers="true"/&gt;<br>
&nbsp; &lt;/<a href="#XML_Hierarchy">Hierarchy</a>&gt;<br>
&lt;/<a href="#XML_Dimension">Dimension</a>&gt;
</code>
</blockquote>

Expand Down Expand Up @@ -432,22 +433,14 @@ <h1>3.3.3 Time dimensions<a name="Time_dimensions">&nbsp;</a></h1>
<blockquote>
<code>
&lt;<a href="#XML_Dimension">Dimension</a> name=&quot;Time&quot; type=&quot;TimeDimension&quot;&gt;<br>
<span style="padding-left:10px">&lt;<a href="#XML_Hierarchy">Hierarchy</a> hasAll=&quot;true&quot; allMemberName=&quot;All Periods&quot;</span><br />
<span style="padding-left:10px">primaryKey=&quot;dateid&quot;&gt;</span><br>
<span style="padding-left:20px">&lt;<a href="#XML_Table">Table</a> name=&quot;datehierarchy&quot;/&gt;</span><br>
<span style="padding-left:20px">&lt;<a href="#XML_Level">Level</a> name=&quot;Year&quot; column=&quot;year&quot; uniqueMembers=&quot;true&quot;</span><br />
<span style="padding-left:20px">levelType=&quot;TimeYears&quot; type=&quot;Numeric&quot;/&gt;</span><br>
<span style="padding-left:20px">&lt;<a href="#XML_Level">Level</a> name=&quot;Quarter&quot; column=&quot;quarter&quot;</span><br>
<span style="padding-left:20px">uniqueMembers=&quot;false&quot; levelType=&quot;TimeQuarters&quot; /&gt;</span><br>
<span style="padding-left:20px">&lt;<a href="#XML_Level">Level</a> name=&quot;Month&quot; column=&quot;month&quot; uniqueMembers=&quot;false&quot;</span><br>
<span style="padding-left:20px">ordinalColumn=&quot;month&quot; nameColumn=&quot;month_name&quot;</span><br>
<span style="padding-left:20px">levelType=&quot;TimeMonths&quot; type=&quot;Numeric&quot;/&gt;</span><br>
<span style="padding-left:20px">&lt;<a href="#XML_Level">Level</a> name=&quot;Week&quot; column=&quot;week_in_month&quot;</span><br>
<span style="padding-left:20px">uniqueMembers=&quot;false&quot; levelType=&quot;TimeWeeks&quot; /&gt;</span><br>
<span style="padding-left:20px">&lt;<a href="#XML_Level">Level</a> name=&quot;Day&quot; column=&quot;day_in_month&quot;</span><br>
<span style="padding-left:20px">uniqueMembers=&quot;false&quot; ordinalColumn=&quot;day_in_month&quot;</span><br>
<span style="padding-left:20px">nameColumn=&quot;day_name&quot; levelType=&quot;TimeDays&quot; type=&quot;Numeric&quot;/&gt;</span><br>
<span style="padding-left:10px">&lt;/<a href="#XML_Hierarchy">Hierarchy</a>&gt;</span><br>
<span style="padding-left:10px">&nbsp; &lt;<a href="#XML_Hierarchy">Hierarchy</a> hasAll=&quot;true&quot; allMemberName=&quot;All Periods&quot; primaryKey=&quot;dateid&quot;&gt;</span><br>
<span style="padding-left:20px">&nbsp;&nbsp;&nbsp; &lt;<a href="#XML_Table">Table</a> name=&quot;datehierarchy&quot;/&gt;</span><br>
<span style="padding-left:20px">&nbsp;&nbsp;&nbsp; &lt;<a href="#XML_Level">Level</a> name=&quot;Year&quot; column=&quot;year&quot; uniqueMembers=&quot;true&quot; levelType=&quot;TimeYears&quot; type=&quot;Numeric&quot;/&gt;</span><br>
<span style="padding-left:20px">&nbsp;&nbsp;&nbsp; &lt;<a href="#XML_Level">Level</a> name=&quot;Quarter&quot; column=&quot;quarter&quot; uniqueMembers=&quot;false&quot; levelType=&quot;TimeQuarters&quot; /&gt;</span><br>
<span style="padding-left:20px">&nbsp;&nbsp;&nbsp; &lt;<a href="#XML_Level">Level</a> name=&quot;Month&quot; column=&quot;month&quot; uniqueMembers=&quot;false&quot; ordinalColumn=&quot;month&quot; nameColumn=&quot;month_name&quot; levelType=&quot;TimeMonths&quot; type=&quot;Numeric&quot;/&gt;</span><br>
<span style="padding-left:20px">&nbsp;&nbsp;&nbsp; &lt;<a href="#XML_Level">Level</a> name=&quot;Week&quot; column=&quot;week_in_month&quot; uniqueMembers=&quot;false&quot; levelType=&quot;TimeWeeks&quot; /&gt;</span><br>
<span style="padding-left:20px">&nbsp;&nbsp;&nbsp; &lt;<a href="#XML_Level">Level</a> name=&quot;Day&quot; column=&quot;day_in_month&quot; uniqueMembers=&quot;false&quot; ordinalColumn=&quot;day_in_month&quot; nameColumn=&quot;day_name&quot; levelType=&quot;TimeDays&quot; type=&quot;Numeric&quot;/&gt;</span><br>
<span style="padding-left:10px">&nbsp; &lt;/<a href="#XML_Hierarchy">Hierarchy</a>&gt;</span><br>
&lt;/<a href="#XML_Dimension">Dimension</a>&gt;
</code>
</blockquote>
Expand All @@ -459,7 +452,7 @@ <h1>3.3.4 Order and display of levels<a name="Level_Order_and_Display">&nbsp;</a

<p>Notice that in the time hierarchy example above the <code>ordinalColumn</code> and
<code>nameColumn</code> attributes on the <code>&lt;Level&gt;</code> element. These
effect how levels are displsyed in a result. The <code>ordinalColumn</code> attribute specifies a
effect how levels are displayed in a result. The <code>ordinalColumn</code> attribute specifies a
column in the Hierarchy table that provides the order of the members in a given Level, while the
<code>nameColumn</code> specifies a column that will be displayed.</p>

Expand All @@ -468,6 +461,15 @@ <h1>3.3.4 Order and display of levels<a name="Level_Order_and_Display">&nbsp;</a
month column, so valid member specifications will be of the form:
<code>[Time].[2005].[Q1].[<b><i>1</i></b>]</code>. Members of the <code>[Month]</code>
level will displayed in the order January, February, etc.</p>
<p>Levels contain a <code>type</code> attribute, which can have values &quot;<code>String</code>", "<code>Integer</code>", &quot;<code>Numeric</code>", &quot;<code>Boolean</code>&quot;,
&quot;<code>Date</code>&quot;, &quot;<code>Time</code>&quot;, and &quot;<code>Timestamp</code>&quot;.
The default value is <code>&quot;Numeric&quot;</code> because key columns generally have a numeric type. If it is a
different type, Mondrian needs to know this so it can generate SQL statements
correctly; for example, string values will be generated enclosed in single
quotes:</p>
<blockquote>
<p><code>WHERE productSku = '123-455-AA'</code></p>
</blockquote>
<!--
####################################
## 3.3.5 Multiple hierarchies #####
Expand All @@ -477,39 +479,22 @@ <h1>3.3.5 Multiple hierarchies<a name="Multiple_hierarchies">&nbsp;</a></h1>
<p>A dimension can contain more than one hierarchy:</p>

<blockquote>
<p><code>&lt;<a href="#XML_Dimension">Dimension</a> name="Time" foreignKey="time_id"&gt;<br>&nbsp; &lt;<a
href="#XML_Hierarchy">Hierarchy</a> hasAll="false" primaryKey="time_id"&gt;<br>
&nbsp;&nbsp;&nbsp; &lt;<a href="#XML_Table">Table</a> name="time_by_day"/&gt;<br>&nbsp;&nbsp;&nbsp; &lt;<a
href="#XML_Level">Level</a> name="Year" column="the_year" type="Numeric"<br />
&nbsp;&nbsp;&nbsp;&nbsp;uniqueMembers="true"/&gt;<br>

&nbsp;&nbsp;&nbsp; &lt;<a
href="#XML_Level">Level</a> name="Quarter" column="quarter"<br />
&nbsp;&nbsp;&nbsp;&nbsp;uniqueMembers="false"/&gt;<br>
&nbsp;&nbsp;&nbsp; &lt;<a
href="#XML_Level">Level</a> name="Month" column="month_of_year"<br />
&nbsp;&nbsp;&nbsp;&nbsp;type="Numeric" uniqueMembers="false"/&gt;<br>
&nbsp; &lt;/<a
href="#XML_Hierarchy">Hierarchy</a>&gt;<br>
&nbsp; &lt;<a
href="#XML_Hierarchy">Hierarchy</a> name="Time Weekly" hasAll="false"<br />
&nbsp;&nbsp;&nbsp;&nbsp;primaryKey="time_id"&gt;<br>

&nbsp;&nbsp;&nbsp; &lt;<a
href="#XML_Table">Table</a> name="time_by_week"/&gt;<br>
&nbsp;&nbsp;&nbsp; &lt;<a
href="#XML_Level">Level</a> name="Year" column="the_year" type="Numeric"<br />
&nbsp;&nbsp;&nbsp;&nbsp;uniqueMembers="true"/&gt;<br>
&nbsp;&nbsp;&nbsp; &lt;<a
href="#XML_Level">Level</a> name="Week" column="week"<br />
&nbsp;&nbsp;&nbsp;&nbsp;uniqueMembers="false"/&gt;<br>
&nbsp;&nbsp;&nbsp; &lt;<a
href="#XML_Level">Level</a> name="Day" column="day_of_week" type="String"<br />
&nbsp;&nbsp;&nbsp;&nbsp;uniqueMembers="false"/&gt;<br>

&nbsp; &lt;/<a
href="#XML_Hierarchy">Hierarchy</a>&gt;<br>&lt;/<a
href="#XML_Dimension">Dimension</a>&gt;</code></p>
<code>
&lt;<a href="#XML_Dimension">Dimension</a> name="Time" foreignKey="time_id"&gt;<br>
&nbsp; &lt;<a href="#XML_Hierarchy">Hierarchy</a> hasAll="false" primaryKey="time_id"&gt;<br>
&nbsp;&nbsp;&nbsp; &lt;<a href="#XML_Table">Table</a> name="time_by_day"/&gt;<br>
&nbsp;&nbsp;&nbsp; &lt;<a href="#XML_Level">Level</a> name="Year" column="the_year" type="Numeric" uniqueMembers="true"/&gt;<br>
&nbsp;&nbsp;&nbsp; &lt;<a href="#XML_Level">Level</a> name="Quarter" column="quarter" uniqueMembers="false"/&gt;<br>
&nbsp;&nbsp;&nbsp; &lt;<a href="#XML_Level">Level</a> name="Month" column="month_of_year" type="Numeric" uniqueMembers="false"/&gt;<br>
&nbsp; &lt;/<a href="#XML_Hierarchy">Hierarchy</a>&gt;<br>
&nbsp; &lt;<a href="#XML_Hierarchy">Hierarchy</a> name="Time Weekly" hasAll="false" primaryKey="time_id"&gt;<br>
&nbsp;&nbsp;&nbsp; &lt;<a href="#XML_Table">Table</a> name="time_by_week"/&gt;<br>
&nbsp;&nbsp;&nbsp; &lt;<a href="#XML_Level">Level</a> name="Year" column="the_year" type="Numeric"&nbsp;uniqueMembers="true"/&gt;<br>
&nbsp;&nbsp;&nbsp; &lt;<a href="#XML_Level">Level</a> name="Week" column="week" uniqueMembers="false"/&gt;<br>
&nbsp;&nbsp;&nbsp; &lt;<a href="#XML_Level">Level</a> name="Day" column="day_of_week" type="String" uniqueMembers="false"/&gt;<br>
&nbsp; &lt;/<a href="#XML_Hierarchy">Hierarchy</a>&gt;<br>
&lt;/<a href="#XML_Dimension">Dimension</a>&gt;
</code>
</blockquote>

<p>Notice that the first hierarchy doesn't have a name. By default, a hierarchy has the
Expand Down Expand Up @@ -742,7 +727,7 @@ <h1>3.3.9 Approximate level cardinality<a name="Approximate_level_cardinality">&

<p>The <a
href="#XML_Level">&lt;Level&gt;</a> element allows specifying the optional attribute "approxRowCount". Specifying
approxRowCount can improve performance by reducing the need to determine level, hierarchy, and dimension cardinality.
<code>approxRowCount</code> can improve performance by reducing the need to determine level, hierarchy, and dimension cardinality.
This can have a significant impact when connecting to Mondrian via XMLA.</p>
<!--
#######################################
Expand Down Expand Up @@ -1247,7 +1232,7 @@ <h1>5.3 Member properties<a name="Member_properties">&nbsp;</a></h1>
</blockquote>

<p>Mondrian deduces the type of the property expression, if it can. If the property name is a
constant string, the type is based upon the type attribute ("String", "Numeric" or "Boolean")
constant string, the type is based upon the <code>type</code> attribute ("String", "Numeric" or "Boolean")
of the property definition. If the property name is an expression (for example
<code>CurrentMember.Properties("Store " + "Type")</code>), Mondrian will return an untyped
value.</p>
Expand Down
66 changes: 55 additions & 11 deletions src/main/mondrian/olap/Mondrian.xml
Original file line number Diff line number Diff line change
Expand Up @@ -526,13 +526,23 @@ Revision is $Id$
</Attribute>
<Attribute name="type" default="String">
<Doc>
Indicates the type of this level's key column: String or
Numeric. When generating SQL statements, Mondrian
Indicates the type of this level's key column:
String, Numeric, Integer, Boolean, Date, Time or Timestamp.
When generating SQL statements, Mondrian
encloses values for String columns in quotation marks,
but leaves values for Numeric columns un-quoted.
but leaves values for Integer and Numeric columns un-quoted.

<p/>Date, Time, and Timestamp values are quoted according to the
SQL dialect. For a SQL-compliant dialect, the values appear
prefixed by their typename, for example, "DATE '2006-06-01'".
</Doc>
<Value>String</Value>
<Value>Numeric</Value>
<Value>Integer</Value>
<Value>Boolean</Value>
<Value>Date</Value>
<Value>Time</Value>
<Value>Timestamp</Value>
</Attribute>
<Attribute name="uniqueMembers" type="Boolean" default="false">
<Doc>
Expand Down Expand Up @@ -626,6 +636,7 @@ Revision is $Id$
return null;
}
}

public Expression getNameExp() {
if (nameExp != null) {
return nameExp;
Expand All @@ -635,13 +646,15 @@ Revision is $Id$
return null;
}
}

public Expression getCaptionExp() {
if (captionColumn != null) {
return new Column(table, captionColumn);
} else {
return null;
}
}

public Expression getOrdinalExp() {
if (ordinalExp != null) {
return ordinalExp;
Expand All @@ -651,6 +664,7 @@ Revision is $Id$
return null;
}
}

public Expression getParentExp() {
if (parentExp != null) {
return parentExp;
Expand All @@ -660,9 +674,14 @@ Revision is $Id$
return null;
}
}

public Expression getPropertyExp(int i) {
return new Column(table, properties[i].column);
}

public mondrian.rolap.sql.SqlQuery.Datatype getDatatype() {
return mondrian.rolap.sql.SqlQuery.Datatype.valueOf(type);
}
</Code>
</Element>

Expand All @@ -685,10 +704,17 @@ Revision is $Id$
<Attribute name="name"><Doc></Doc></Attribute>
<Attribute name="column"><Doc></Doc></Attribute>
<Attribute name="type" default="String">
<Doc>Data type of this property</Doc>
<Doc>
Data type of this property:
String, Numeric, Integer, Boolean, Date, Time or Timestamp.
</Doc>
<Value>String</Value>
<Value>Numeric</Value>
<Value>Integer</Value>
<Value>Boolean</Value>
<Value>Date</Value>
<Value>Time</Value>
<Value>Timestamp</Value>
</Attribute>
<Attribute name="formatter" required="false">
<Doc>
Expand Down Expand Up @@ -718,15 +744,20 @@ Revision is $Id$
</Attribute>
<Attribute name="datatype" required="false">
<Doc>
The datatype of this measure.
Valid values are 'String', 'Numeric' and 'Integer'.
The default datatype of a measure is
The datatype of this measure:
String, Numeric, Integer, Boolean, Date, Time or Timestamp.

<p/>The default datatype of a measure is
'Integer' if the measure's aggregator is 'Count',
otherwise it is 'Numeric'.
</Doc>
<Value>String</Value>
<Value>Numeric</Value>
<Value>Integer</Value>
<Value>String</Value>
<Value>Boolean</Value>
<Value>Date</Value>
<Value>Time</Value>
<Value>Timestamp</Value>
</Attribute>
<Attribute name="formatString">
<Doc>
Expand Down Expand Up @@ -1194,8 +1225,16 @@ Revision is $Id$
</Attribute>
<Attribute name="type" required="true">
<Doc>
Type of the column (String or Numeric)
Type of the column:
String, Numeric, Integer, Boolean, Date, Time or Timestamp.
</Doc>
<Value>String</Value>
<Value>Numeric</Value>
<Value>Integer</Value>
<Value>Boolean</Value>
<Value>Date</Value>
<Value>Time</Value>
<Value>Timestamp</Value>
</Attribute>
</Element>

Expand Down Expand Up @@ -1668,11 +1707,16 @@ Revision is $Id$
</Attribute>
<Attribute name="type" default="String" required="true">
<Doc>
Indicates the type of this parameter: String,
Numeric or Member.
Indicates the type of this parameter:
String, Numeric, Integer, Boolean, Date, Time, Timestamp, or Member.
</Doc>
<Value>String</Value>
<Value>Numeric</Value>
<Value>Integer</Value>
<Value>Boolean</Value>
<Value>Date</Value>
<Value>Time</Value>
<Value>Timestamp</Value>
<Value>Member</Value>
</Attribute>
<Attribute name="modifiable" type="Boolean" required="false" default="true">
Expand Down
Loading

0 comments on commit 6d5d857

Please sign in to comment.