SELECT {[Measures].[Unit Sales], [Measures].[Store Sales]} ON COLUMNS, {Descendants([Time].[Yearly].[1997].[Q1])} ON ROWS FROM [Sales] WHERE [Customer].[Gender].[F]
An optional formatString attribute specifies how the value is to be printed. Here, we have chosen to output unit sales with no decimal places (since it is an integer), and store sales with two decimal places (since it is a currency value). The ',' and '.' symbols are locale-sensitive, so if you were running in Italian, store sales might appear as "48.123,45". You can achieve even more wild effects using advanced format strings.
一些属性具有“在父”和“无父”的形式。例如,该[Time].[Month]属性在10年内有120个成员,而[Time].[Month of Year] 仅有12个成员。第一个可以用来比较2012年12月份的平底雪橇销售是否比2011年12月好; 第二个可以用来比较12月份的平底雪橇比四月份更好。你需要定义两个独立的属性。没有简单的方法来定义其中一个,或者它们之间的自动映射。你可以做的最好的办法是使用一个命名约定,比如“ Parent of Attribute ”,这样所有这些属性的对应关系对你的最终用户都是清楚的。
(Rationale as follows. If we used links for purposes such as connecting fact to dimension tables, many schemas would become cyclic or ambiguous (there might be multiple paths between various tables). But we still think it is useful to be able define links in a diagram, as a guideline for what join paths make sense. After all, doesn't everyone wish there were a schema diagram for every schema? A schema modeler would, we hope, include a diagramming tool, and if links are present, it would suggest that they are used when defining connections in the schema.)
4.6 Table Hints
Mondrian supports a limited set of database-specific hints for the
element, which will then be passed on to SQL queries involving the table. These hints are as follows:
Database
Hint Type
Permitted Values
Description
MySQL
force_index
The name of an index on this table
Forces the named index to be used when selecting level values from this table.
For example:
my_index
As with the functional dependency optimizations, support for table hints is in a transitional stage, and are likely to change in Mondrian 4.0. Any schema using them may need to be migrated to the new schema syntax as part of upgrading to Mondrian 4.0.
4. Star and snowflake schemas
We saw earlier how to build a cube based upon a fact table, and dimensions in the fact table ("Payment method") and in a table joined to the fact table ("Gender"). This is the most common kind of mapping, and is known as a star schema.
If we want to compute the total salary budget for Bill, we need to add in the salaries of Eric and Carla (who report to Bill) and Mark (who reports to Eric). Usually Mondrian generates a SQL GROUP BY statement to compute these totals, but there is no (generally available) SQL construct which can traverse hierarchies. So by default, Mondrian generates one SQL statement per supervisor, to retrieve and total all of that supervisor's direct reports.
This approach has a couple of drawbacks. First, the performance is not very good if a hierarchy contains more than a hundred members. Second, because Mondrian implements the distinct-count aggregator by generating SQL, you cannot define a distinct-count measure in any cube which contains a parent-child hierarchy.
CREATE UNIQUE INDEX employee_closure_pk ON employee_closure ( supervisor_id, employee_id); CREATE INDEX employee_closure_emp ON employee_closure ( employee_id);
CREATE PROCEDURE populate_employee_closure() BEGIN DECLARE distance int; TRUNCATE TABLE employee_closure; SET distance = 0; -- seed closure with self-pairs (distance 0) INSERT INTO employee_closure (supervisor_id, employee_id, distance) SELECT employee_id, employee_id, distance FROM employee;
-- for each pair (root, leaf) in the closure, -- add (root, leaf->child) from the base table REPEAT SET distance = distance + 1; INSERT INTO employee_closure (supervisor_id, employee_id, distance) SELECT employee_closure.supervisor_id, employee.employee_id, distance FROM employee_closure, employee WHERE employee_closure.employee_id = employee.supervisor_id AND employee_closure.distance = distance - 1; UNTIL (ROW_COUNT() == 0)) END REPEAT; END //
WITH MEMBER [Measures].[Profit] AS '[Measures].[Store Sales]-[Measures].[Store Cost]', FORMAT_STRING = '$#,###' SELECT {[Measures].[Store Sales], [Measures].[Profit]} ON COLUMNS, {[Product].Children} ON ROWS FROM [Sales] WHERE [Time].[1997]
The FORMAT_STRING property value can also be evaluated using an expression. When formatting a particular cell, first the expression is evaluated to yield a format string, then the format string is applied to the cell value. Here is the same property with a conditional format string:
For more details about format strings, see the MDX specification.
One additional calculated member property that is worth mentioning is DATATYPE. As with measures, setting datatype specifies how the calculated member is returned via XML for Analysis. The DATATYPE property of a calculated member can have values "String", "Integer", or "Numeric":
WITH SET [Top Sellers] AS 'TopCount([Warehouse].[Warehouse Name].MEMBERS, 5, [Measures].[Warehouse Sales])' SELECT {[Measures].[Warehouse Sales]} ON COLUMNS, {[Top Sellers]} ON ROWS FROM [Warehouse] WHERE [Time].[Year].[1997]
在架构中定义的命名集可用于该架构中的所有多维数据集和虚拟多维数据集。但是,只有在多维数据集包含使公式有效的名称所需的维度时才有效。例如,[CA Cities]在查询[Sales]和[Warehouse and Sales]多维[Warehouse]数据集中使用它是有效的,但是如果您在针对多维数据集的查询中使用它,则会出现错误,因为[Warehouse]它没有[Store]维度。
/** * A simple user-defined function which adds one to its argument. */ public class PlusOneUdf implements UserDefinedFunction { // public constructor public PlusOneUdf() { }
public String getName() { return "PlusOne"; }
public String getDescription() { return "Returns its argument plus one"; }
public Syntax getSyntax() { return Syntax.Function; }
public Type getReturnType(Type[] parameterTypes) { return new NumericType(); }
public Type[] getParameterTypes() { return new Type[] {new NumericType()}; }
public Object execute(Evaluator evaluator, Exp[] arguments) { final Object argValue = arguments[0].evaluateScalar(evaluator); if (argValue instanceof Number) { return new Double(((Number) argValue).doubleValue() + 1); } else { // Argument might be a RuntimeException indicating that // the cache does not yet have the required cell value. The // function will be called again when the cache is loaded. return null; } }
public String[] getReservedWords() { return null; } }
在你的模式中声明它:
...
并在任何MDX语句中使用它:
WITH MEMBER [Measures].[Unit Sales Plus One] AS 'PlusOne([Measures].[Unit Sales])' SELECT {[Measures].[Unit Sales]} ON COLUMNS, {[Gender].MEMBERS} ON ROWS FROM [Sales]
/** * A user-defined function which either adds one to or * subtracts one from its argument. */ public class PlusOrMinusOneUdf implements UserDefinedFunction { private final name; private final isPlus;
// public constructor with one argument public PlusOneUdf(String name) { this.name = name; if (name.equals("PlusOne")) { isPlus = true; } else if (name.equals("MinusOne")) { isPlus = false; } else { throw new IllegalArgumentException("Unexpected name " + name); } }
public String getName() { return name; }
public String getDescription() { return "Returns its argument plus or minus one"; }
public Syntax getSyntax() { return Syntax.Function; }
public Type getReturnType(Type[] parameterTypes) { return new NumericType(); }
public Type[] getParameterTypes() { return new Type[] {new NumericType()}; }
public Object execute(Evaluator evaluator, Exp[] arguments) { final Object argValue = arguments[0].evaluateScalar(evaluator); if (argValue instanceof Number) { if (isPlus) { return new Double(((Number) argValue).doubleValue() + 1); } else { return new Double(((Number) argValue).doubleValue() - 1); } } else { // Argument might be a RuntimeException indicating that // the cache does not yet have the required cell value. The // function will be called again when the cache is loaded. return null; } }
public String[] getReservedWords() { return null; } }
WITH MEMBER [Measures].[Foo] AS '[Measures].[Unit Sales] * 2', CELL_FORMATTER='com.example.MyCellFormatter' SELECT {[Measures].[Unit Sales], [Measures].[Foo]} ON COLUMNS, {[Store].Children} ON ROWS FROM [Sales]
WITH MEMBER [Measures].[Foo] AS '[Measures].[Unit Sales] * 2', CELL_FORMATTER_SCRIPT_LANGUAGE='JavaScript', CELL_FORMATTER_SCRIPT='var s = value.toString(); while (s.length() < 20) s = "0" + s; return s;' SELECT {[Measures].[Unit Sales], [Measures].[Foo]} ON COLUMNS, {[Store].Children} ON ROWS FROM [Sales]
A 定义模式中对象的默认访问权限。该access属性可以是“全部”或“无”; 这个访问可以被特定的对象覆盖。在这种情况下,因为 access="none"用户只能浏览“销售”多维数据集,因为它是明确授予的。
A 定义了对特定多维数据集的访问。至于访问属性可以是“全部”,“自定义”或“无”,并可以覆盖多维数据集中的特定子对象。
A 定义对维度的访问。访问属性可以是“all”,“custrom”或“none”。“全部”的访问级别意味着该维度的所有子级别将获得继承的访问权限。“自定义”的访问级别意味着角色不能获得对子层次结构的固有访问权限,除非使用元素明确授予角色 。
A 定义了对层次结构的访问。访问属性可以是“全部”,意味着所有成员都可见; “无”,意味着层级的存在对用户是隐藏的; 和“定制”。使用自定义访问权限,您可以使用该topLevel 属性来定义可见的最高级别(防止用户看到太多的“大图片”,例如查看收入卷起到 Store Country级别)。或者使用该bottomLevel 属性来定义可见的底层(这里,防止用户侵入个人客户的细节); 或者通过定义嵌套 元素来控制用户可以看到的成员集合。
什么是Thrift
The Apache Thrift software framework, for scalable cross-language services development, combines a software stack with a code generation engine to build services that work efficiently and s
org.json.JSONException: No value for items
在JSON解析中会遇到一种错误,很常见的错误
06-21 12:19:08.714 2098-2127/com.jikexueyuan.secret I/System.out﹕ Result:{"status":1,"page":1,&