You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lens.apache.org by pr...@apache.org on 2016/10/10 09:41:53 UTC
[4/4] lens git commit: LENS-1287: Create command in cli to create
schema taking parent directory where schema is stored
LENS-1287: Create command in cli to create schema taking parent directory where schema is stored
Project: http://git-wip-us.apache.org/repos/asf/lens/repo
Commit: http://git-wip-us.apache.org/repos/asf/lens/commit/d9884ec6
Tree: http://git-wip-us.apache.org/repos/asf/lens/tree/d9884ec6
Diff: http://git-wip-us.apache.org/repos/asf/lens/diff/d9884ec6
Branch: refs/heads/master
Commit: d9884ec6dcc59825f7f771b4d0c3cf7f187686f8
Parents: 2cfb7b0
Author: Rajat Khandelwal <pr...@apache.org>
Authored: Mon Oct 10 15:11:14 2016 +0530
Committer: Rajat Khandelwal <ra...@gmail.com>
Committed: Mon Oct 10 15:11:14 2016 +0530
----------------------------------------------------------------------
.../lens/cli/commands/LensDatabaseCommands.java | 3 +-
.../commands/LensDimensionTableCommands.java | 3 +-
.../lens/cli/commands/LensFactCommands.java | 3 +-
.../lens/cli/commands/LensSchemaCommands.java | 162 +++++++++++++
.../java/org/apache/lens/cli/LensCLITest.java | 67 ++++++
.../apache/lens/cli/TestLensCubeCommands.java | 6 +-
.../lens/cli/TestLensDatabaseCommands.java | 4 +-
.../lens/cli/TestLensDimensionCommands.java | 8 +-
.../cli/TestLensDimensionTableCommands.java | 7 +-
.../apache/lens/cli/TestLensFactCommands.java | 6 +-
.../TestLensFactCommandsWithMissingWeight.java | 4 +-
.../apache/lens/cli/TestLensQueryCommands.java | 4 +-
.../apache/lens/cli/TestLensSchemaCommands.java | 49 ++++
.../lens/cli/TestLensSegmentationCommands.java | 6 +-
.../lens/cli/TestLensStorageCommands.java | 6 +-
.../lens/cli/doc/TestGenerateCLIUserDoc.java | 68 ++++--
.../resources/cube_with_no_weight_facts.xml | 41 ----
lens-cli/src/test/resources/dim_table.xml | 48 ----
lens-cli/src/test/resources/dim_table2.xml | 48 ----
lens-cli/src/test/resources/fact1.xml | 51 -----
.../src/test/resources/fact_without_weight.xml | 51 -----
lens-cli/src/test/resources/local-storage.xml | 27 ---
lens-cli/src/test/resources/sample-cube.xml | 102 ---------
.../cubes/base/cube_with_no_weight_facts.xml | 41 ++++
.../resources/schema/cubes/base/sample-cube.xml | 102 +++++++++
.../resources/schema/dimensions/test-detail.xml | 32 +++
.../schema/dimensions/test-dimension.xml | 61 +++++
.../resources/schema/dimtables/dim_table.xml | 48 ++++
.../resources/schema/dimtables/dim_table2.xml | 48 ++++
.../src/test/resources/schema/facts/fact1.xml | 51 +++++
.../schema/facts/fact_without_weight.xml | 51 +++++
.../resources/schema/segmentations/seg1.xml | 45 ++++
.../resources/schema/storages/local-storage.xml | 26 +++
lens-cli/src/test/resources/seg1.xml | 45 ----
lens-cli/src/test/resources/test-detail.xml | 32 ---
lens-cli/src/test/resources/test-dimension.xml | 61 -----
src/site/apt/user/cli.apt | 228 ++++++++++++-------
37 files changed, 1010 insertions(+), 635 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lens/blob/d9884ec6/lens-cli/src/main/java/org/apache/lens/cli/commands/LensDatabaseCommands.java
----------------------------------------------------------------------
diff --git a/lens-cli/src/main/java/org/apache/lens/cli/commands/LensDatabaseCommands.java b/lens-cli/src/main/java/org/apache/lens/cli/commands/LensDatabaseCommands.java
index 05108f0..c6ae02b 100644
--- a/lens-cli/src/main/java/org/apache/lens/cli/commands/LensDatabaseCommands.java
+++ b/lens-cli/src/main/java/org/apache/lens/cli/commands/LensDatabaseCommands.java
@@ -87,7 +87,8 @@ public class LensDatabaseCommands extends LensCRUDCommand {
* @return the string
*/
@CliCommand(value = "drop database", help = "drop a database with specified name")
- public String dropDatabase(@CliOption(key = {"", "db"}, mandatory = true, help = "<database-name>") String database,
+ public String dropDatabase(
+ @CliOption(key = {"", "db", "database"}, mandatory = true, help = "<database-name>") String database,
@CliOption(key = "cascade", specifiedDefaultValue = "true", unspecifiedDefaultValue = "false") boolean cascade) {
return drop(database, cascade);
}
http://git-wip-us.apache.org/repos/asf/lens/blob/d9884ec6/lens-cli/src/main/java/org/apache/lens/cli/commands/LensDimensionTableCommands.java
----------------------------------------------------------------------
diff --git a/lens-cli/src/main/java/org/apache/lens/cli/commands/LensDimensionTableCommands.java b/lens-cli/src/main/java/org/apache/lens/cli/commands/LensDimensionTableCommands.java
index 7df5c7c..26650c1 100644
--- a/lens-cli/src/main/java/org/apache/lens/cli/commands/LensDimensionTableCommands.java
+++ b/lens-cli/src/main/java/org/apache/lens/cli/commands/LensDimensionTableCommands.java
@@ -110,7 +110,8 @@ public class LensDimensionTableCommands extends LogicalTableCrudCommand<XDimensi
+ " By default <cascade> is false")
public String dropDimensionTable(
@CliOption(key = {"", "dimtable_name"}, mandatory = true, help = "<dimtable_name>") String name,
- @CliOption(key = {"cascade"}, mandatory = false, unspecifiedDefaultValue = "false", help = "<cascade>")
+ @CliOption(key = {"cascade"}, mandatory = false, specifiedDefaultValue = "true", unspecifiedDefaultValue = "false",
+ help = "<cascade>")
boolean cascade) {
return drop(name, cascade);
}
http://git-wip-us.apache.org/repos/asf/lens/blob/d9884ec6/lens-cli/src/main/java/org/apache/lens/cli/commands/LensFactCommands.java
----------------------------------------------------------------------
diff --git a/lens-cli/src/main/java/org/apache/lens/cli/commands/LensFactCommands.java b/lens-cli/src/main/java/org/apache/lens/cli/commands/LensFactCommands.java
index 6457bce..9ea887a 100644
--- a/lens-cli/src/main/java/org/apache/lens/cli/commands/LensFactCommands.java
+++ b/lens-cli/src/main/java/org/apache/lens/cli/commands/LensFactCommands.java
@@ -105,7 +105,8 @@ public class LensFactCommands extends LogicalTableCrudCommand<XFactTable> {
+ " By default <cascade> is false")
public String dropFact(
@CliOption(key = {"", "fact_name"}, mandatory = true, help = "<fact_name>") String fact,
- @CliOption(key = {"cascade"}, mandatory = false, unspecifiedDefaultValue = "false", help = "<cascade>")
+ @CliOption(key = {"cascade"}, mandatory = false, specifiedDefaultValue = "true", unspecifiedDefaultValue = "false",
+ help = "<cascade>")
boolean cascade) {
return drop(fact, cascade);
}
http://git-wip-us.apache.org/repos/asf/lens/blob/d9884ec6/lens-cli/src/main/java/org/apache/lens/cli/commands/LensSchemaCommands.java
----------------------------------------------------------------------
diff --git a/lens-cli/src/main/java/org/apache/lens/cli/commands/LensSchemaCommands.java b/lens-cli/src/main/java/org/apache/lens/cli/commands/LensSchemaCommands.java
new file mode 100644
index 0000000..feabf9c
--- /dev/null
+++ b/lens-cli/src/main/java/org/apache/lens/cli/commands/LensSchemaCommands.java
@@ -0,0 +1,162 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.lens.cli.commands;
+
+import java.io.*;
+import java.util.List;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.apache.lens.cli.commands.annotations.UserDocumentation;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.shell.core.CommandMarker;
+import org.springframework.shell.core.JLineShellComponent;
+import org.springframework.shell.core.annotation.CliCommand;
+import org.springframework.shell.core.annotation.CliOption;
+import org.springframework.shell.support.logging.HandlerUtils;
+import org.springframework.stereotype.Component;
+import org.springframework.util.Assert;
+
+import com.google.common.collect.Lists;
+
+@Component
+@UserDocumentation(title = "Creating schema with one command",
+ description = "")
+public class LensSchemaCommands implements CommandMarker {
+ public static final String STRUCTURE = "\n"
+ + ".\n"
+ + "|-- storages\n"
+ + "| |-- storage1.xml\n"
+ + "| |-- storage2.xml\n"
+ + "|\n"
+ + "|-- dimensions\n"
+ + "| |-- dim1.xml\n"
+ + "| |-- dim2.xml\n"
+ + "|\n"
+ + "|-- cubes\n"
+ + "| |-- base\n"
+ + "| | |-- base_cube1.xml\n"
+ + "| | |-- base_cube2.xml\n"
+ + "| |\n"
+ + "| |-- derived\n"
+ + "| | |-- derived_cube1.xml\n"
+ + "| | |-- derived_cube2.xml\n"
+ + "| |\n"
+ + "| |-- independent_cube1.xml\n"
+ + "| |-- independent_cube2.xml\n"
+ + "|\n"
+ + "|-- dimensiontables\n"
+ + "| |-- dimtable1.xml\n"
+ + "| |-- dimtable2.xml\n"
+ + "|\n"
+ + "|-- dimtables\n"
+ + "| |-- dimtable3.xml\n"
+ + "| |-- dimtable4.xml\n"
+ + "|\n"
+ + "|-- facts\n"
+ + " |-- fact1.xml\n"
+ + " |-- fact2.xml\n\n\n"
+ + "If your cubes are divided between base and derived cubes,\nit makes sense to seperate into two directories, "
+ + "since derived cubes can't be created unless base cube exists.\nIn the other case you can keep them in the cubes "
+ + "directory itself.\nFor dimtables, you can keep your schema files in a directory named either dimtables or "
+ + "dimensiontables.\nEach of these directories is optional and the order of processing is top to bottom.\nCLI will "
+ + "let you know in case of any errors and proceed further without failing in between.";
+ protected final Logger logger = HandlerUtils.getLogger(getClass());
+
+ {
+ logger.setLevel(Level.FINE);
+ }
+
+ private static final FilenameFilter XML_FILTER = new FilenameFilter() {
+ @Override
+ public boolean accept(File dir, String name) {
+ return name.endsWith(".xml");
+ }
+ };
+ @Autowired
+ private JLineShellComponent shell;
+
+ @CliCommand(value = {"schema", "create schema"},
+ help = "Parses the specified resource file and executes commands for "
+ + "creation/updation of schema\nExpected structure is " + STRUCTURE)
+ public void script(
+ @CliOption(key = {"", "db"},
+ help = "<database-to-create-schema-in>", mandatory = true) final String database,
+ @CliOption(key = {"", "file", "path"},
+ help = "<schema-directory>", mandatory = true) final File schemaDirectory) {
+ if (!schemaDirectory.isDirectory()) {
+ throw new IllegalStateException("Schema directory should be a directory");
+ }
+
+ // ignore result. it can fail if database already exists
+ shell.executeCommand("create database " + database);
+ if (shell.executeScriptLine("use " + database)) {
+ createOrUpdate(new File(schemaDirectory, "storages"), "storage",
+ "create storage --path %s", "update storage --name %s --path %s");
+ createOrUpdate(new File(schemaDirectory, "dimensions"), "dimension",
+ "create dimension --path %s", "update dimension --name %s --path %s");
+ createOrUpdate(new File(new File(schemaDirectory, "cubes"), "base"), "base cube",
+ "create cube --path %s", "update cube --name %s --path %s");
+ createOrUpdate(new File(new File(schemaDirectory, "cubes"), "derived"), "derived cube",
+ "create cube --path %s", "update cube --name %s --path %s");
+ createOrUpdate(new File(schemaDirectory, "dimensiontables"), "dimension table",
+ "create dimtable --path %s", "update dimtable --dimtable_name %s --path %s");
+ createOrUpdate(new File(schemaDirectory, "dimtables"), "dimension table",
+ "create dimtable --path %s", "update dimtable --dimtable_name %s --path %s");
+ createOrUpdate(new File(schemaDirectory, "facts"), "fact",
+ "create fact --path %s", "update fact --fact_name %s --path %s");
+ createOrUpdate(new File(schemaDirectory, "segmentations"), "fact",
+ "create segmentation --path %s", "update segmentation --name %s --path %s");
+ } else {
+ throw new IllegalStateException("Switching to database " + database + " failed");
+ }
+ }
+
+ public List<File> createOrUpdate(File parent, String entityType, String createSyntax, String updateSyntax) {
+ List<File> failedFiles = Lists.newArrayList();
+ // Create/update entities
+ if (parent.exists()) {
+ Assert.isTrue(parent.isDirectory(), parent.toString() + " must be a directory");
+ for (File entityFile : parent.listFiles(XML_FILTER)) {
+ String entityName = entityFile.getName().substring(0, entityFile.getName().length() - 4);
+ String entityPath = entityFile.getAbsolutePath();
+ String createCommand = String.format(createSyntax, entityPath);
+ logger.fine(createCommand);
+ if (shell.executeScriptLine(createCommand)) {
+ logger.info("Created " + entityType + " " + entityName);
+ } else {
+ logger.warning("Create failed, trying update");
+ String updateCommand = String.format(updateSyntax, entityName, entityPath);
+ logger.fine(updateCommand);
+ if (shell.executeScriptLine(updateCommand)) {
+ logger.info("Updated " + entityType + " " + entityName);
+ } else {
+ logger.severe("Couldn't create or update " + entityType + " " + entityName);
+ failedFiles.add(entityFile);
+ }
+ }
+ }
+ }
+ if (!failedFiles.isEmpty()) {
+ logger.severe("Failed for " + entityType + ": " + failedFiles);
+ }
+ return failedFiles;
+ }
+}
http://git-wip-us.apache.org/repos/asf/lens/blob/d9884ec6/lens-cli/src/test/java/org/apache/lens/cli/LensCLITest.java
----------------------------------------------------------------------
diff --git a/lens-cli/src/test/java/org/apache/lens/cli/LensCLITest.java b/lens-cli/src/test/java/org/apache/lens/cli/LensCLITest.java
new file mode 100644
index 0000000..8d80c7b
--- /dev/null
+++ b/lens-cli/src/test/java/org/apache/lens/cli/LensCLITest.java
@@ -0,0 +1,67 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.lens.cli;
+
+import org.springframework.shell.Bootstrap;
+import org.springframework.shell.core.CommandResult;
+import org.springframework.shell.core.JLineShellComponent;
+import org.testng.Assert;
+import org.testng.annotations.BeforeClass;
+
+/**
+ * The Class TestLensStorageCommands.
+ */
+public class LensCLITest extends LensCliApplicationTest {
+
+ protected static JLineShellComponent shell;
+
+ @BeforeClass
+ public static void startUp() throws InterruptedException {
+ Bootstrap bootstrap = new Bootstrap();
+ shell = bootstrap.getJLineShellComponent();
+ }
+
+
+ public <T> T execute(String command) throws Throwable {
+ CommandResult commandResult = shell.executeCommand(command);
+ if (commandResult.isSuccess()) {
+ return (T) commandResult.getResult();
+ }
+ if (commandResult.getException() != null) {
+ throw commandResult.getException();
+ }
+ throw new AssertionError("Result is not success and exception is null");
+ }
+
+ public <T> void execute(String command, T result) throws Throwable {
+ Assert.assertEquals(execute(command), result);
+ }
+
+ public <T> void execute(String command, T result, Throwable throwable) throws Throwable {
+ CommandResult commandResult = shell.executeCommand(command);
+ if (commandResult.isSuccess()) {
+ Assert.assertNull(throwable);
+ Assert.assertEquals(commandResult.getResult(), result);
+ } else {
+ Assert.assertNull(result);
+ Assert.assertEquals(commandResult.getException().getClass(), throwable.getClass());
+ Assert.assertEquals(commandResult.getException().getMessage(), throwable.getMessage());
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/lens/blob/d9884ec6/lens-cli/src/test/java/org/apache/lens/cli/TestLensCubeCommands.java
----------------------------------------------------------------------
diff --git a/lens-cli/src/test/java/org/apache/lens/cli/TestLensCubeCommands.java b/lens-cli/src/test/java/org/apache/lens/cli/TestLensCubeCommands.java
index c20766c..ae12deb 100644
--- a/lens-cli/src/test/java/org/apache/lens/cli/TestLensCubeCommands.java
+++ b/lens-cli/src/test/java/org/apache/lens/cli/TestLensCubeCommands.java
@@ -55,13 +55,13 @@ public class TestLensCubeCommands extends LensCliApplicationTest {
LensDimensionCommands dimensionCommand = new LensDimensionCommands();
dimensionCommand.setClient(client);
dimensionCommand.createDimension(new File(
- TestLensCubeCommands.class.getClassLoader().getResource("test-detail.xml").toURI()));
+ TestLensCubeCommands.class.getClassLoader().getResource("schema/dimensions/test-detail.xml").toURI()));
dimensionCommand.createDimension(new File(
- TestLensCubeCommands.class.getClassLoader().getResource("test-dimension.xml").toURI()));
+ TestLensCubeCommands.class.getClassLoader().getResource("schema/dimensions/test-dimension.xml").toURI()));
LensCubeCommands command = new LensCubeCommands();
command.setClient(client);
LOG.debug("Starting to test cube commands");
- URL cubeSpec = TestLensCubeCommands.class.getClassLoader().getResource("sample-cube.xml");
+ URL cubeSpec = TestLensCubeCommands.class.getClassLoader().getResource("schema/cubes/base/sample-cube.xml");
String cubeList = command.showCubes();
assertFalse(cubeList.contains("sample_cube"));
command.createCube(new File(cubeSpec.toURI()));
http://git-wip-us.apache.org/repos/asf/lens/blob/d9884ec6/lens-cli/src/test/java/org/apache/lens/cli/TestLensDatabaseCommands.java
----------------------------------------------------------------------
diff --git a/lens-cli/src/test/java/org/apache/lens/cli/TestLensDatabaseCommands.java b/lens-cli/src/test/java/org/apache/lens/cli/TestLensDatabaseCommands.java
index 9687c60..7fc8438 100644
--- a/lens-cli/src/test/java/org/apache/lens/cli/TestLensDatabaseCommands.java
+++ b/lens-cli/src/test/java/org/apache/lens/cli/TestLensDatabaseCommands.java
@@ -68,8 +68,8 @@ public class TestLensDatabaseCommands extends LensCliApplicationTest {
result = command.switchDatabase(myDatabase);
assertEquals(result, "Successfully switched to my_db");
if (cascade) {
- String createOutput = cubeCommand.createCube(
- new File(TestLensDatabaseCommands.class.getClassLoader().getResource("sample-cube.xml").toURI()));
+ String createOutput = cubeCommand.createCube(new File(TestLensDatabaseCommands.class.getClassLoader()
+ .getResource("schema/cubes/base/sample-cube.xml").toURI()));
assertEquals(createOutput, "succeeded");
assertTrue(cubeCommand.showCubes().contains("sample_cube"));
}
http://git-wip-us.apache.org/repos/asf/lens/blob/d9884ec6/lens-cli/src/test/java/org/apache/lens/cli/TestLensDimensionCommands.java
----------------------------------------------------------------------
diff --git a/lens-cli/src/test/java/org/apache/lens/cli/TestLensDimensionCommands.java b/lens-cli/src/test/java/org/apache/lens/cli/TestLensDimensionCommands.java
index a3f01c3..c29e842 100644
--- a/lens-cli/src/test/java/org/apache/lens/cli/TestLensDimensionCommands.java
+++ b/lens-cli/src/test/java/org/apache/lens/cli/TestLensDimensionCommands.java
@@ -71,8 +71,9 @@ public class TestLensDimensionCommands extends LensCliApplicationTest {
*/
public static void createDimension() throws URISyntaxException {
getCommand().createDimension(new File(
- TestLensCubeCommands.class.getClassLoader().getResource("test-detail.xml").toURI()));
- URL dimensionSpec = TestLensDimensionCommands.class.getClassLoader().getResource("test-dimension.xml");
+ TestLensCubeCommands.class.getClassLoader().getResource("schema/dimensions/test-detail.xml").toURI()));
+ URL dimensionSpec = TestLensDimensionCommands.class.getClassLoader()
+ .getResource("schema/dimensions/test-dimension.xml");
getCommand().createDimension(new File(dimensionSpec.toURI()));
}
@@ -85,7 +86,8 @@ public class TestLensDimensionCommands extends LensCliApplicationTest {
@Test
public void testDimensionCommands() throws Exception {
log.debug("Starting to test dimension commands");
- URL dimensionSpec = TestLensDimensionCommands.class.getClassLoader().getResource("test-dimension.xml");
+ URL dimensionSpec = TestLensDimensionCommands.class.getClassLoader()
+ .getResource("schema/dimensions/test-dimension.xml");
String dimensionList = getCommand().showDimensions();
Assert.assertFalse(dimensionList.contains("test_dim"));
createDimension();
http://git-wip-us.apache.org/repos/asf/lens/blob/d9884ec6/lens-cli/src/test/java/org/apache/lens/cli/TestLensDimensionTableCommands.java
----------------------------------------------------------------------
diff --git a/lens-cli/src/test/java/org/apache/lens/cli/TestLensDimensionTableCommands.java b/lens-cli/src/test/java/org/apache/lens/cli/TestLensDimensionTableCommands.java
index 5d6d768..20289cd 100644
--- a/lens-cli/src/test/java/org/apache/lens/cli/TestLensDimensionTableCommands.java
+++ b/lens-cli/src/test/java/org/apache/lens/cli/TestLensDimensionTableCommands.java
@@ -85,7 +85,7 @@ public class TestLensDimensionTableCommands extends LensCliApplicationTest {
@Test
public void testDimTableCommands() throws IOException, URISyntaxException {
createDimension();
- addDim1Table("dim_table2", "dim_table2.xml", DIM_LOCAL);
+ addDim1Table("dim_table2", "schema/dimtables/dim_table2.xml", DIM_LOCAL);
updateDim1Table();
testDimStorageActions();
testDimPartitionActions();
@@ -98,7 +98,8 @@ public class TestLensDimensionTableCommands extends LensCliApplicationTest {
}
private void createDimension() throws URISyntaxException {
- URL dimensionSpec = TestLensDimensionTableCommands.class.getClassLoader().getResource("test-dimension.xml");
+ URL dimensionSpec = TestLensDimensionTableCommands.class.getClassLoader()
+ .getResource("schema/dimensions/test-dimension.xml");
getDimensionCommand().createDimension(new File(dimensionSpec.toURI()));
}
@@ -153,7 +154,7 @@ public class TestLensDimensionTableCommands extends LensCliApplicationTest {
*/
private static void updateDim1Table() throws IOException {
LensDimensionTableCommands command = getCommand();
- URL dimSpec = TestLensFactCommands.class.getClassLoader().getResource("dim_table2.xml");
+ URL dimSpec = TestLensFactCommands.class.getClassLoader().getResource("schema/dimtables/dim_table2.xml");
StringBuilder sb = new StringBuilder();
BufferedReader bufferedReader = new BufferedReader(new FileReader(dimSpec.getFile()));
String s;
http://git-wip-us.apache.org/repos/asf/lens/blob/d9884ec6/lens-cli/src/test/java/org/apache/lens/cli/TestLensFactCommands.java
----------------------------------------------------------------------
diff --git a/lens-cli/src/test/java/org/apache/lens/cli/TestLensFactCommands.java b/lens-cli/src/test/java/org/apache/lens/cli/TestLensFactCommands.java
index b4cbf34..f176078 100644
--- a/lens-cli/src/test/java/org/apache/lens/cli/TestLensFactCommands.java
+++ b/lens-cli/src/test/java/org/apache/lens/cli/TestLensFactCommands.java
@@ -66,7 +66,7 @@ public class TestLensFactCommands extends LensCliApplicationTest {
}
private void createSampleCube() throws URISyntaxException {
- URL cubeSpec = TestLensCubeCommands.class.getClassLoader().getResource("sample-cube.xml");
+ URL cubeSpec = TestLensCubeCommands.class.getClassLoader().getResource("schema/cubes/base/sample-cube.xml");
String cubeList = getCubeCommand().showCubes();
assertFalse(cubeList.contains("sample_cube"), cubeList);
getCubeCommand().createCube(new File(cubeSpec.toURI()));
@@ -118,7 +118,7 @@ public class TestLensFactCommands extends LensCliApplicationTest {
assertEquals(factList, "No fact found", "Fact tables should not be found");
// add local storage before adding fact table
TestLensStorageCommands.addLocalStorage(FACT_LOCAL);
- URL factSpec = TestLensFactCommands.class.getClassLoader().getResource("fact1.xml");
+ URL factSpec = TestLensFactCommands.class.getClassLoader().getResource("schema/facts/fact1.xml");
try {
command.createFact(new File(factSpec.toURI()));
} catch (Exception e) {
@@ -147,7 +147,7 @@ public class TestLensFactCommands extends LensCliApplicationTest {
public static void updateFact1Table() {
try {
LensFactCommands command = getCommand();
- URL factSpec = TestLensFactCommands.class.getClassLoader().getResource("fact1.xml");
+ URL factSpec = TestLensFactCommands.class.getClassLoader().getResource("schema/facts/fact1.xml");
StringBuilder sb = new StringBuilder();
BufferedReader bufferedReader = new BufferedReader(new FileReader(factSpec.getFile()));
String s;
http://git-wip-us.apache.org/repos/asf/lens/blob/d9884ec6/lens-cli/src/test/java/org/apache/lens/cli/TestLensFactCommandsWithMissingWeight.java
----------------------------------------------------------------------
diff --git a/lens-cli/src/test/java/org/apache/lens/cli/TestLensFactCommandsWithMissingWeight.java b/lens-cli/src/test/java/org/apache/lens/cli/TestLensFactCommandsWithMissingWeight.java
index 24f9279..dcbb355 100644
--- a/lens-cli/src/test/java/org/apache/lens/cli/TestLensFactCommandsWithMissingWeight.java
+++ b/lens-cli/src/test/java/org/apache/lens/cli/TestLensFactCommandsWithMissingWeight.java
@@ -53,10 +53,10 @@ public class TestLensFactCommandsWithMissingWeight extends LensCliApplicationTes
public static final String FACT_NAME = "fact_without_wt";
/* The File name with cube details */
- public static final String CUBE_XML_FILE = "cube_with_no_weight_facts.xml";
+ public static final String CUBE_XML_FILE = "schema/cubes/base/cube_with_no_weight_facts.xml";
/* The File name with fact details */
- public static final String FACT_XML_FILE = "fact_without_weight.xml";
+ public static final String FACT_XML_FILE = "schema/facts/fact_without_weight.xml";
/** The command. */
private static LensFactCommands command = null;
http://git-wip-us.apache.org/repos/asf/lens/blob/d9884ec6/lens-cli/src/test/java/org/apache/lens/cli/TestLensQueryCommands.java
----------------------------------------------------------------------
diff --git a/lens-cli/src/test/java/org/apache/lens/cli/TestLensQueryCommands.java b/lens-cli/src/test/java/org/apache/lens/cli/TestLensQueryCommands.java
index e75fc0e..e1eaae5 100644
--- a/lens-cli/src/test/java/org/apache/lens/cli/TestLensQueryCommands.java
+++ b/lens-cli/src/test/java/org/apache/lens/cli/TestLensQueryCommands.java
@@ -416,10 +416,10 @@ public class TestLensQueryCommands extends LensCliApplicationTest {
command.setClient(client);
log.debug("Starting to test cube commands");
- URL cubeSpec = TestLensQueryCommands.class.getClassLoader().getResource("sample-cube.xml");
+ URL cubeSpec = TestLensQueryCommands.class.getClassLoader().getResource("schema/cubes/base/sample-cube.xml");
command.createCube(new File(cubeSpec.toURI()));
TestLensDimensionCommands.createDimension();
- TestLensDimensionTableCommands.addDim1Table("dim_table", "dim_table.xml", "local");
+ TestLensDimensionTableCommands.addDim1Table("dim_table", "schema/dimtables/dim_table.xml", "local");
// Add partition
URL dataDir = TestLensQueryCommands.class.getClassLoader().getResource("dim2-part");
http://git-wip-us.apache.org/repos/asf/lens/blob/d9884ec6/lens-cli/src/test/java/org/apache/lens/cli/TestLensSchemaCommands.java
----------------------------------------------------------------------
diff --git a/lens-cli/src/test/java/org/apache/lens/cli/TestLensSchemaCommands.java b/lens-cli/src/test/java/org/apache/lens/cli/TestLensSchemaCommands.java
new file mode 100644
index 0000000..ca6db2c
--- /dev/null
+++ b/lens-cli/src/test/java/org/apache/lens/cli/TestLensSchemaCommands.java
@@ -0,0 +1,49 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.lens.cli;
+
+import static junit.framework.Assert.assertFalse;
+import static junit.framework.Assert.assertTrue;
+
+import org.testng.annotations.Test;
+
+/**
+ * The Class TestLensStorageCommands.
+ */
+public class TestLensSchemaCommands extends LensCLITest {
+
+ @Test
+ public void testCreateSchema() throws Throwable {
+ String schemaDirectory = TestLensSchemaCommands.class.getClassLoader().getResource("schema").getFile();
+ String dbName = "schema_command_db";
+ try {
+ execute("schema --db " + dbName + " --path " + schemaDirectory, null);
+ assertTrue(((String) execute("show databases")).contains(dbName));
+ execute("show storages", "local");
+ execute("show dimensions", "test_detail\ntest_dim");
+ execute("show cubes", "sample_cube\ncube_with_no_weight_facts");
+ assertTrue(((String) execute("show dimtables")).contains("dim_table"));
+ assertTrue(((String) execute("show facts")).contains("fact1"));
+ execute("show segmentations", "seg1");
+ } finally {
+ execute("drop database --db " + dbName + " --cascade", "succeeded");
+ assertFalse(((String) execute("show databases")).contains(dbName));
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/lens/blob/d9884ec6/lens-cli/src/test/java/org/apache/lens/cli/TestLensSegmentationCommands.java
----------------------------------------------------------------------
diff --git a/lens-cli/src/test/java/org/apache/lens/cli/TestLensSegmentationCommands.java b/lens-cli/src/test/java/org/apache/lens/cli/TestLensSegmentationCommands.java
index e6d4bc5..beafd43 100644
--- a/lens-cli/src/test/java/org/apache/lens/cli/TestLensSegmentationCommands.java
+++ b/lens-cli/src/test/java/org/apache/lens/cli/TestLensSegmentationCommands.java
@@ -41,7 +41,7 @@ public class TestLensSegmentationCommands extends LensCliApplicationTest {
private static LensCubeCommands cubeCommands = null;
private void createSampleCube() throws URISyntaxException {
- URL cubeSpec = TestLensCubeCommands.class.getClassLoader().getResource("sample-cube.xml");
+ URL cubeSpec = TestLensCubeCommands.class.getClassLoader().getResource("schema/cubes/base/sample-cube.xml");
String cubeList = getCubeCommand().showCubes();
assertFalse(cubeList.contains("sample_cube"), cubeList);
getCubeCommand().createCube(new File(cubeSpec.toURI()));
@@ -72,7 +72,7 @@ public class TestLensSegmentationCommands extends LensCliApplicationTest {
String segList = command.showSegmentations(null);
assertEquals(command.showSegmentations("sample_cube"), "No segmentation found for sample_cube");
assertEquals(segList, "No segmentation found");
- URL segSpec = TestLensSegmentationCommands.class.getClassLoader().getResource("seg1.xml");
+ URL segSpec = TestLensSegmentationCommands.class.getClassLoader().getResource("schema/segmentations/seg1.xml");
try {
command.createSegmentation(new File(segSpec.toURI()));
} catch (Exception e) {
@@ -91,7 +91,7 @@ public class TestLensSegmentationCommands extends LensCliApplicationTest {
public static void testUpdateSegmentation() {
try {
LensSegmentationCommands command = getCommand();
- URL segSpec = TestLensSegmentationCommands.class.getClassLoader().getResource("seg1.xml");
+ URL segSpec = TestLensSegmentationCommands.class.getClassLoader().getResource("schema/segmentations/seg1.xml");
StringBuilder sb = new StringBuilder();
BufferedReader bufferedReader = new BufferedReader(new FileReader(segSpec.getFile()));
String s;
http://git-wip-us.apache.org/repos/asf/lens/blob/d9884ec6/lens-cli/src/test/java/org/apache/lens/cli/TestLensStorageCommands.java
----------------------------------------------------------------------
diff --git a/lens-cli/src/test/java/org/apache/lens/cli/TestLensStorageCommands.java b/lens-cli/src/test/java/org/apache/lens/cli/TestLensStorageCommands.java
index c4ab614..d320d79 100644
--- a/lens-cli/src/test/java/org/apache/lens/cli/TestLensStorageCommands.java
+++ b/lens-cli/src/test/java/org/apache/lens/cli/TestLensStorageCommands.java
@@ -92,8 +92,8 @@ public class TestLensStorageCommands extends LensCliApplicationTest {
*/
public static synchronized void addLocalStorage(String storageName) throws IOException {
LensStorageCommands command = getCommand();
- URL storageSpec = TestLensStorageCommands.class.getClassLoader().getResource("local-storage.xml");
- File newFile = new File("target/local-" + storageName + ".xml");
+ URL storageSpec = TestLensStorageCommands.class.getClassLoader().getResource("schema/storages/local-storage.xml");
+ File newFile = new File(storageSpec.getFile().replace("local-storage", "local-"+storageName));
try {
StringBuilder sb = new StringBuilder();
BufferedReader bufferedReader = new BufferedReader(new FileReader(storageSpec.getFile()));
@@ -131,7 +131,7 @@ public class TestLensStorageCommands extends LensCliApplicationTest {
private void testUpdateStorage(String storageName) throws IOException {
LensStorageCommands command = getCommand();
- URL storageSpec = TestLensStorageCommands.class.getClassLoader().getResource("local-storage.xml");
+ URL storageSpec = TestLensStorageCommands.class.getClassLoader().getResource("schema/storages/local-storage.xml");
StringBuilder sb = new StringBuilder();
BufferedReader bufferedReader = new BufferedReader(new FileReader(storageSpec.getFile()));
String s;
http://git-wip-us.apache.org/repos/asf/lens/blob/d9884ec6/lens-cli/src/test/java/org/apache/lens/cli/doc/TestGenerateCLIUserDoc.java
----------------------------------------------------------------------
diff --git a/lens-cli/src/test/java/org/apache/lens/cli/doc/TestGenerateCLIUserDoc.java b/lens-cli/src/test/java/org/apache/lens/cli/doc/TestGenerateCLIUserDoc.java
index 95e6b4e..34bb5ce 100644
--- a/lens-cli/src/test/java/org/apache/lens/cli/doc/TestGenerateCLIUserDoc.java
+++ b/lens-cli/src/test/java/org/apache/lens/cli/doc/TestGenerateCLIUserDoc.java
@@ -28,24 +28,53 @@ import org.apache.lens.cli.commands.annotations.UserDocumentation;
import org.apache.commons.lang.StringUtils;
+import org.springframework.shell.core.CommandMarker;
import org.springframework.shell.core.annotation.CliCommand;
import org.springframework.shell.core.annotation.CliOption;
import org.testng.annotations.Test;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
+import lombok.Data;
import lombok.extern.slf4j.Slf4j;
@Slf4j
public class TestGenerateCLIUserDoc {
public static final String APT_FILE = "../src/site/apt/user/cli.apt";
-
+ @Data
+ static class DocEntry {
+ private String command;
+ private String[] help;
+ private int maxLength = 0;
+ public DocEntry(String command, String help) {
+ this.command = command;
+ this.help = help.split("\r|\n");
+ for (int i = 0; i < this.help.length; i++) {
+ this.help[i] = this.help[i].replaceAll("\\|", "\\\\|");
+ if (i > 0) {
+ this.help[i] = this.help[i].replaceAll("\\ ", "\\\\ ");
+ }
+ }
+ for (String line: this.help) {
+ if (line.length() > maxLength) {
+ maxLength = line.length();
+ }
+ }
+ for (int i = 0; i < this.help.length; i++) {
+ StringBuilder sb = new StringBuilder(this.help[i]);
+ while (sb.length() < maxLength) {
+ sb.append(" ");
+ }
+ this.help[i] = sb.append("\\ ").toString();
+ }
+ }
+ }
@Test
public void generateDoc() throws IOException {
BufferedWriter bw = new BufferedWriter(new FileWriter(new File(APT_FILE)));
StringBuilder sb = new StringBuilder();
sb.append(getCLIIntroduction()).append("\n\n\n");
- List<Class<? extends BaseLensCommand>> classes = Lists.newArrayList(
+ List<Class<? extends CommandMarker>> classes = Lists.newArrayList(
LensConnectionCommands.class,
LensDatabaseCommands.class,
LensStorageCommands.class,
@@ -55,8 +84,10 @@ public class TestGenerateCLIUserDoc {
LensDimensionTableCommands.class,
LensNativeTableCommands.class,
LensQueryCommands.class,
- LensLogResourceCommands.class
+ LensLogResourceCommands.class,
+ LensSchemaCommands.class
);
+
for (Class claz : classes) {
UserDocumentation doc = (UserDocumentation) claz.getAnnotation(UserDocumentation.class);
if (doc != null && StringUtils.isNotBlank(doc.title())) {
@@ -79,13 +110,13 @@ public class TestGenerateCLIUserDoc {
log.info("Not adding " + method.getDeclaringClass().getSimpleName() + "#" + method.getName());
}
}
-
+ List<DocEntry> docEntries = Lists.newArrayList();
for (Method method : methods) {
CliCommand annot = method.getAnnotation(CliCommand.class);
- sb.append("|");
+ StringBuilder commandBuilder = new StringBuilder();
String sep = "";
for (String value : annot.value()) {
- sb.append(sep).append(value);
+ commandBuilder.append(sep).append(value);
sep = "/";
}
for (Annotation[] annotations : method.getParameterAnnotations()) {
@@ -99,32 +130,39 @@ public class TestGenerateCLIUserDoc {
keys.remove("");
}
if (!keys.isEmpty()) {
- sb.append(" ");
+ commandBuilder.append(" ");
if (!cliOption.mandatory()) {
- sb.append("[");
+ commandBuilder.append("[");
}
if (optional) {
- sb.append("[");
+ commandBuilder.append("[");
}
sep = "";
for (String key : keys) {
- sb.append(sep).append("--").append(key);
+ commandBuilder.append(sep).append("--").append(key);
sep = "/";
}
if (optional) {
- sb.append("]");
+ commandBuilder.append("]");
}
sep = "";
}
- sb.append(" ").append(cliOption.help().replaceAll("<", "\\\\<").replaceAll(">", "\\\\>"));
+ commandBuilder.append(" ").append(cliOption.help().replaceAll("<", "\\\\<").replaceAll(">", "\\\\>"));
if (!cliOption.mandatory()) {
- sb.append("]");
+ commandBuilder.append("]");
}
}
}
}
- sb.append("|").append(annot.help().replaceAll("<", "<<<").replaceAll(">", ">>>")).append("|").append("\n")
- .append("*--+--+\n");
+ docEntries.add(new DocEntry(commandBuilder.toString(),
+ annot.help().replaceAll("<", "<<<").replaceAll(">", ">>>")));
+ }
+ for (DocEntry entry: docEntries) {
+ for (int i = 0; i < entry.getHelp().length; i++) {
+ sb.append("|").append(i == 0 ? entry.getCommand() : entry.getCommand().replaceAll(".", " "))
+ .append("|").append(entry.getHelp()[i]).append("|").append("\n");
+ }
+ sb.append("*--+--+\n");
}
sb.append(" <<").append(getReadableName(claz.getSimpleName())).append(">>\n\n===\n\n");
}
http://git-wip-us.apache.org/repos/asf/lens/blob/d9884ec6/lens-cli/src/test/resources/cube_with_no_weight_facts.xml
----------------------------------------------------------------------
diff --git a/lens-cli/src/test/resources/cube_with_no_weight_facts.xml b/lens-cli/src/test/resources/cube_with_no_weight_facts.xml
deleted file mode 100644
index 4673ca4..0000000
--- a/lens-cli/src/test/resources/cube_with_no_weight_facts.xml
+++ /dev/null
@@ -1,41 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
-
--->
-<x_base_cube name="cube_with_no_weight_facts" xmlns="uri:lens:cube:0.1"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="uri:lens:cube:0.1 cube-0.1.xsd ">
- <measures>
- <measure name="measure1" _type="BIGINT" />
- <measure name="measure2" _type="INT" default_aggr="SUM" />
- <measure name="measure3" _type="FLOAT" default_aggr="MAX" start_time='2013-12-12T00:00:00' />
- <measure name="measure4" _type="DOUBLE" default_aggr="MIN" />
- </measures>
- <dim_attributes>
- <dim_attribute name="dim1" _type="INT" />
- <dim_attribute name="dim2" _type="INT" start_time='2013-12-01T00:00:00' />
- <dim_attribute name="dim3" _type="INT"/>
- </dim_attributes>
- <expressions>
- <expression name="expr_msr5" _type="DOUBLE">
- <expr_spec expr = "measure3 + measure4" end_time='2013-12-12T00:00:00'/>
- <expr_spec expr = "measure3 + measure4 + 0.01" start_time='2013-12-12T00:00:00'/>
- </expression>
- </expressions>
-</x_base_cube>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/lens/blob/d9884ec6/lens-cli/src/test/resources/dim_table.xml
----------------------------------------------------------------------
diff --git a/lens-cli/src/test/resources/dim_table.xml b/lens-cli/src/test/resources/dim_table.xml
deleted file mode 100644
index eb4ddfc..0000000
--- a/lens-cli/src/test/resources/dim_table.xml
+++ /dev/null
@@ -1,48 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
-
--->
-<x_dimension_table dimension_name="test_dim" table_name="dim_table" weight="100.0" xmlns="uri:lens:cube:0.1"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="uri:lens:cube:0.1 cube-0.1.xsd ">
- <columns>
- <column comment="ID" name="id" _type="INT"/>
- <column comment="name" name="name" _type="STRING"/>
- <column comment="more details" name="detail" _type="STRING"/>
- <column comment="d2 ID" name="d2id" _type="INT"/>
- </columns>
- <properties>
- <property name="dim1.prop" value="d1"/>
- </properties>
- <storage_tables>
- <storage_table>
- <update_periods>
- <update_period>HOURLY</update_period>
- </update_periods>
- <storage_name>local</storage_name>
- <table_desc external="true" field_delimiter=","
- table_location="${project.build.directory}/metastore/examples/local">
- <part_cols>
- <column comment="Time column" name="dt" _type="STRING"/>
- </part_cols>
- <time_part_cols>dt</time_part_cols>
- </table_desc>
- </storage_table>
- </storage_tables>
-</x_dimension_table>
http://git-wip-us.apache.org/repos/asf/lens/blob/d9884ec6/lens-cli/src/test/resources/dim_table2.xml
----------------------------------------------------------------------
diff --git a/lens-cli/src/test/resources/dim_table2.xml b/lens-cli/src/test/resources/dim_table2.xml
deleted file mode 100644
index 8440e28..0000000
--- a/lens-cli/src/test/resources/dim_table2.xml
+++ /dev/null
@@ -1,48 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
-
--->
-<x_dimension_table dimension_name="test_dim" table_name="dim_table2" weight="100.0" xmlns="uri:lens:cube:0.1"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="uri:lens:cube:0.1 cube-0.1.xsd ">
- <columns>
- <column comment="ID" name="id" _type="INT"/>
- <column comment="name" name="name" _type="STRING"/>
- <column comment="more details for dim2" name="detail2" _type="STRING"/>
- </columns>
-
- <properties>
- <property name="dim2.prop" value="d2"/>
- </properties>
- <storage_tables>
- <storage_table>
- <update_periods>
- <update_period>HOURLY</update_period>
- </update_periods>
- <storage_name>dim_local</storage_name>
- <table_desc external="true" field_delimiter=","
- table_location="${project.build.directory}/metastore/examples/dim1">
- <part_cols>
- <column comment="Time column" name="dt" _type="STRING"/>
- </part_cols>
- <time_part_cols>dt</time_part_cols>
- </table_desc>
- </storage_table>
- </storage_tables>
-</x_dimension_table>
http://git-wip-us.apache.org/repos/asf/lens/blob/d9884ec6/lens-cli/src/test/resources/fact1.xml
----------------------------------------------------------------------
diff --git a/lens-cli/src/test/resources/fact1.xml b/lens-cli/src/test/resources/fact1.xml
deleted file mode 100644
index b18a393..0000000
--- a/lens-cli/src/test/resources/fact1.xml
+++ /dev/null
@@ -1,51 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
-
--->
-<x_fact_table cube_name="sample_cube" name="fact1" weight="100.0" xmlns="uri:lens:cube:0.1"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="uri:lens:cube:0.1 cube-0.1.xsd ">
- <columns>
- <column comment="" name="dim1" _type="INT"/>
- <column comment="" name="measure1" _type="BIGINT"/>
- <column comment="" name="measure2" _type="INT"/>
- <column comment="" name="measure3" _type="FLOAT"/>
- </columns>
- <properties>
- <property name="fact1.prop" value="f1"/>
- <property name="cube.fact.is.aggregated" value="true"/>
- </properties>
- <storage_tables>
- <storage_table>
- <update_periods>
- <update_period>HOURLY</update_period>
- <update_period>DAILY</update_period>
- <update_period>MONTHLY</update_period>
- </update_periods>
- <storage_name>fact_local</storage_name>
- <table_desc external="true" field_delimiter=","
- table_location="${project.build.directory}/metastore/examples/fact1_local">
- <part_cols>
- <column comment="Time column" name="dt" _type="STRING"/>
- </part_cols>
- <time_part_cols>dt</time_part_cols>
- </table_desc>
- </storage_table>
- </storage_tables>
-</x_fact_table>
http://git-wip-us.apache.org/repos/asf/lens/blob/d9884ec6/lens-cli/src/test/resources/fact_without_weight.xml
----------------------------------------------------------------------
diff --git a/lens-cli/src/test/resources/fact_without_weight.xml b/lens-cli/src/test/resources/fact_without_weight.xml
deleted file mode 100644
index 0c124b2..0000000
--- a/lens-cli/src/test/resources/fact_without_weight.xml
+++ /dev/null
@@ -1,51 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
-
--->
-<x_fact_table cube_name="cube_with_no_weight_facts" name="fact_without_wt" xmlns="uri:lens:cube:0.1"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="uri:lens:cube:0.1 cube-0.1.xsd ">
- <columns>
- <column comment="" name="dim1" _type="INT"/>
- <column comment="" name="measure1" _type="BIGINT"/>
- <column comment="" name="measure2" _type="INT"/>
- <column comment="" name="measure3" _type="FLOAT"/>
- </columns>
- <properties>
- <property name="fact_without_wt.prop" value="f1"/>
- <property name="cube.fact.is.aggregated" value="true"/>
- </properties>
- <storage_tables>
- <storage_table>
- <update_periods>
- <update_period>HOURLY</update_period>
- <update_period>DAILY</update_period>
- <update_period>MONTHLY</update_period>
- </update_periods>
- <storage_name>fact_local_without_wt</storage_name>
- <table_desc external="true" field_delimiter=","
- table_location="${project.build.directory}/metastore/examples/fact_local_without_wt">
- <part_cols>
- <column comment="Time column" name="dt" _type="STRING"/>
- </part_cols>
- <time_part_cols>dt</time_part_cols>
- </table_desc>
- </storage_table>
- </storage_tables>
-</x_fact_table>
http://git-wip-us.apache.org/repos/asf/lens/blob/d9884ec6/lens-cli/src/test/resources/local-storage.xml
----------------------------------------------------------------------
diff --git a/lens-cli/src/test/resources/local-storage.xml b/lens-cli/src/test/resources/local-storage.xml
deleted file mode 100644
index 6551375..0000000
--- a/lens-cli/src/test/resources/local-storage.xml
+++ /dev/null
@@ -1,27 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
-
--->
-<x_storage classname="org.apache.lens.cube.metadata.HDFSStorage" name="local" xmlns="uri:lens:cube:0.1"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="uri:lens:cube:0.1 cube-0.1.xsd ">
- <properties>
- <property name="storage.url" value="file:///" />
- </properties>
-</x_storage>
http://git-wip-us.apache.org/repos/asf/lens/blob/d9884ec6/lens-cli/src/test/resources/sample-cube.xml
----------------------------------------------------------------------
diff --git a/lens-cli/src/test/resources/sample-cube.xml b/lens-cli/src/test/resources/sample-cube.xml
deleted file mode 100644
index 2d6bc34..0000000
--- a/lens-cli/src/test/resources/sample-cube.xml
+++ /dev/null
@@ -1,102 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
-
--->
-<x_base_cube name="sample_cube" xmlns="uri:lens:cube:0.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="uri:lens:cube:0.1 cube-0.1.xsd ">
- <properties>
- <property name="sample_cube.prop" value="sample" />
- <property name="cube.sample_cube.timed.dimensions.list" value="dt" />
- </properties>
- <measures>
- <measure name="measure1" _type="BIGINT" />
- <measure name="measure2" _type="INT" default_aggr="SUM" />
- <measure name="measure3" _type="FLOAT" default_aggr="MAX" start_time='2013-12-12T00:00:00' />
- <measure name="measure4" _type="DOUBLE" default_aggr="MIN" />
- <measure name="measure5" _type="BIGINT">
- <tags>
- <property name="category" value="primary"/>
- <property name="is_ui_visible" value="true"/>
- </tags>
- </measure>
- <measure name="measure6" _type="BIGINT">
- <tags>
- <property name="category" value="secondary"/>
- <property name="is_ui_visible" value="false"/>
- </tags>
- </measure>
- </measures>
- <dim_attributes>
- <dim_attribute name="dim1" _type="INT" />
- <dim_attribute name="dim2" _type="INT" start_time='2013-12-01T00:00:00' />
- <dim_attribute name="dim3" _type="INT"/>
- <dim_attribute name="dimDetail" _type="string" description="City name to which the customer belongs"
- display_string="Customer City">
- <chain_ref_column chain_name="testdimchain" ref_col="detail" />
- <chain_ref_column chain_name="testdetailchain" ref_col="name" />
- </dim_attribute>
- <dim_attribute name="dim4" _type="BIGINT">
- <tags>
- <property name="category" value="primary"/>
- <property name="is_ui_visible" value="true"/>
- </tags>
- </dim_attribute>
- </dim_attributes>
- <expressions>
- <expression name="expr_msr5" _type="DOUBLE">
- <expr_spec expr = "measure3 + measure4" end_time='2013-12-12T00:00:00'/>
- <expr_spec expr = "measure3 + measure4 + 0.01" start_time='2013-12-12T00:00:00'/>
- </expression>
- <expression name="expr_msr6" _type="DOUBLE">
- <tags>
- <property name="category" value="primary"/>
- <property name="is_ui_visible" value="true"/>
- </tags>
- <expr_spec expr = "measure3 + measure4" start_time='2013-12-12T00:00:00' />
- <expr_spec expr = "measure3 + measure4 + 0.01" end_time='2013-12-12T00:00:00'/>
- </expression>
- </expressions>
- <join_chains>
- <join_chain name="testdimchain">
- <paths>
- <path>
- <edges>
- <edge>
- <from table="sample_cube" column="dim1" />
- <to table="test_dim" column="id" />
- </edge>
- </edges>
- </path>
- </paths>
- </join_chain>
- <join_chain name="testdetailchain">
- <paths>
- <path>
- <edges>
- <edge>
- <from table="sample_cube" column="dim2" />
- <to table="test_detail" column="id" />
- </edge>
- </edges>
- </path>
- </paths>
- </join_chain>
- </join_chains>
-</x_base_cube>
http://git-wip-us.apache.org/repos/asf/lens/blob/d9884ec6/lens-cli/src/test/resources/schema/cubes/base/cube_with_no_weight_facts.xml
----------------------------------------------------------------------
diff --git a/lens-cli/src/test/resources/schema/cubes/base/cube_with_no_weight_facts.xml b/lens-cli/src/test/resources/schema/cubes/base/cube_with_no_weight_facts.xml
new file mode 100644
index 0000000..4673ca4
--- /dev/null
+++ b/lens-cli/src/test/resources/schema/cubes/base/cube_with_no_weight_facts.xml
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+
+-->
+<x_base_cube name="cube_with_no_weight_facts" xmlns="uri:lens:cube:0.1"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="uri:lens:cube:0.1 cube-0.1.xsd ">
+ <measures>
+ <measure name="measure1" _type="BIGINT" />
+ <measure name="measure2" _type="INT" default_aggr="SUM" />
+ <measure name="measure3" _type="FLOAT" default_aggr="MAX" start_time='2013-12-12T00:00:00' />
+ <measure name="measure4" _type="DOUBLE" default_aggr="MIN" />
+ </measures>
+ <dim_attributes>
+ <dim_attribute name="dim1" _type="INT" />
+ <dim_attribute name="dim2" _type="INT" start_time='2013-12-01T00:00:00' />
+ <dim_attribute name="dim3" _type="INT"/>
+ </dim_attributes>
+ <expressions>
+ <expression name="expr_msr5" _type="DOUBLE">
+ <expr_spec expr = "measure3 + measure4" end_time='2013-12-12T00:00:00'/>
+ <expr_spec expr = "measure3 + measure4 + 0.01" start_time='2013-12-12T00:00:00'/>
+ </expression>
+ </expressions>
+</x_base_cube>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/lens/blob/d9884ec6/lens-cli/src/test/resources/schema/cubes/base/sample-cube.xml
----------------------------------------------------------------------
diff --git a/lens-cli/src/test/resources/schema/cubes/base/sample-cube.xml b/lens-cli/src/test/resources/schema/cubes/base/sample-cube.xml
new file mode 100644
index 0000000..2d6bc34
--- /dev/null
+++ b/lens-cli/src/test/resources/schema/cubes/base/sample-cube.xml
@@ -0,0 +1,102 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+
+-->
+<x_base_cube name="sample_cube" xmlns="uri:lens:cube:0.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="uri:lens:cube:0.1 cube-0.1.xsd ">
+ <properties>
+ <property name="sample_cube.prop" value="sample" />
+ <property name="cube.sample_cube.timed.dimensions.list" value="dt" />
+ </properties>
+ <measures>
+ <measure name="measure1" _type="BIGINT" />
+ <measure name="measure2" _type="INT" default_aggr="SUM" />
+ <measure name="measure3" _type="FLOAT" default_aggr="MAX" start_time='2013-12-12T00:00:00' />
+ <measure name="measure4" _type="DOUBLE" default_aggr="MIN" />
+ <measure name="measure5" _type="BIGINT">
+ <tags>
+ <property name="category" value="primary"/>
+ <property name="is_ui_visible" value="true"/>
+ </tags>
+ </measure>
+ <measure name="measure6" _type="BIGINT">
+ <tags>
+ <property name="category" value="secondary"/>
+ <property name="is_ui_visible" value="false"/>
+ </tags>
+ </measure>
+ </measures>
+ <dim_attributes>
+ <dim_attribute name="dim1" _type="INT" />
+ <dim_attribute name="dim2" _type="INT" start_time='2013-12-01T00:00:00' />
+ <dim_attribute name="dim3" _type="INT"/>
+ <dim_attribute name="dimDetail" _type="string" description="City name to which the customer belongs"
+ display_string="Customer City">
+ <chain_ref_column chain_name="testdimchain" ref_col="detail" />
+ <chain_ref_column chain_name="testdetailchain" ref_col="name" />
+ </dim_attribute>
+ <dim_attribute name="dim4" _type="BIGINT">
+ <tags>
+ <property name="category" value="primary"/>
+ <property name="is_ui_visible" value="true"/>
+ </tags>
+ </dim_attribute>
+ </dim_attributes>
+ <expressions>
+ <expression name="expr_msr5" _type="DOUBLE">
+ <expr_spec expr = "measure3 + measure4" end_time='2013-12-12T00:00:00'/>
+ <expr_spec expr = "measure3 + measure4 + 0.01" start_time='2013-12-12T00:00:00'/>
+ </expression>
+ <expression name="expr_msr6" _type="DOUBLE">
+ <tags>
+ <property name="category" value="primary"/>
+ <property name="is_ui_visible" value="true"/>
+ </tags>
+ <expr_spec expr = "measure3 + measure4" start_time='2013-12-12T00:00:00' />
+ <expr_spec expr = "measure3 + measure4 + 0.01" end_time='2013-12-12T00:00:00'/>
+ </expression>
+ </expressions>
+ <join_chains>
+ <join_chain name="testdimchain">
+ <paths>
+ <path>
+ <edges>
+ <edge>
+ <from table="sample_cube" column="dim1" />
+ <to table="test_dim" column="id" />
+ </edge>
+ </edges>
+ </path>
+ </paths>
+ </join_chain>
+ <join_chain name="testdetailchain">
+ <paths>
+ <path>
+ <edges>
+ <edge>
+ <from table="sample_cube" column="dim2" />
+ <to table="test_detail" column="id" />
+ </edge>
+ </edges>
+ </path>
+ </paths>
+ </join_chain>
+ </join_chains>
+</x_base_cube>
http://git-wip-us.apache.org/repos/asf/lens/blob/d9884ec6/lens-cli/src/test/resources/schema/dimensions/test-detail.xml
----------------------------------------------------------------------
diff --git a/lens-cli/src/test/resources/schema/dimensions/test-detail.xml b/lens-cli/src/test/resources/schema/dimensions/test-detail.xml
new file mode 100644
index 0000000..b51c188
--- /dev/null
+++ b/lens-cli/src/test/resources/schema/dimensions/test-detail.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+
+-->
+<x_dimension name="test_detail" xmlns="uri:lens:cube:0.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="uri:lens:cube:0.1 cube-0.1.xsd ">
+ <attributes>
+ <dim_attribute name="id" _type="INT" />
+ <dim_attribute name="name" _type="STRING" />
+ </attributes>
+
+ <properties>
+ <property name="dimension.test_dim.timed.dimension" value="dt" />
+ </properties>
+</x_dimension>
http://git-wip-us.apache.org/repos/asf/lens/blob/d9884ec6/lens-cli/src/test/resources/schema/dimensions/test-dimension.xml
----------------------------------------------------------------------
diff --git a/lens-cli/src/test/resources/schema/dimensions/test-dimension.xml b/lens-cli/src/test/resources/schema/dimensions/test-dimension.xml
new file mode 100644
index 0000000..01de8e6
--- /dev/null
+++ b/lens-cli/src/test/resources/schema/dimensions/test-dimension.xml
@@ -0,0 +1,61 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+
+-->
+<x_dimension name="test_dim" xmlns="uri:lens:cube:0.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="uri:lens:cube:0.1 cube-0.1.xsd ">
+ <attributes>
+ <dim_attribute name="id" _type="INT" />
+ <dim_attribute name="name" _type="STRING" />
+ <dim_attribute name="detail" _type="STRING" start_time='2013-12-01T00:00:00' />
+ <dim_attribute name="d2id" _type="INT" start_time='2013-12-01T00:00:00'/>
+ <dim_attribute name="inline" _type="STRING" >
+ <values>A</values>
+ <values>B</values>
+ <values>C</values>
+ </dim_attribute>
+ <dim_attribute name="location">
+ <hierarchy>
+ <dim_attribute name="zipcode" _type="INT" />
+ <dim_attribute name="city" _type="STRING" />
+ <dim_attribute name="state" _type="STRING" />
+ </hierarchy>
+ </dim_attribute>
+ </attributes>
+
+ <join_chains>
+ <join_chain name="dim2chain">
+ <paths>
+ <path>
+ <edges>
+ <edge>
+ <from table="test_dim" column="d2id" />
+ <to table="test_detail" column="id" />
+ </edge>
+ </edges>
+ </path>
+ </paths>
+ </join_chain>
+ </join_chains>
+ <properties>
+ <property name="test_dim.prop" value="test" />
+ <property name="dimension.test_dim.timed.dimension" value="dt" />
+ </properties>
+</x_dimension>
http://git-wip-us.apache.org/repos/asf/lens/blob/d9884ec6/lens-cli/src/test/resources/schema/dimtables/dim_table.xml
----------------------------------------------------------------------
diff --git a/lens-cli/src/test/resources/schema/dimtables/dim_table.xml b/lens-cli/src/test/resources/schema/dimtables/dim_table.xml
new file mode 100644
index 0000000..eb4ddfc
--- /dev/null
+++ b/lens-cli/src/test/resources/schema/dimtables/dim_table.xml
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+
+-->
+<x_dimension_table dimension_name="test_dim" table_name="dim_table" weight="100.0" xmlns="uri:lens:cube:0.1"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="uri:lens:cube:0.1 cube-0.1.xsd ">
+ <columns>
+ <column comment="ID" name="id" _type="INT"/>
+ <column comment="name" name="name" _type="STRING"/>
+ <column comment="more details" name="detail" _type="STRING"/>
+ <column comment="d2 ID" name="d2id" _type="INT"/>
+ </columns>
+ <properties>
+ <property name="dim1.prop" value="d1"/>
+ </properties>
+ <storage_tables>
+ <storage_table>
+ <update_periods>
+ <update_period>HOURLY</update_period>
+ </update_periods>
+ <storage_name>local</storage_name>
+ <table_desc external="true" field_delimiter=","
+ table_location="${project.build.directory}/metastore/examples/local">
+ <part_cols>
+ <column comment="Time column" name="dt" _type="STRING"/>
+ </part_cols>
+ <time_part_cols>dt</time_part_cols>
+ </table_desc>
+ </storage_table>
+ </storage_tables>
+</x_dimension_table>
http://git-wip-us.apache.org/repos/asf/lens/blob/d9884ec6/lens-cli/src/test/resources/schema/dimtables/dim_table2.xml
----------------------------------------------------------------------
diff --git a/lens-cli/src/test/resources/schema/dimtables/dim_table2.xml b/lens-cli/src/test/resources/schema/dimtables/dim_table2.xml
new file mode 100644
index 0000000..8440e28
--- /dev/null
+++ b/lens-cli/src/test/resources/schema/dimtables/dim_table2.xml
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+
+-->
+<x_dimension_table dimension_name="test_dim" table_name="dim_table2" weight="100.0" xmlns="uri:lens:cube:0.1"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="uri:lens:cube:0.1 cube-0.1.xsd ">
+ <columns>
+ <column comment="ID" name="id" _type="INT"/>
+ <column comment="name" name="name" _type="STRING"/>
+ <column comment="more details for dim2" name="detail2" _type="STRING"/>
+ </columns>
+
+ <properties>
+ <property name="dim2.prop" value="d2"/>
+ </properties>
+ <storage_tables>
+ <storage_table>
+ <update_periods>
+ <update_period>HOURLY</update_period>
+ </update_periods>
+ <storage_name>dim_local</storage_name>
+ <table_desc external="true" field_delimiter=","
+ table_location="${project.build.directory}/metastore/examples/dim1">
+ <part_cols>
+ <column comment="Time column" name="dt" _type="STRING"/>
+ </part_cols>
+ <time_part_cols>dt</time_part_cols>
+ </table_desc>
+ </storage_table>
+ </storage_tables>
+</x_dimension_table>
http://git-wip-us.apache.org/repos/asf/lens/blob/d9884ec6/lens-cli/src/test/resources/schema/facts/fact1.xml
----------------------------------------------------------------------
diff --git a/lens-cli/src/test/resources/schema/facts/fact1.xml b/lens-cli/src/test/resources/schema/facts/fact1.xml
new file mode 100644
index 0000000..b18a393
--- /dev/null
+++ b/lens-cli/src/test/resources/schema/facts/fact1.xml
@@ -0,0 +1,51 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+
+-->
+<x_fact_table cube_name="sample_cube" name="fact1" weight="100.0" xmlns="uri:lens:cube:0.1"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="uri:lens:cube:0.1 cube-0.1.xsd ">
+ <columns>
+ <column comment="" name="dim1" _type="INT"/>
+ <column comment="" name="measure1" _type="BIGINT"/>
+ <column comment="" name="measure2" _type="INT"/>
+ <column comment="" name="measure3" _type="FLOAT"/>
+ </columns>
+ <properties>
+ <property name="fact1.prop" value="f1"/>
+ <property name="cube.fact.is.aggregated" value="true"/>
+ </properties>
+ <storage_tables>
+ <storage_table>
+ <update_periods>
+ <update_period>HOURLY</update_period>
+ <update_period>DAILY</update_period>
+ <update_period>MONTHLY</update_period>
+ </update_periods>
+ <storage_name>fact_local</storage_name>
+ <table_desc external="true" field_delimiter=","
+ table_location="${project.build.directory}/metastore/examples/fact1_local">
+ <part_cols>
+ <column comment="Time column" name="dt" _type="STRING"/>
+ </part_cols>
+ <time_part_cols>dt</time_part_cols>
+ </table_desc>
+ </storage_table>
+ </storage_tables>
+</x_fact_table>
http://git-wip-us.apache.org/repos/asf/lens/blob/d9884ec6/lens-cli/src/test/resources/schema/facts/fact_without_weight.xml
----------------------------------------------------------------------
diff --git a/lens-cli/src/test/resources/schema/facts/fact_without_weight.xml b/lens-cli/src/test/resources/schema/facts/fact_without_weight.xml
new file mode 100644
index 0000000..0c124b2
--- /dev/null
+++ b/lens-cli/src/test/resources/schema/facts/fact_without_weight.xml
@@ -0,0 +1,51 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+
+-->
+<x_fact_table cube_name="cube_with_no_weight_facts" name="fact_without_wt" xmlns="uri:lens:cube:0.1"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="uri:lens:cube:0.1 cube-0.1.xsd ">
+ <columns>
+ <column comment="" name="dim1" _type="INT"/>
+ <column comment="" name="measure1" _type="BIGINT"/>
+ <column comment="" name="measure2" _type="INT"/>
+ <column comment="" name="measure3" _type="FLOAT"/>
+ </columns>
+ <properties>
+ <property name="fact_without_wt.prop" value="f1"/>
+ <property name="cube.fact.is.aggregated" value="true"/>
+ </properties>
+ <storage_tables>
+ <storage_table>
+ <update_periods>
+ <update_period>HOURLY</update_period>
+ <update_period>DAILY</update_period>
+ <update_period>MONTHLY</update_period>
+ </update_periods>
+ <storage_name>fact_local_without_wt</storage_name>
+ <table_desc external="true" field_delimiter=","
+ table_location="${project.build.directory}/metastore/examples/fact_local_without_wt">
+ <part_cols>
+ <column comment="Time column" name="dt" _type="STRING"/>
+ </part_cols>
+ <time_part_cols>dt</time_part_cols>
+ </table_desc>
+ </storage_table>
+ </storage_tables>
+</x_fact_table>
http://git-wip-us.apache.org/repos/asf/lens/blob/d9884ec6/lens-cli/src/test/resources/schema/segmentations/seg1.xml
----------------------------------------------------------------------
diff --git a/lens-cli/src/test/resources/schema/segmentations/seg1.xml b/lens-cli/src/test/resources/schema/segmentations/seg1.xml
new file mode 100644
index 0000000..8a39915
--- /dev/null
+++ b/lens-cli/src/test/resources/schema/segmentations/seg1.xml
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+
+-->
+<x_segmentation cube_name="sample_cube" name="seg1" weight="100.0" xmlns="uri:lens:cube:0.1"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="uri:lens:cube:0.1 cube-0.1.xsd ">
+ <properties>
+ <property name="seg1.prop" value="s1"/>
+ <property name="cube.segmentation.relative.start.time" value="now -10days"/>
+ </properties>
+ <segements>
+ <segment cube_name="cube11">
+ <segment_parameters>
+ <property name="lens.metastore.cube.column.mapping" value="foo=bar"/>
+ </segment_parameters>
+ </segment>
+ <segment cube_name="cube22">
+ <segment_parameters>
+ <property name="lens.metastore.cube.column.mapping" value="foo1=bar1"/>
+ </segment_parameters>
+ </segment>
+ <segment cube_name="cube33">
+ <segment_parameters>
+ <property name="lens.metastore.cube.column.mapping" value="foo2=bar2"/>
+ </segment_parameters>
+ </segment>
+ </segements>
+</x_segmentation>
http://git-wip-us.apache.org/repos/asf/lens/blob/d9884ec6/lens-cli/src/test/resources/schema/storages/local-storage.xml
----------------------------------------------------------------------
diff --git a/lens-cli/src/test/resources/schema/storages/local-storage.xml b/lens-cli/src/test/resources/schema/storages/local-storage.xml
new file mode 100644
index 0000000..4dd0f0c
--- /dev/null
+++ b/lens-cli/src/test/resources/schema/storages/local-storage.xml
@@ -0,0 +1,26 @@
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+
+-->
+<x_storage classname="org.apache.lens.cube.metadata.HDFSStorage" name="local" xmlns="uri:lens:cube:0.1"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="uri:lens:cube:0.1 cube-0.1.xsd ">
+ <properties>
+ <property name="storage.url" value="file:///" />
+ </properties>
+</x_storage>
http://git-wip-us.apache.org/repos/asf/lens/blob/d9884ec6/lens-cli/src/test/resources/seg1.xml
----------------------------------------------------------------------
diff --git a/lens-cli/src/test/resources/seg1.xml b/lens-cli/src/test/resources/seg1.xml
deleted file mode 100644
index 8a39915..0000000
--- a/lens-cli/src/test/resources/seg1.xml
+++ /dev/null
@@ -1,45 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
-
--->
-<x_segmentation cube_name="sample_cube" name="seg1" weight="100.0" xmlns="uri:lens:cube:0.1"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="uri:lens:cube:0.1 cube-0.1.xsd ">
- <properties>
- <property name="seg1.prop" value="s1"/>
- <property name="cube.segmentation.relative.start.time" value="now -10days"/>
- </properties>
- <segements>
- <segment cube_name="cube11">
- <segment_parameters>
- <property name="lens.metastore.cube.column.mapping" value="foo=bar"/>
- </segment_parameters>
- </segment>
- <segment cube_name="cube22">
- <segment_parameters>
- <property name="lens.metastore.cube.column.mapping" value="foo1=bar1"/>
- </segment_parameters>
- </segment>
- <segment cube_name="cube33">
- <segment_parameters>
- <property name="lens.metastore.cube.column.mapping" value="foo2=bar2"/>
- </segment_parameters>
- </segment>
- </segements>
-</x_segmentation>
http://git-wip-us.apache.org/repos/asf/lens/blob/d9884ec6/lens-cli/src/test/resources/test-detail.xml
----------------------------------------------------------------------
diff --git a/lens-cli/src/test/resources/test-detail.xml b/lens-cli/src/test/resources/test-detail.xml
deleted file mode 100644
index b51c188..0000000
--- a/lens-cli/src/test/resources/test-detail.xml
+++ /dev/null
@@ -1,32 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
-
--->
-<x_dimension name="test_detail" xmlns="uri:lens:cube:0.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="uri:lens:cube:0.1 cube-0.1.xsd ">
- <attributes>
- <dim_attribute name="id" _type="INT" />
- <dim_attribute name="name" _type="STRING" />
- </attributes>
-
- <properties>
- <property name="dimension.test_dim.timed.dimension" value="dt" />
- </properties>
-</x_dimension>