You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kylin.apache.org by ya...@apache.org on 2022/03/28 11:09:13 UTC
[kylin] branch mdx-query-demo created (now c97d174)
This is an automated email from the ASF dual-hosted git repository.
yaqian pushed a change to branch mdx-query-demo
in repository https://gitbox.apache.org/repos/asf/kylin.git.
at c97d174 MDX query demo
This branch includes the following new commits:
new 63c8d79 init repo
new c97d174 MDX query demo
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
[kylin] 02/02: MDX query demo
Posted by ya...@apache.org.
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 c97d174517ed1c7aef8299f867927e5552527a65
Author: yaqian.zhang <59...@qq.com>
AuthorDate: Mon Mar 28 19:06:30 2022 +0800
MDX query demo
---
.../mdxquerydemo/MdxQueryDemoApplication.java | 47 ++++++++++++++++------
1 file changed, 34 insertions(+), 13 deletions(-)
diff --git a/src/main/java/io/kyligence/mdxquerydemo/MdxQueryDemoApplication.java b/src/main/java/io/kyligence/mdxquerydemo/MdxQueryDemoApplication.java
index a3c0eb2..96f0142 100644
--- a/src/main/java/io/kyligence/mdxquerydemo/MdxQueryDemoApplication.java
+++ b/src/main/java/io/kyligence/mdxquerydemo/MdxQueryDemoApplication.java
@@ -9,27 +9,48 @@ import java.sql.DriverManager;
public class MdxQueryDemoApplication {
public static void main(String[] args) throws Exception {
+ String mdx_ip = args.length != 0 ? args[0] : "localhost";
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");
+ "jdbc:xmla:Server=http://" + mdx_ip + ":7080/mdx/xmla/test_covid_project?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";
+ String mdx = "SELECT\n" +
+ "{[Measures].DefaultMember} DIMENSION PROPERTIES [MEMBER_UNIQUE_NAME],[MEMBER_ORDINAL],[MEMBER_CAPTION] ON COLUMNS,\n" +
+ "NON EMPTY CROSSJOIN(\n" +
+ " [DROPOFF_NEWYORK_ZONE].[BOROUGH].[BOROUGH].AllMembers,\n" +
+ " [PICKUP_NEWYORK_ZONE].[BOROUGH].[BOROUGH].AllMembers) DIMENSION PROPERTIES [MEMBER_UNIQUE_NAME],[MEMBER_ORDINAL],[MEMBER_CAPTION] ON ROWS\n" +
+ "FROM [nyc_taxi_coivd_dataset]";
CellSet cellSet =
statement.executeOlapQuery(mdx);
- for (Position column : cellSet.getAxes().get(0)) {
- for (Member member : column.getMembers()) {
- System.out.println(member.getUniqueName());
+
+ boolean flag = false;
+ for (Position row : cellSet.getAxes().get(1)) {
+ for (Position column : cellSet.getAxes().get(0)) {
+ if (!flag) {
+ flag = true;
+ for (Member member : row.getMembers()) {
+ String name = member.getUniqueName();
+ String[] s = name.split("\\.");
+ if (s.length > 1) {
+ name = s[0].concat(s[1]);
+ }
+ System.out.print(name);
+ System.out.print(" ");
+ }
+ for (Member member : column.getMembers()) {
+ System.out.println(member.getUniqueName());
+ System.out.println("-------------------------------------------------------------------------");
+ }
+ }
+ for (Member member : row.getMembers()) {
+ System.out.print(member.getCaption());
+ System.out.print(" ");
+ }
+ final Cell cell = cellSet.getCell(column, row);
+ System.out.println(cell.getFormattedValue());
}
- final Cell cell = cellSet.getCell(column);
- System.out.println(cell.getValue());
- System.out.println();
}
}
-
-
-
}
[kylin] 01/02: init repo
Posted by ya...@apache.org.
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 <lw...@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();
+ }
+ }
+
+
+
+}