This is an automated email from the ASF dual-hosted git repository. yaqian pushed a commit to branch mdx-query-demo in repository https://gitbox.apache.org/repos/asf/kylin.git
commit 63c8d792bfd7e4f2fcc86f321048893f3ae1a43c Author: lwz9103 <lwz9...@163.com> AuthorDate: Mon Jun 8 19:37:18 2020 +0800 init repo --- .gitignore | 31 ++++++++++++++ lib/olap4j-1.2.0.jar | Bin 0 -> 336397 bytes lib/olap4j-xmla-1.2.0.jar | Bin 0 -> 217778 bytes lib/xercesImpl-2.9.1.jar | Bin 0 -> 1229125 bytes pom.xml | 46 +++++++++++++++++++++ .../mdxquerydemo/MdxQueryDemoApplication.java | 35 ++++++++++++++++ 6 files changed, 112 insertions(+) diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a2a3040 --- /dev/null +++ b/.gitignore @@ -0,0 +1,31 @@ +HELP.md +target/ +!.mvn/wrapper/maven-wrapper.jar +!**/src/main/** +!**/src/test/** + +### STS ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache + +### IntelliJ IDEA ### +.idea +*.iws +*.iml +*.ipr + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ +build/ + +### VS Code ### +.vscode/ diff --git a/lib/olap4j-1.2.0.jar b/lib/olap4j-1.2.0.jar new file mode 100755 index 0000000..00b1c9c Binary files /dev/null and b/lib/olap4j-1.2.0.jar differ diff --git a/lib/olap4j-xmla-1.2.0.jar b/lib/olap4j-xmla-1.2.0.jar new file mode 100755 index 0000000..d514e69 Binary files /dev/null and b/lib/olap4j-xmla-1.2.0.jar differ diff --git a/lib/xercesImpl-2.9.1.jar b/lib/xercesImpl-2.9.1.jar new file mode 100644 index 0000000..547f563 Binary files /dev/null and b/lib/xercesImpl-2.9.1.jar differ diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..baf0d8d --- /dev/null +++ b/pom.xml @@ -0,0 +1,46 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <groupId>io.kyligence</groupId> + <artifactId>mdx-query-demo</artifactId> + <version>0.0.1-SNAPSHOT</version> + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-compiler-plugin</artifactId> + <configuration> + <source>6</source> + <target>6</target> + </configuration> + </plugin> + </plugins> + </build> + <name>mdx-query-demo</name> + + <properties> + <java.version>1.8</java.version> + </properties> + + <dependencies> + <dependency> + <groupId>org.olap4j</groupId> + <artifactId>olap4j</artifactId> + <version>1.2.0</version> + </dependency> + + <dependency> + <groupId>xerces</groupId> + <artifactId>xercesImpl</artifactId> + <version>2.9.1</version> + </dependency> + + <dependency> + <groupId>org.olap4j</groupId> + <artifactId>olap4j-xmla</artifactId> + <version>1.2.0</version> + </dependency> + </dependencies> + +</project> diff --git a/src/main/java/io/kyligence/mdxquerydemo/MdxQueryDemoApplication.java b/src/main/java/io/kyligence/mdxquerydemo/MdxQueryDemoApplication.java new file mode 100644 index 0000000..a3c0eb2 --- /dev/null +++ b/src/main/java/io/kyligence/mdxquerydemo/MdxQueryDemoApplication.java @@ -0,0 +1,35 @@ +package io.kyligence.mdxquerydemo; + +import org.olap4j.*; +import org.olap4j.metadata.Member; + +import java.sql.Connection; +import java.sql.DriverManager; + +public class MdxQueryDemoApplication { + + public static void main(String[] args) throws Exception { + Class.forName("org.olap4j.driver.xmla.XmlaOlap4jDriver"); + Connection connection = + DriverManager.getConnection( + "jdbc:xmla:Server=http://localhost:7080/mdx/xmla/learn_kylin?username=ADMIN&password=KYLIN"); + OlapConnection olapConnection = connection.unwrap(OlapConnection.class); + OlapStatement statement = olapConnection.createStatement(); + String mdx = "SELECT NON EMPTY Hierarchize(AddCalculatedMembers({DrilldownLevel({[KYLIN_COUNTRY].[NAME].[All]})})) " + + "DIMENSION PROPERTIES PARENT_UNIQUE_NAME ON COLUMNS FROM [test001] WHERE ([Measures].[SUM_PRICE]) " + + "CELL PROPERTIES VALUE, FORMAT_STRING, LANGUAGE, BACK_COLOR, FORE_COLOR, FONT_FLAGS"; + CellSet cellSet = + statement.executeOlapQuery(mdx); + for (Position column : cellSet.getAxes().get(0)) { + for (Member member : column.getMembers()) { + System.out.println(member.getUniqueName()); + } + final Cell cell = cellSet.getCell(column); + System.out.println(cell.getValue()); + System.out.println(); + } + } + + + +}