Repository: incubator-lens Updated Branches: refs/heads/master 9b51b46f7 -> 10917c25e
http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/10917c25/lens-cli/src/main/java/org/apache/lens/cli/commands/LensNativeTableCommands.java ---------------------------------------------------------------------- diff --git a/lens-cli/src/main/java/org/apache/lens/cli/commands/LensNativeTableCommands.java b/lens-cli/src/main/java/org/apache/lens/cli/commands/LensNativeTableCommands.java index 3dc29a7..df42581 100644 --- a/lens-cli/src/main/java/org/apache/lens/cli/commands/LensNativeTableCommands.java +++ b/lens-cli/src/main/java/org/apache/lens/cli/commands/LensNativeTableCommands.java @@ -20,48 +20,65 @@ package org.apache.lens.cli.commands; import java.util.List; -import org.springframework.shell.core.CommandMarker; +import org.apache.lens.api.APIResult; +import org.apache.lens.api.metastore.XNativeTable; +import org.apache.lens.cli.commands.annotations.UserDocumentation; + import org.springframework.shell.core.annotation.CliCommand; import org.springframework.shell.core.annotation.CliOption; import org.springframework.stereotype.Component; -import com.google.common.base.Joiner; - /** * The Class LensNativeTableCommands. */ @Component -public class LensNativeTableCommands extends BaseLensCommand implements CommandMarker { +@UserDocumentation(title = "Native Table management", description = "Read operations on native tables") +public class LensNativeTableCommands extends LensCRUDCommand<XNativeTable> { /** * Show native tables. * * @return the string */ - @CliCommand(value = "show nativetables", help = "show list of native tables") + @CliCommand(value = "show nativetables", help = "show list of native tables belonging to current database") public String showNativeTables() { - List<String> nativetables = getClient().getAllNativeTables(); - if (nativetables != null) { - return Joiner.on("\n").join(nativetables); - } else { - return "No native tables found"; - } + return showAll(); } /** * Describe native table. * - * @param tblName the tbl name + * @param name the tbl name * @return the string */ - @CliCommand(value = "describe nativetable", help = "describe nativetable") + @CliCommand(value = "describe nativetable", help = "describe nativetable named <native-table-name>") public String describeNativeTable( - @CliOption(key = {"", "nativetable"}, mandatory = true, help = "<native-table-name>") String tblName) { + @CliOption(key = {"", "name"}, mandatory = true, help = "<native-table-name>") String name) { + return describe(name); + } + + @Override + public List<String> getAll() { + return getClient().getAllNativeTables(); + } + + @Override + protected APIResult doCreate(String path, boolean ignoreIfExists) { + return null; + } + + @Override + protected XNativeTable doRead(String name) { + return getClient().getNativeTable(name); + } + + @Override + public APIResult doUpdate(String name, String path) { + return null; + } - try { - return formatJson(mapper.writer(pp).writeValueAsString(getClient().getNativeTable(tblName))); - } catch (Exception e) { - throw new IllegalArgumentException(e); - } + @Override + protected APIResult doDelete(String name, boolean cascade) { + return null; } } http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/10917c25/lens-cli/src/main/java/org/apache/lens/cli/commands/LensQueryCommands.java ---------------------------------------------------------------------- diff --git a/lens-cli/src/main/java/org/apache/lens/cli/commands/LensQueryCommands.java b/lens-cli/src/main/java/org/apache/lens/cli/commands/LensQueryCommands.java index 920ba9c..c0616d2 100644 --- a/lens-cli/src/main/java/org/apache/lens/cli/commands/LensQueryCommands.java +++ b/lens-cli/src/main/java/org/apache/lens/cli/commands/LensQueryCommands.java @@ -18,15 +18,20 @@ */ package org.apache.lens.cli.commands; +import java.io.FileOutputStream; import java.io.IOException; +import java.io.OutputStreamWriter; import java.io.UnsupportedEncodingException; +import java.nio.charset.Charset; import java.util.List; import java.util.UUID; import org.apache.lens.api.query.*; +import org.apache.lens.cli.commands.annotations.UserDocumentation; import org.apache.lens.client.LensClient; -import org.springframework.shell.core.CommandMarker; +import org.apache.commons.lang.StringUtils; + import org.springframework.shell.core.annotation.CliCommand; import org.springframework.shell.core.annotation.CliOption; import org.springframework.stereotype.Component; @@ -37,32 +42,47 @@ import com.google.common.base.Joiner; * The Class LensQueryCommands. */ @Component -public class LensQueryCommands extends BaseLensCommand implements CommandMarker { +@UserDocumentation(title = "Query Management", + description = "This section provides commands for query life cycle - " + + "submit, check status,\n" + + " fetch results, kill or list all the queries. Also provides commands for\n" + + " prepare a query, destroy a prepared query and list all prepared queries.\n" + + "\n" + + " Please note that, character <<<\">>> is used as delimiter by the Spring Shell\n" + + " framework, which is used to build lens cli. So queries which require <<<\">>>,\n" + + " should be prefixed with another double quote. For example\n" + + " <<<query execute cube select id,name from dim_table where name != \"\"first\"\">>>,\n" + + " will be parsed as <<<cube select id,name from dim_table where name != \"first\">>>") +public class LensQueryCommands extends BaseLensCommand { /** * Execute query. * * @param sql the sql - * @param asynch the asynch + * @param async the asynch * @param queryName the query name * @return the string */ - @CliCommand(value = "query execute", help = "Execute query in async/sync manner") + @CliCommand(value = "query execute", + help = "Execute query <query-string>." + + + " If <async> is true, The query is launched in async manner and query handle is returned. It's by default false." + + " <query name> can also be provided, though not required") public String executeQuery( - @CliOption(key = {"", "query"}, mandatory = true, help = "Query to execute") String sql, + @CliOption(key = {"", "query"}, mandatory = true, help = "<query-string>") String sql, @CliOption(key = {"async"}, mandatory = false, unspecifiedDefaultValue = "false", - specifiedDefaultValue = "true", help = "Sync query execution") boolean asynch, - @CliOption(key = {"name"}, mandatory = false, help = "Query name") String queryName) { - if (!asynch) { + specifiedDefaultValue = "true", help = "<async>") boolean async, + @CliOption(key = {"name"}, mandatory = false, help = "<query-name>") String queryName) { + if (async) { + QueryHandle handle = getClient().executeQueryAsynch(sql, queryName); + return handle.getHandleId().toString(); + } else { try { LensClient.LensClientResultSetWithStats result = getClient().getResults(sql, queryName); return formatResultSet(result); } catch (Throwable t) { return t.getMessage(); } - } else { - QueryHandle handle = getClient().executeQueryAsynch(sql, queryName); - return handle.getHandleId().toString(); } } @@ -113,10 +133,9 @@ public class LensQueryCommands extends BaseLensCommand implements CommandMarker * @param qh the qh * @return the status */ - @CliCommand(value = "query status", help = "Fetch status of executed query") + @CliCommand(value = "query status", help = "Fetch status of executed query having query handle <query-handle>") public String getStatus( - @CliOption(key = {"", "query"}, mandatory = true, help - = "<query-handle> for which status has to be fetched") String qh) { + @CliOption(key = {"", "query-handle"}, mandatory = true, help = "<query-handle>") String qh) { QueryStatus status = getClient().getQueryStatus(new QueryHandle(UUID.fromString(qh))); StringBuilder sb = new StringBuilder(); if (status == null) { @@ -146,10 +165,10 @@ public class LensQueryCommands extends BaseLensCommand implements CommandMarker * @param qh the qh * @return the query */ - @CliCommand(value = "query details", help = "Get query details") + @CliCommand(value = "query details", help = "Get query details of query with handle <query-handle>") public String getDetails( - @CliOption(key = {"", "query"}, mandatory = true, help - = "<query-handle> for which details have to be fetched") String qh) { + @CliOption(key = {"", "query-handle"}, mandatory = true, help + = "<query-handle>") String qh) { LensQuery query = getClient().getQueryDetails(qh); if (query == null) { return "Unable to find query for " + qh; @@ -170,15 +189,23 @@ public class LensQueryCommands extends BaseLensCommand implements CommandMarker * @return the string * @throws UnsupportedEncodingException the unsupported encoding exception */ - @CliCommand(value = "query explain", help = "Explain query plan") - public String explainQuery(@CliOption(key = {"", "query"}, mandatory = true, help = "Query to execute") String sql, - @CliOption(key = {"save"}, mandatory = false, help = "query to explain") String location) - throws UnsupportedEncodingException { - + @CliCommand(value = "query explain", + help = "Explain execution plan of query <query-string>. Can optionally save the plan" + + " to a file by providing <save-location>") + public String explainQuery(@CliOption(key = {"", "query"}, mandatory = true, help = "<query-string>") String sql, + @CliOption(key = {"save-location"}, mandatory = false, help = "<save-location>") String location) + throws IOException { QueryPlan plan = getClient().getQueryPlan(sql); if (plan.isError()) { return "Explain FAILED:" + plan.getErrorMsg(); } + if (StringUtils.isNotBlank(location)) { + String validPath = getValidPath(location); + OutputStreamWriter osw = new OutputStreamWriter(new FileOutputStream(validPath), Charset.defaultCharset()); + osw.write(plan.getPlanString()); + osw.close(); + return "Saved to " + validPath; + } return plan.getPlanString(); } @@ -192,20 +219,17 @@ public class LensQueryCommands extends BaseLensCommand implements CommandMarker * @param toDate the to date * @return the all queries */ - @CliCommand(value = "query list", help = "Get all queries") + @CliCommand(value = "query list", + help = "Get all queries. Various filter options can be provided(optionally), " + + " as can be seen from the command syntax") public String getAllQueries( - @CliOption(key = {"state"}, mandatory = false, help = "Status of queries to be listed") String state, - @CliOption(key = {"name"}, mandatory = false, help = "query name") String queryName, - @CliOption(key = {"user"}, mandatory = false, help - = "user name. Use 'all' to get queries of all users") String user, + @CliOption(key = {"state"}, mandatory = false, help = "<query-status>") String state, + @CliOption(key = {"name"}, mandatory = false, help = "<query-name>") String queryName, + @CliOption(key = {"user"}, mandatory = false, help = "<user-who-submitted-query>") String user, @CliOption(key = {"fromDate"}, mandatory = false, unspecifiedDefaultValue = "-1", help - = "start time to filter queries by submission time") long fromDate, - @CliOption(key = {"toDate"}, mandatory = false, unspecifiedDefaultValue = "-1", help - = "end time to filter queries by submission time") long toDate) { - - if (toDate == -1L) { - toDate = Long.MAX_VALUE; - } + = "<submission-time-is-after>") long fromDate, + @CliOption(key = {"toDate"}, mandatory = false, unspecifiedDefaultValue = "" + Long.MAX_VALUE, help + = "<submission-time-is-before>") long toDate) { List<QueryHandle> handles = getClient().getQueries(state, queryName, user, fromDate, toDate); if (handles != null && !handles.isEmpty()) { return Joiner.on("\n").skipNulls().join(handles).concat("\n").concat("Total number of queries: " @@ -221,9 +245,9 @@ public class LensQueryCommands extends BaseLensCommand implements CommandMarker * @param qh the qh * @return the string */ - @CliCommand(value = "query kill", help = "Kill a query") + @CliCommand(value = "query kill", help = "Kill query with handle <query-handle>") public String killQuery( - @CliOption(key = {"", "query"}, mandatory = true, help = "query-handle for killing") String qh) { + @CliOption(key = {"", "query-handle"}, mandatory = true, help = "<query-handle>") String qh) { boolean status = getClient().killQuery(new QueryHandle(UUID.fromString(qh))); if (status) { return "Successfully killed " + qh; @@ -238,9 +262,9 @@ public class LensQueryCommands extends BaseLensCommand implements CommandMarker * @param qh the qh * @return the query results */ - @CliCommand(value = "query results", help = "get results of async query") + @CliCommand(value = "query results", help = "get results of async query with query handle <query-handle>") public String getQueryResults( - @CliOption(key = {"", "query"}, mandatory = true, help = "query-handle for fetching result") String qh) { + @CliOption(key = {"", "query-handle"}, mandatory = true, help = "<query-handle>") String qh) { try { LensClient.LensClientResultSetWithStats result = getClient() .getAsyncResults(new QueryHandle(UUID.fromString(qh))); @@ -259,18 +283,16 @@ public class LensQueryCommands extends BaseLensCommand implements CommandMarker * @param toDate the to date * @return the all prepared queries */ - @CliCommand(value = "prepQuery list", help = "Get all prepared queries") + @CliCommand(value = "prepQuery list", + help = "Get all prepared queries. Various filters can be provided(optionally)" + + " as can be seen from command syntax") public String getAllPreparedQueries( - @CliOption(key = {"user"}, mandatory = false, help = "user name") String userName, - @CliOption(key = {"name"}, mandatory = false, help = "query name") String queryName, + @CliOption(key = {"name"}, mandatory = false, help = "<query-name>") String queryName, + @CliOption(key = {"user"}, mandatory = false, help = "<user-who-submitted-query>") String userName, @CliOption(key = {"fromDate"}, mandatory = false, unspecifiedDefaultValue = "-1", help - = "start time to filter queries by submission time") long fromDate, - @CliOption(key = {"toDate"}, mandatory = false, unspecifiedDefaultValue = "-1", help - = "end time to filter queries by submission time") long toDate) { - - if (toDate == -1L) { - toDate = Long.MAX_VALUE; - } + = "<submission-time-is-after>") long fromDate, + @CliOption(key = {"toDate"}, mandatory = false, unspecifiedDefaultValue = "" + Long.MAX_VALUE, help + = "<submission-time-is-before>") long toDate) { List<QueryPrepareHandle> handles = getClient().getPreparedQueries(userName, queryName, fromDate, toDate); if (handles != null && !handles.isEmpty()) { return Joiner.on("\n").skipNulls().join(handles); @@ -285,22 +307,21 @@ public class LensQueryCommands extends BaseLensCommand implements CommandMarker * @param ph the ph * @return the prepared status */ - @CliCommand(value = "prepQuery details", help = "Get prepared query") + @CliCommand(value = "prepQuery details", help = "Get prepared query with handle <prepare-handle>") public String getPreparedStatus( - @CliOption(key = {"", "handle"}, mandatory = true, help = "Prepare handle") String ph) { + @CliOption(key = {"", "prepare-handle"}, mandatory = true, help = "<prepare-handle>") String ph) { LensPreparedQuery prepared = getClient().getPreparedQuery(QueryPrepareHandle.fromString(ph)); if (prepared != null) { - StringBuilder sb = new StringBuilder(); - sb.append("User query:").append(prepared.getUserQuery()).append("\n"); - sb.append("Prepare handle:").append(prepared.getPrepareHandle()).append("\n"); - sb.append("User:" + prepared.getPreparedUser()).append("\n"); - sb.append("Prepared at:").append(prepared.getPreparedTime()).append("\n"); - sb.append("Selected driver :").append(prepared.getSelectedDriverClassName()).append("\n"); - sb.append("Driver query:").append(prepared.getDriverQuery()).append("\n"); + StringBuilder sb = new StringBuilder() + .append("User query:").append(prepared.getUserQuery()).append("\n") + .append("Prepare handle:").append(prepared.getPrepareHandle()).append("\n") + .append("User:" + prepared.getPreparedUser()).append("\n") + .append("Prepared at:").append(prepared.getPreparedTime()).append("\n") + .append("Selected driver :").append(prepared.getSelectedDriverClassName()).append("\n") + .append("Driver query:").append(prepared.getDriverQuery()).append("\n"); if (prepared.getConf() != null) { sb.append("Conf:").append(prepared.getConf().getProperties()).append("\n"); } - return sb.toString(); } else { return "No such handle"; @@ -313,9 +334,9 @@ public class LensQueryCommands extends BaseLensCommand implements CommandMarker * @param ph the ph * @return the string */ - @CliCommand(value = "prepQuery destroy", help = "Destroy a prepared query") + @CliCommand(value = "prepQuery destroy", help = "Destroy prepared query with handle <prepare-handle>") public String destroyPreparedQuery( - @CliOption(key = {"", "handle"}, mandatory = true, help = "prepare handle to destroy") String ph) { + @CliOption(key = {"", "prepare-handle"}, mandatory = true, help = "<prepare-handle>") String ph) { boolean status = getClient().destroyPrepared(new QueryPrepareHandle(UUID.fromString(ph))); if (status) { return "Successfully destroyed " + ph; @@ -328,17 +349,23 @@ public class LensQueryCommands extends BaseLensCommand implements CommandMarker * Execute prepared query. * * @param phandle the phandle - * @param asynch the asynch + * @param async the asynch * @param queryName the query name * @return the string */ - @CliCommand(value = "prepQuery execute", help = "Execute prepared query in async/sync manner") + @CliCommand(value = "prepQuery execute", + help = "Execute prepared query with handle <prepare-handle>." + + " If <async> is supplied and is true, query is run in async manner and query handle is returned immediately." + + " Optionally, <query-name> can be provided, though not required.") public String executePreparedQuery( - @CliOption(key = {"", "handle"}, mandatory = true, help = "Prepare handle to execute") String phandle, + @CliOption(key = {"", "prepare-handle"}, mandatory = true, help = "Prepare handle to execute") String phandle, @CliOption(key = {"async"}, mandatory = false, unspecifiedDefaultValue = "false", - specifiedDefaultValue = "true", help = "Sync query execution") boolean asynch, - @CliOption(key = {"name"}, mandatory = false, help = "query name") String queryName) { - if (!asynch) { + specifiedDefaultValue = "true", help = "<async>") boolean async, + @CliOption(key = {"name"}, mandatory = false, help = "<query-name>") String queryName) { + if (async) { + QueryHandle handle = getClient().executePrepared(QueryPrepareHandle.fromString(phandle), queryName); + return handle.getHandleId().toString(); + } else { try { LensClient.LensClientResultSetWithStats result = getClient().getResultsFromPrepared( QueryPrepareHandle.fromString(phandle), queryName); @@ -346,9 +373,6 @@ public class LensQueryCommands extends BaseLensCommand implements CommandMarker } catch (Throwable t) { return t.getMessage(); } - } else { - QueryHandle handle = getClient().executePrepared(QueryPrepareHandle.fromString(phandle), queryName); - return handle.getHandleId().toString(); } } @@ -360,13 +384,12 @@ public class LensQueryCommands extends BaseLensCommand implements CommandMarker * @return the string * @throws UnsupportedEncodingException the unsupported encoding exception */ - @CliCommand(value = "prepQuery prepare", help = "Prepapre query") - public String prepare(@CliOption(key = {"", "query"}, mandatory = true, help = "Query to prepare") String sql, - @CliOption(key = {"name"}, mandatory = false, help = "query name") String queryName) + @CliCommand(value = "prepQuery prepare", + help = "Prepapre query <query-string> and return prepare handle. Can optionaly provide <query-name>") + public String prepare(@CliOption(key = {"", "query"}, mandatory = true, help = "<query-string>") String sql, + @CliOption(key = {"name"}, mandatory = false, help = "<query-name>") String queryName) throws UnsupportedEncodingException { - - QueryPrepareHandle handle = getClient().prepare(sql, queryName); - return handle.toString(); + return getClient().prepare(sql, queryName).toString(); } /** @@ -377,10 +400,11 @@ public class LensQueryCommands extends BaseLensCommand implements CommandMarker * @return the string * @throws UnsupportedEncodingException the unsupported encoding exception */ - @CliCommand(value = "prepQuery explain", help = "Explain and prepare query") + @CliCommand(value = "prepQuery explain", + help = "Explain and prepare query <query-string>. Can optionally provide <query-name>") public String explainAndPrepare( - @CliOption(key = {"", "query"}, mandatory = true, help = "Query to explain and prepare") String sql, - @CliOption(key = {"name"}, mandatory = false, help = "query name") String queryName) + @CliOption(key = {"", "query"}, mandatory = true, help = "<query-string>") String sql, + @CliOption(key = {"name"}, mandatory = false, help = "<query-name>") String queryName) throws UnsupportedEncodingException { QueryPlan plan = getClient().explainAndPrepare(sql, queryName); http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/10917c25/lens-cli/src/main/java/org/apache/lens/cli/commands/LensStorageCommands.java ---------------------------------------------------------------------- diff --git a/lens-cli/src/main/java/org/apache/lens/cli/commands/LensStorageCommands.java b/lens-cli/src/main/java/org/apache/lens/cli/commands/LensStorageCommands.java index d2dc6e5..928120a 100644 --- a/lens-cli/src/main/java/org/apache/lens/cli/commands/LensStorageCommands.java +++ b/lens-cli/src/main/java/org/apache/lens/cli/commands/LensStorageCommands.java @@ -18,113 +18,102 @@ */ package org.apache.lens.cli.commands; -import java.io.File; -import java.io.IOException; import java.util.List; import org.apache.lens.api.APIResult; +import org.apache.lens.api.metastore.XStorage; +import org.apache.lens.cli.commands.annotations.UserDocumentation; import org.springframework.shell.core.CommandMarker; import org.springframework.shell.core.annotation.CliCommand; import org.springframework.shell.core.annotation.CliOption; import org.springframework.stereotype.Component; -import com.google.common.base.Joiner; -import com.google.common.base.Splitter; -import com.google.common.collect.Iterables; - /** * The Class LensStorageCommands. */ @Component -public class LensStorageCommands extends BaseLensCommand implements CommandMarker { +@UserDocumentation(title = "Storage Management", description = "These commands provide CRUD for Storages") +public class LensStorageCommands extends LensCRUDCommand<XStorage> implements CommandMarker { - @CliCommand(value = "show storages", help = "list storages") + @CliCommand(value = "show storages", help = "list all storages") public String getStorages() { - List<String> storages = getClient().getAllStorages(); - if (storages == null || storages.isEmpty()) { - return "No storages found"; - } - return Joiner.on("\n").join(storages); + return showAll(); } /** * Creates the storage. * - * @param storageSpec the storage spec + * @param path the storage spec path * @return the string */ - @CliCommand(value = "create storage", help = "Create a new Storage") + @CliCommand(value = "create storage", help = "Create a new Storage from file <path-to-storage-spec>") public String createStorage( - @CliOption(key = {"", "storage"}, mandatory = true, help = "<path to storage-spec>") String storageSpec) { - File f = new File(storageSpec); - if (!f.exists()) { - return "storage spec path" + f.getAbsolutePath() + " does not exist. Please check the path"; - } - APIResult result = getClient().createStorage(storageSpec); - return result.getMessage(); + @CliOption(key = {"", "path"}, mandatory = true, help = "<path-to-storage-spec>") String path) { + return create(path, false); } /** * Drop storage. * - * @param storage the storage + * @param name the storage name * @return the string */ - @CliCommand(value = "drop storage", help = "drop storage") + @CliCommand(value = "drop storage", help = "drop storage <storage-name>") public String dropStorage( - @CliOption(key = {"", "storage"}, mandatory = true, help = "storage name to be dropped") String storage) { - APIResult result = getClient().dropStorage(storage); - if (result.getStatus() == APIResult.Status.SUCCEEDED) { - return "Successfully dropped " + storage + "!!!"; - } else { - return "Dropping storage failed"; - } + @CliOption(key = {"", "name"}, mandatory = true, help = "<storage-name>") String name) { + return drop(name, false); } /** * Update storage. * - * @param specPair the spec pair + * @param name the storage name + * @param path the new storage spec path * @return the string */ - @CliCommand(value = "update storage", help = "update storage") + @CliCommand(value = "update storage", + help = "update storage <storage-name> with storage spec from <path-to-storage-spec>") public String updateStorage( - @CliOption(key = {"", "storage"}, mandatory = true, help - = "<storage-name> <path to storage-spec>") String specPair) { - Iterable<String> parts = Splitter.on(' ').trimResults().omitEmptyStrings().split(specPair); - String[] pair = Iterables.toArray(parts, String.class); - if (pair.length != 2) { - return "Syntax error, please try in following " + "format. update storage <storage-name> <storage spec path>"; - } - - File f = new File(pair[1]); - - if (!f.exists()) { - return "Storage spec path" + f.getAbsolutePath() + " does not exist. Please check the path"; - } - - APIResult result = getClient().updateStorage(pair[0], pair[1]); - if (result.getStatus() == APIResult.Status.SUCCEEDED) { - return "Update of " + pair[0] + " succeeded"; - } else { - return "Update of " + pair[0] + " failed"; - } + @CliOption(key = {"", "name"}, mandatory = true, help = "<storage-name>") String name, + @CliOption(key = {"", "path"}, mandatory = true, help = "<path-to-storage-spec>") String path) { + return update(name, path); } /** * Describe storage. * - * @param storage the storage + * @param name the storage name * @return the string */ - @CliCommand(value = "describe storage", help = "describe storage schema") + @CliCommand(value = "describe storage", help = "describe storage <storage-name>") public String describeStorage( - @CliOption(key = {"", "storage"}, mandatory = true, help = "<storage-name> to be described") String storage) { - try { - return formatJson(mapper.writer(pp).writeValueAsString(getClient().getStorage(storage))); - } catch (IOException e) { - throw new IllegalArgumentException(e); - } + @CliOption(key = {"", "name"}, mandatory = true, help = "<storage-name>") String name) { + return describe(name); + } + + @Override + public List<String> getAll() { + return getClient().getAllStorages(); + } + + @Override + protected APIResult doCreate(String path, boolean ignoreIfExists) { + return getClient().createStorage(path); + } + + @Override + protected XStorage doRead(String name) { + return getClient().getStorage(name); + } + + @Override + public APIResult doUpdate(String name, String path) { + return getClient().updateStorage(name, path); + } + + @Override + protected APIResult doDelete(String name, boolean cascade) { + return getClient().dropStorage(name); } } http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/10917c25/lens-cli/src/main/java/org/apache/lens/cli/commands/annotations/UserDocumentation.java ---------------------------------------------------------------------- diff --git a/lens-cli/src/main/java/org/apache/lens/cli/commands/annotations/UserDocumentation.java b/lens-cli/src/main/java/org/apache/lens/cli/commands/annotations/UserDocumentation.java new file mode 100644 index 0000000..d33915a --- /dev/null +++ b/lens-cli/src/main/java/org/apache/lens/cli/commands/annotations/UserDocumentation.java @@ -0,0 +1,29 @@ +/** + * 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.annotations; + +import java.lang.annotation.*; + +@Target({ElementType.TYPE}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +public @interface UserDocumentation { + String title() default ""; + String description() default ""; +} http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/10917c25/lens-cli/src/main/resources/META-INF/spring/spring-shell-plugin.xml ---------------------------------------------------------------------- diff --git a/lens-cli/src/main/resources/META-INF/spring/spring-shell-plugin.xml b/lens-cli/src/main/resources/META-INF/spring/spring-shell-plugin.xml index 24a35fd..5ee10ba 100644 --- a/lens-cli/src/main/resources/META-INF/spring/spring-shell-plugin.xml +++ b/lens-cli/src/main/resources/META-INF/spring/spring-shell-plugin.xml @@ -20,43 +20,43 @@ --> <beans xmlns="http://www.springframework.org/schema/beans" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xmlns:context="http://www.springframework.org/schema/context" - xsi:schemaLocation=" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns:context="http://www.springframework.org/schema/context" + xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd"> <context:component-scan base-package="org.apache.lens.cli"/> <bean id="lensConnectionCommands" - class="org.apache.lens.cli.commands.LensConnectionCommands"> + class="org.apache.lens.cli.commands.LensConnectionCommands"> </bean> <bean id="lensDatabaseCommands" - class="org.apache.lens.cli.commands.LensDatabaseCommands"> + class="org.apache.lens.cli.commands.LensDatabaseCommands"> </bean> <bean id="lensCubeCommands" - class="org.apache.lens.cli.commands.LensCubeCommands"> + class="org.apache.lens.cli.commands.LensCubeCommands"> </bean> <bean id="lensDimensionCommands" - class="org.apache.lens.cli.commands.LensDimensionCommands"> + class="org.apache.lens.cli.commands.LensDimensionCommands"> </bean> <bean id="lensFactCommands" - class="org.apache.lens.cli.commands.LensFactCommands"> + class="org.apache.lens.cli.commands.LensFactCommands"> </bean> <bean id="lensStorageCommands" - class="org.apache.lens.cli.commands.LensStorageCommands"> + class="org.apache.lens.cli.commands.LensStorageCommands"> </bean> <bean id="lensQueryCommands" - class="org.apache.lens.cli.commands.LensQueryCommands"> + class="org.apache.lens.cli.commands.LensQueryCommands"> </bean> <bean id="lensDimensionTableCommands" - class="org.apache.lens.cli.commands.LensDimensionTableCommands"> + class="org.apache.lens.cli.commands.LensDimensionTableCommands"> </bean> <bean id="lensNativeTableCommands" - class="org.apache.lens.cli.commands.LensNativeTableCommands"> + class="org.apache.lens.cli.commands.LensNativeTableCommands"> </bean> </beans> http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/10917c25/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 8334317..ae39a2a 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 @@ -54,13 +54,13 @@ public class TestLensCubeCommands extends LensCliApplicationTest { Assert.assertFalse(cubeList.contains("sample_cube")); command.createCube(new File(cubeSpec.toURI()).getAbsolutePath()); cubeList = command.showCubes(); - Assert.assertEquals(command.getLatest("sample_cube dt"), "No Data Available"); + Assert.assertEquals(command.getLatest("sample_cube", "dt"), "No Data Available"); Assert.assertTrue(cubeList.contains("sample_cube")); testUpdateCommand(new File(cubeSpec.toURI()), command); command.dropCube("sample_cube"); try { - command.getLatest("sample_cube dt"); + command.getLatest("sample_cube", "dt"); Assert.fail("should have failed as cube doesn't exist"); } catch (Exception e) { //pass @@ -107,7 +107,7 @@ public class TestLensCubeCommands extends LensCliApplicationTest { Assert.assertTrue(desc.contains(propString)); - command.updateCube("sample_cube /tmp/sample_cube1.xml"); + command.updateCube("sample_cube", "/tmp/sample_cube1.xml"); desc = command.describeCube("sample_cube"); LOG.debug(desc); Assert.assertTrue(desc.contains(propString)); http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/10917c25/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 cabe3a5..f8958c4 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 @@ -59,7 +59,7 @@ public class TestLensDatabaseCommands extends LensCliApplicationTest { Assert.assertEquals("Successfully switched to default", result); result = command.dropDatabase(myDatabase); - Assert.assertEquals("drop database my_db successful", result); + Assert.assertEquals(result, "succeeded"); } } http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/10917c25/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 aa289d3..5df3486 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 @@ -119,7 +119,7 @@ public class TestLensDimensionCommands extends LensCliApplicationTest { String propString1 = "name : test_dim.prop1 value : test1"; Assert.assertTrue(desc.contains(propString)); - command.updateDimension("test_dim /tmp/test_dim1.xml"); + command.updateDimension("test_dim", "/tmp/test_dim1.xml"); desc = command.describeDimension("test_dim"); LOG.debug(desc); Assert.assertTrue(desc.contains(propString)); http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/10917c25/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 3cbeed1..a98f183 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 @@ -106,7 +106,8 @@ public class TestLensDimensionTableCommands extends LensCliApplicationTest { throws IOException { LensDimensionTableCommands command = getCommand(); String dimList = command.showDimensionTables(null); - Assert.assertEquals(command.showDimensionTables("test_dim"), dimList); + Assert.assertEquals(dimList, "No dimensiontable found"); + Assert.assertEquals(command.showDimensionTables("test_dim"), "No dimensiontable found for test_dim"); // add local storage before adding fact table TestLensStorageCommands.addLocalStorage(storageName); @@ -171,7 +172,7 @@ public class TestLensDimensionTableCommands extends LensCliApplicationTest { String propString2 = "name : dim2.prop1 value : d2"; Assert.assertTrue(desc.contains(propString)); - command.updateDimensionTable("dim_table2 /tmp/local-dim1.xml"); + command.updateDimensionTable("dim_table2", "/tmp/local-dim1.xml"); desc = command.describeDimensionTable("dim_table2"); LOG.debug(desc); Assert.assertTrue(desc.contains(propString1)); @@ -193,13 +194,13 @@ public class TestLensDimensionTableCommands extends LensCliApplicationTest { Assert.assertEquals(DIM_LOCAL, result); command.dropAllDimStorages("dim_table2"); result = command.getDimStorages("dim_table2"); - Assert.assertEquals("No storages found for dim_table2", result); + Assert.assertEquals(result, "No storage found for dim_table2"); addLocalStorageToDim(); result = command.getDimStorages("dim_table2"); - Assert.assertNotEquals("No storages found for dim_table2", result); - command.dropStorageFromDim("dim_table2 " + DIM_LOCAL); + Assert.assertNotEquals(result, "No storage found for dim_table2"); + command.dropStorageFromDim("dim_table2", DIM_LOCAL); result = command.getDimStorages("dim_table2"); - Assert.assertEquals("No storages found for dim_table2", result); + Assert.assertEquals(result, "No storage found for dim_table2"); addLocalStorageToDim(); } @@ -212,11 +213,11 @@ public class TestLensDimensionTableCommands extends LensCliApplicationTest { LensDimensionTableCommands command = getCommand(); String result; URL resource = TestLensDimensionTableCommands.class.getClassLoader().getResource("dim-local-storage-element.xml"); - command.addNewDimStorage("dim_table2 " + new File(resource.toURI()).getAbsolutePath()); + command.addNewDimStorage("dim_table2", new File(resource.toURI()).getAbsolutePath()); result = command.getDimStorages("dim_table2"); Assert.assertEquals(DIM_LOCAL, result); - result = command.getStorageFromDim("dim_table2 " + DIM_LOCAL); + result = command.getStorageFromDim("dim_table2", DIM_LOCAL); String partString = "DAILY"; Assert.assertTrue(result.contains(partString)); } @@ -227,10 +228,10 @@ public class TestLensDimensionTableCommands extends LensCliApplicationTest { private static void testDimPartitionActions() { LensDimensionTableCommands command = getCommand(); String result; - result = command.getAllPartitionsOfDim("dim_table2 " + DIM_LOCAL); + result = command.getAllPartitionsOfDim("dim_table2", DIM_LOCAL, null); Assert.assertTrue(result.trim().isEmpty()); try { - command.addPartitionToDimTable("dim_table2" + " " + DIM_LOCAL + " " + new File( + command.addPartitionToDimtable("dim_table2", DIM_LOCAL, new File( TestLensFactCommands.class.getClassLoader().getResource("dim1-local-part.xml").toURI()).getAbsolutePath()); } catch (Throwable t) { t.printStackTrace(); @@ -238,7 +239,7 @@ public class TestLensDimensionTableCommands extends LensCliApplicationTest { } verifyAndDeletePartition(); try { - command.addPartitionsToDimTable("dim_table2" + " " + DIM_LOCAL + " " + new File( + command.addPartitionsToDimtable("dim_table2", DIM_LOCAL, new File( TestLensFactCommands.class.getClassLoader().getResource("dim1-local-parts.xml").toURI()).getAbsolutePath()); } catch (Throwable t) { t.printStackTrace(); @@ -248,24 +249,42 @@ public class TestLensDimensionTableCommands extends LensCliApplicationTest { } private static void verifyAndDeletePartition() { - String result = command.getAllPartitionsOfDim("dim_table2 " + DIM_LOCAL); + String result = command.getAllPartitionsOfDim("dim_table2", DIM_LOCAL, null); String partString = "DAILY"; Assert.assertTrue(result.contains(partString)); - command.dropAllPartitionsOfDim("dim_table2 " + DIM_LOCAL); - result = command.getAllPartitionsOfDim("dim_table2 " + DIM_LOCAL); + command.dropAllPartitionsOfDim("dim_table2", DIM_LOCAL, null); + result = command.getAllPartitionsOfDim("dim_table2", DIM_LOCAL, null); Assert.assertTrue(result.trim().isEmpty()); } /** + * Adds the partition to storage. + * + * @param tableName the table name + * @param storageName the storage name + * @param localPartSpec the local part spec + */ + public static void addPartitionToStorage(String tableName, String storageName, String localPartSpec) { + LensDimensionTableCommands command = getCommand(); + URL resource = TestLensFactCommands.class.getClassLoader().getResource(localPartSpec); + try { + command.addPartitionToDimtable(tableName, storageName, new File(resource.toURI()).getAbsolutePath()); + } catch (Throwable t) { + t.printStackTrace(); + Assert.fail("Unable to locate the storage part file for adding new storage to dim table dim_table2"); + } + } + + /** * Drop dim1 table. */ public static void dropDim1Table() { LensDimensionTableCommands command = getCommand(); String dimList = command.showDimensionTables(null); - Assert.assertEquals("dim_table2", dimList, "dim_table table should be found"); + Assert.assertEquals("dim_table2", dimList, "dim table should be found"); command.dropDimensionTable("dim_table2", false); dimList = command.showDimensionTables(null); - Assert.assertEquals("No Dimensions Found", dimList, "Dim tables should not be found"); + Assert.assertEquals(dimList, "No dimensiontable found", "Dim tables should not be found"); TestLensStorageCommands.dropStorage(DIM_LOCAL); } } http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/10917c25/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 02f5ac7..195bd43 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 @@ -67,7 +67,7 @@ public class TestLensFactCommands extends LensCliApplicationTest { private void createSampleCube() throws URISyntaxException { URL cubeSpec = TestLensCubeCommands.class.getClassLoader().getResource("sample-cube.xml"); String cubeList = getCubeCommand().showCubes(); - Assert.assertFalse(cubeList.contains("sample_cube")); + Assert.assertFalse(cubeList.contains("sample_cube"), cubeList); getCubeCommand().createCube(new File(cubeSpec.toURI()).getAbsolutePath()); } @@ -101,8 +101,8 @@ public class TestLensFactCommands extends LensCliApplicationTest { public static void addFact1Table() throws IOException { LensFactCommands command = getCommand(); String factList = command.showFacts(null); - Assert.assertEquals(command.showFacts("sample_cube"), factList); - Assert.assertEquals("No Facts Found", factList, "Fact tables should not be found"); + Assert.assertEquals(command.showFacts("sample_cube"), "No fact found for sample_cube"); + Assert.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"); @@ -161,7 +161,7 @@ public class TestLensFactCommands extends LensCliApplicationTest { Assert.assertTrue(desc.contains(propString)); - command.updateFactTable("fact1 /tmp/local-fact1.xml"); + command.updateFactTable("fact1", "/tmp/local-fact1.xml"); desc = command.describeFactTable("fact1"); LOG.debug(desc); Assert.assertTrue(desc.contains(propString), "The sample property value is not set"); @@ -186,11 +186,13 @@ public class TestLensFactCommands extends LensCliApplicationTest { Assert.assertEquals(FACT_LOCAL, result); command.dropAllFactStorages("fact1"); result = command.getFactStorages("fact1"); - Assert.assertEquals("No storages found for fact1", result); + Assert.assertEquals(result, "No storage found for fact1"); addLocalStorageToFact1(); - command.dropStorageFromFact("fact1 " + FACT_LOCAL); result = command.getFactStorages("fact1"); - Assert.assertEquals("No storages found for fact1", result); + Assert.assertNotEquals(result, "No storage found for fact1"); + command.dropStorageFromFact("fact1", FACT_LOCAL); + result = command.getFactStorages("fact1"); + Assert.assertEquals(result, "No storage found for fact1"); addLocalStorageToFact1(); } @@ -202,7 +204,7 @@ public class TestLensFactCommands extends LensCliApplicationTest { String result; URL resource = TestLensFactCommands.class.getClassLoader().getResource("fact-local-storage-element.xml"); try { - command.addNewFactStorage("fact1 " + new File(resource.toURI()).getAbsolutePath()); + command.addNewFactStorage("fact1", new File(resource.toURI()).getAbsolutePath()); } catch (Throwable t) { t.printStackTrace(); Assert.fail("Unable to locate the storage part file for adding new storage to fact table fact1"); @@ -210,7 +212,7 @@ public class TestLensFactCommands extends LensCliApplicationTest { result = command.getFactStorages("fact1"); Assert.assertEquals(FACT_LOCAL, result); - result = command.getStorageFromFact("fact1 " + FACT_LOCAL); + result = command.getStorageFromFact("fact1", FACT_LOCAL); Assert.assertTrue(result.contains("HOURLY")); Assert.assertTrue(result.contains("DAILY")); @@ -222,10 +224,10 @@ public class TestLensFactCommands extends LensCliApplicationTest { private void testFactPartitionActions() { LensFactCommands command = getCommand(); String result; - result = command.getAllPartitionsOfFact("fact1 " + FACT_LOCAL); + result = command.getAllPartitionsOfFact("fact1", FACT_LOCAL, null); Assert.assertTrue(result.trim().isEmpty()); try { - command.addPartitionToFact("fact1 " + FACT_LOCAL + " " + new File( + command.addPartitionToFact("fact1", FACT_LOCAL, new File( TestLensFactCommands.class.getClassLoader().getResource("fact1-local-part.xml").toURI()).getAbsolutePath()); } catch (Throwable t) { t.printStackTrace(); @@ -233,7 +235,7 @@ public class TestLensFactCommands extends LensCliApplicationTest { } verifyAndDeletePartitions(); try { - command.addPartitionsToFact("fact1 " + FACT_LOCAL + " " + new File( + command.addPartitionsToFact("fact1", FACT_LOCAL, new File( TestLensFactCommands.class.getClassLoader().getResource("fact1-local-parts.xml").toURI()).getAbsolutePath()); } catch (Throwable t) { t.printStackTrace(); @@ -243,14 +245,14 @@ public class TestLensFactCommands extends LensCliApplicationTest { // Wrong files: try { - command.addPartitionToFact("fact1 " + FACT_LOCAL + " " + new File( + command.addPartitionToFact("fact1", FACT_LOCAL, new File( TestLensFactCommands.class.getClassLoader().getResource("fact1-local-parts.xml").toURI()).getAbsolutePath()); Assert.fail("Should fail"); } catch (Throwable t) { // pass } try { - command.addPartitionsToFact("fact1 " + FACT_LOCAL + " " + new File( + command.addPartitionsToFact("fact1", FACT_LOCAL, new File( TestLensFactCommands.class.getClassLoader().getResource("fact1-local-part.xml").toURI()).getAbsolutePath()); Assert.fail("Should fail"); } catch (Throwable t) { @@ -259,12 +261,12 @@ public class TestLensFactCommands extends LensCliApplicationTest { } private void verifyAndDeletePartitions() { - Assert.assertEquals(getCubeCommand().getLatest("sample_cube dt"), "2014-03-27T12:00:00:000"); - String result = command.getAllPartitionsOfFact("fact1 " + FACT_LOCAL); + Assert.assertEquals(getCubeCommand().getLatest("sample_cube", "dt"), "2014-03-27T12:00:00:000"); + String result = command.getAllPartitionsOfFact("fact1", FACT_LOCAL, null); Assert.assertTrue(result.contains("HOURLY")); - String dropPartitionsStatus = command.dropAllPartitionsOfFact("fact1 " + FACT_LOCAL); + String dropPartitionsStatus = command.dropAllPartitionsOfFact("fact1", FACT_LOCAL, null); Assert.assertFalse(dropPartitionsStatus.contains("Syntax error, please try in following")); - result = command.getAllPartitionsOfFact("fact1 " + FACT_LOCAL); + result = command.getAllPartitionsOfFact("fact1", FACT_LOCAL, null); Assert.assertTrue(result.trim().isEmpty()); } @@ -277,7 +279,7 @@ public class TestLensFactCommands extends LensCliApplicationTest { Assert.assertEquals("fact1", factList, "Fact1 table should be found"); command.dropFact("fact1", false); factList = command.showFacts(null); - Assert.assertEquals("No Facts Found", factList, "Fact tables should not be found"); + Assert.assertEquals(factList, "No fact found", "Fact tables should not be found"); TestLensStorageCommands.dropStorage(FACT_LOCAL); } } http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/10917c25/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 a48734a..d7b6372 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 @@ -112,11 +112,11 @@ public class TestLensQueryCommands extends LensCliApplicationTest { private void testPreparedQuery(LensQueryCommands qCom) throws Exception { long submitTime = System.currentTimeMillis(); String sql = "cube select id, name from test_dim"; - String result = qCom.getAllPreparedQueries("all", "testPreparedName", submitTime, Long.MAX_VALUE); + String result = qCom.getAllPreparedQueries("testPreparedName", "all", submitTime, Long.MAX_VALUE); Assert.assertEquals(result, "No prepared queries"); final String qh = qCom.prepare(sql, "testPreparedName"); - result = qCom.getAllPreparedQueries("all", "testPreparedName", submitTime, System.currentTimeMillis()); + result = qCom.getAllPreparedQueries("testPreparedName", "all", submitTime, System.currentTimeMillis()); Assert.assertEquals(qh, result); result = qCom.getPreparedStatus(qh); @@ -145,16 +145,16 @@ public class TestLensQueryCommands extends LensCliApplicationTest { LOG.debug("destroy result is " + result); Assert.assertEquals("Successfully destroyed " + qh, result); - result = qCom.getAllPreparedQueries("all", "testPreparedName", submitTime, Long.MAX_VALUE); + result = qCom.getAllPreparedQueries("testPreparedName", "all", submitTime, Long.MAX_VALUE); Assert.assertEquals(result, "No prepared queries"); final String qh2 = qCom.explainAndPrepare(sql, "testPrepQuery3"); Assert.assertTrue(qh2.contains(explainPlan)); - String handles = qCom.getAllPreparedQueries("all", "testPrepQuery3", -1, Long.MAX_VALUE); + String handles = qCom.getAllPreparedQueries("testPrepQuery3", "all", -1, Long.MAX_VALUE); Assert.assertFalse(handles.contains("No prepared queries"), handles); - String handles2 = qCom.getAllPreparedQueries("all", "testPrepQuery3", -1, submitTime - 1); + String handles2 = qCom.getAllPreparedQueries("testPrepQuery3", "all", -1, submitTime - 1); Assert.assertFalse(handles2.contains(qh), handles2); result = qCom.destroyPreparedQuery(handles); Assert.assertEquals("Successfully destroyed " + handles, result); http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/10917c25/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 9772849..3a04ec6 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 @@ -152,7 +152,7 @@ public class TestLensStorageCommands extends LensCliApplicationTest { String propString = "name : storage.url value : file:///"; Assert.assertTrue(desc.contains(propString)); - String updateResult = command.updateStorage(storageName + " " + updateFilePath); + String updateResult = command.updateStorage(storageName, updateFilePath); Assert.assertTrue(updateResult.contains("succeeded")); desc = command.describeStorage(storageName); LOG.debug(desc); http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/10917c25/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 new file mode 100644 index 0000000..5086907 --- /dev/null +++ b/lens-cli/src/test/java/org/apache/lens/cli/doc/TestGenerateCLIUserDoc.java @@ -0,0 +1,126 @@ +/** + * 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.doc; + +import java.io.*; +import java.lang.annotation.Annotation; +import java.lang.reflect.Method; +import java.util.HashSet; + +import org.apache.lens.cli.commands.*; +import org.apache.lens.cli.commands.annotations.UserDocumentation; + +import org.apache.commons.lang.StringUtils; + +import org.springframework.shell.core.annotation.CliCommand; +import org.springframework.shell.core.annotation.CliOption; +import org.testng.annotations.Test; + +import com.google.common.collect.Sets; + +public class TestGenerateCLIUserDoc { + public static final String APT_FILE = "../src/site/apt/user/cli.apt"; + + @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"); + Class[] classes = + new Class[]{LensConnectionCommands.class, LensDatabaseCommands.class, LensStorageCommands.class, + LensCubeCommands.class, LensDimensionCommands.class, LensFactCommands.class, LensDimensionTableCommands.class, + LensNativeTableCommands.class, LensQueryCommands.class, }; + for (Class claz : classes) { + UserDocumentation doc = (UserDocumentation) claz.getAnnotation(UserDocumentation.class); + if (doc != null && StringUtils.isNotBlank(doc.title())) { + sb.append("** ").append(doc.title()).append("\n\n ").append(doc.description()).append("\n\n"); + } + sb.append("*--+--+\n" + + "|<<Command>>|<<Description>>|\n" + + "*--+--+\n"); + for (Method method : claz.getMethods()) { + CliCommand annot = method.getAnnotation(CliCommand.class); + if (annot == null) { + continue; + } + sb.append("|"); + String sep = ""; + for (String value : annot.value()) { + sb.append(sep).append(value); + sep = "/"; + } + for (Annotation[] annotations : method.getParameterAnnotations()) { + for (Annotation paramAnnot : annotations) { + if (paramAnnot instanceof CliOption) { + CliOption cliOption = (CliOption) paramAnnot; + HashSet<String> keys = Sets.newHashSet(cliOption.key()); + boolean optional = false; + if (keys.contains("")) { + optional = true; + keys.remove(""); + } + if (!keys.isEmpty()) { + sb.append(" "); + if (!cliOption.mandatory()) { + sb.append("["); + } + if (optional) { + sb.append("["); + } + sep = ""; + for (String key : keys) { + sb.append(sep).append("--").append(key); + sep = "/"; + } + if (optional) { + sb.append("]"); + } + sep = ""; + } + sb.append(" ").append(cliOption.help().replaceAll("<", "\\\\<").replaceAll(">", "\\\\>")); + if (!cliOption.mandatory()) { + sb.append("]"); + } + } + } + } + sb.append("|").append(annot.help().replaceAll("<", "<<<").replaceAll(">", ">>>")).append("|").append("\n") + .append("*--+--+\n"); + } + sb.append(" <<").append(getReadableName(claz.getSimpleName())).append(">>\n\n===\n\n"); + } + bw.write(sb.toString()); + bw.close(); + } + + private StringBuilder getCLIIntroduction() throws IOException { + BufferedReader br = + new BufferedReader(new InputStreamReader(TestGenerateCLIUserDoc.class.getResourceAsStream("/cli-intro.apt"))); + StringBuilder sb = new StringBuilder(); + String line; + while((line = br.readLine()) != null) { + sb.append(line).append("\n"); + } + return sb; + } + + private String getReadableName(String simpleName) { + return simpleName.replaceAll("\\.class", "").replaceAll("[A-Z]", " $0").trim(); + } +} http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/10917c25/lens-cli/src/test/resources/cli-intro.apt ---------------------------------------------------------------------- diff --git a/lens-cli/src/test/resources/cli-intro.apt b/lens-cli/src/test/resources/cli-intro.apt new file mode 100644 index 0000000..b5773ab --- /dev/null +++ b/lens-cli/src/test/resources/cli-intro.apt @@ -0,0 +1,78 @@ +~~ +~~ 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. +~~ + +User CLI Commands + + Lens provides CLI on a shell. This document provides various commands available + in lens CLI. All the commands documented below can be seen by typing <<help>> + from the CLI shell. + +%{toc} + + +* Understanding this document + + Given below are a bunch of available commands in lens cli along with the argumets they expect and the way + they expect those arguments. This section will give a brief introduction on how to interpret the help of + commands given below. Arguments to commands can be passed in the following ways: + +** Passing Keyword arguments + + In this, all the arguments are passed with arg name and arg value. example: + + <<<command --arg1 value1 --arg2 value2 --arg3 value3 >>> + +** Passing list arguments + + In this, arguments are passed without arg names. Directly values will be passed: + + <<<command value1 value2 value3>>> + + +** Mixing list and keyword arguments + + <<<base command --arg1 value1 [--arg2] value2 [[--arg3] value3] [--arg4 value4] >>> + + The <<<[]>>> notation means <<<optional>>>. So argument <<<arg1>>> has to be passed as keyword argument, <<<arg2>>> + can be passed either with or without <<<--arg2>>>. arg3 can be omitted, passed without <<<--arg3>>> or passed + with <<<arg3>>>. arg4 can be omitted, or if passed, it has to be passed with <<<--arg4>>>. + + +========================= + + +* LENS Commands + + +** Argument Passing in LENS + + Lens supports both the approaches of passing arguments but advises the usage of keyword arguments over list arguments. + Mixing is not generally supported. Keyword args are always supported. In places where all the arguments + have arg name optional, list arguments are supported. So to re-iterate, list arguments are supported if + + + * All args are either like <<<arg2>>> or <<<arg3>>> in the previous section. + + * Arguments are of any type, but there is only one argument of type arg2 or arg3 and that's the argument you intend + to pass value to. + +** Known bugs + + * If all arguments have same value, Something weird will happen. + http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/10917c25/src/site/apt/user/cli.apt ---------------------------------------------------------------------- diff --git a/src/site/apt/user/cli.apt b/src/site/apt/user/cli.apt index a928425..cbbc3eb 100644 --- a/src/site/apt/user/cli.apt +++ b/src/site/apt/user/cli.apt @@ -25,152 +25,267 @@ User CLI Commands %{toc} -* Session management - Opening the lens CLI shell is equivalent to open a session with lens server. This - section provides all the commands available for in shell which are applicable for the full session. - +* Understanding this document + + Given below are a bunch of available commands in lens cli along with the argumets they expect and the way + they expect those arguments. This section will give a brief introduction on how to interpret the help of + commands given below. Arguments to commands can be passed in the following ways: + +** Passing Keyword arguments + + In this, all the arguments are passed with arg name and arg value. example: + + <<<command --arg1 value1 --arg2 value2 --arg3 value3 >>> + +** Passing list arguments + + In this, arguments are passed without arg names. Directly values will be passed: + + <<<command value1 value2 value3>>> + + +** Mixing list and keyword arguments + + <<<base command --arg1 value1 [--arg2] value2 [[--arg3] value3] [--arg4 value4] >>> + + The <<<[]>>> notation means <<<optional>>>. So argument <<<arg1>>> has to be passed as keyword argument, <<<arg2>>> + can be passed either with or without <<<--arg2>>>. arg3 can be omitted, passed without <<<--arg3>>> or passed + with <<<arg3>>>. arg4 can be omitted, or if passed, it has to be passed with <<<--arg4>>>. + + +========================= + + +* LENS Commands + + +** Argument Passing in LENS + + Lens supports both the approaches of passing arguments but advises the usage of keyword arguments over list arguments. + Mixing is not generally supported. Keyword args are always supported. In places where all the arguments + have arg name optional, list arguments are supported. So to re-iterate, list arguments are supported if + + + * All args are either like <<<arg2>>> or <<<arg3>>> in the previous section. + + * Arguments are of any type, but there is only one argument of type arg2 or arg3 and that's the argument you intend + to pass value to. + +** Known bugs + + * If all arguments have same value, Something weird will happen. + + + + +** Session management + + Opening the lens CLI shell is equivalent to open a session with lens server.This section provides all the commands available for in shell which are applicable for the full session. + *--+--+ |<<Command>>|<<Description>>| *--+--+ -| set <name>=<value> | Assign <<value>> to session parameter specified with <<name>> on lens server| +|set \<key\>=\<value\>|Assign <<<value>>> to session parameter specified with <<<key>>> on lens server| *--+--+ -| get <name>| Fetches and prints session parameter specified with name <<name>> from lens server| +|get [--key] \<key\>|Fetches and prints session parameter specified with name <<<key>>> from lens server| *--+--+ -| show params| Fetches and prints all session parameter from lens server| +|show params|Fetches and prints all session parameter from lens server| *--+--+ -| add jar <path to jar file>| Adds jar resource to the session| +|add jar [--path] \<path-to-jar-on-server-side\>|Adds jar resource to the session| *--+--+ -| add file <path to file>| Adds the file resource to the session| +|remove jar [--path] \<path-to-jar-on-server-side\>|Removes a jar resource from session| *--+--+ -| remove jar <path to file> | removes jar resource from the session| +|add file [--path] \<path-to-file-on-server-side\>|Adds a file resource to session| *--+--+ -| remove file <path to file> | remove the file resource from the session| +|remove file [--path] \<path-to-file-on-server-side\>|removes a file resource from session| *--+--+ -| list resources \[type\] | list resources from the session for a given resource type.\ | -| | Lists all resources if resource type is not mentioned. <<type>> of resource can be either <<jar>> or <<file>>.\ | -| | <<help:>> type <<list resources -->> for getting available options in the command| +|list resources [[--type] \<resource-type\>]|list all resources from session. If type is provided, lists resources of type <<<resource-type>>>. Valid values for type are jar and file.| *--+--+ -| close| Closes the session on the lens server and exits the shell. It is mandatory to call close to release all the resource of the session| +|close/bye|Releases all resources of the server session and exits the shell| *--+--+ - <<Lens Session Management Command list>> - -=== + <<Lens Connection Commands>> + +=== -* OLAP Data cube metadata management +** Database management commands - These commands provide CRUD for storages, cubes, facts, dimensions and partitions. + These commands provide CRUD for databases *--+--+ |<<Command>>|<<Description>>| *--+--+ -| show database | prints a list of databases on lens server| +|show databases|displays list of all databases| *--+--+ -| use <database-name>| Sets the session database to database specified by <database-name>| +|use [--db] \<database-name\>|change to new database| *--+--+ -| create database <database-name>| creates a database specified by <database-name>| +|create database [--db] \<database-name\> [--ignoreIfExists \<ignore-if-exists\>]|create a database with specified name. if <<<ignore-if-exists>>> is true, create will not be tried if already exists. Default is false| *--+--+ -| drop database <database-name> | drops the database specified by <database-name>| +|drop database [--db] \<database-name\>|drop a database with specified name| *--+--+ - <<Lens Database Management Command list>> - + <<Lens Database Commands>> + === - + +** Storage Management + + These commands provide CRUD for Storages + *--+--+ |<<Command>>|<<Description>>| *--+--+ -| show storage| print all the storages present in the current database| +|show storages|list all storages| *--+--+ -| create storage <storage-spec>| Creates a new storage specified in <storage-spec> file| +|create storage [--path] \<path-to-storage-spec\>|Create a new Storage from file <<<path-to-storage-spec>>>| *--+--+ -| update storage <storage-table> <storage-spec>| Updates storage <storage-table> as specified in the <storage-spec> file| +|drop storage [--name] \<storage-name\>|drop storage <<<storage-name>>>| *--+--+ -| drop storage <storage-table> | drops storage table <dimension-table> | +|update storage [--name] \<storage-name\> [--path] \<path-to-storage-spec\>|update storage <<<storage-name>>> with storage spec from <<<path-to-storage-spec>>>| *--+--+ -| describe storage <storage-table> | Prints the Schema and properties of Storage table <storage-table> | +|describe storage [--name] \<storage-name\>|describe storage <<<storage-name>>>| *--+--+ - <<Lens Storage Management List>> - + <<Lens Storage Commands>> + === - + +** OLAP Data cube metadata management + + These commands provide CRUD for cubes + *--+--+ |<<Command>>|<<Description>>| *--+--+ -| show cubes| Displays list of cubes| +|show cubes|show list of cubes in current database| +*--+--+ +|create cube [--path] \<path-to-cube-spec-file\>|Create a new Cube, taking spec from <<<path-to-cube-spec-file>>>| *--+--+ -| create cube <path to cube-spec.xml>| Creates a cube specified in <cube-spec.xml>| +|describe cube [--name] \<cube-name\>|describe cube with name <<<cube-name>>>| *--+--+ -| drop cube <cube-name>| Drops a cube specified by the name| +|update cube [--name] \<cube-name\> [--path] \<path-to-cube-spec-file\>|update cube <<<cube-name>>> with spec from <<<path-to-cube-spec-file>>>| *--+--+ -| update cube <cube-name> <cube-spec>| updates the cube with <cube-name> to cube specification specified in <cube-spec> file| +|drop cube [--name] \<cube-name\>|drop cube <<<cube-name>>>| *--+--+ -| describe cube <cube-name> | Print the schema of the cube| +|cube latestdate [--cube] \<cube-name\> [--timeDimension] \<time-dimension-name\>|get latest date of data available in cube <<<cube-name>>> for time dimension <<<time-dimension-name>>>| *--+--+ - <<Cube Management Command list>> - + <<Lens Cube Commands>> + +=== + +** Dimension Management + + These commands provide CRUD for Dimensions + +*--+--+ +|<<Command>>|<<Description>>| +*--+--+ +|show dimensions|show list of all dimensions in current database| +*--+--+ +|create dimension [--path] \<path-to-dimension-spec file\>|Create a new Dimension, taking spec from <<<path-to-dimension-spec file>>>| +*--+--+ +|describe dimension [--name] \<dimension-name\>|describe dimension <<<dimension-name>>>| +*--+--+ +|update dimension [--name] \<dimension-name\> [--path] \<path-to-dimension-spec-file\>|update dimension <<<dimension-name>>>, taking spec from <<<path-to-dimension-spec file>>>| +*--+--+ +|drop dimension [--name] \<dimension-name\>|drop dimension <<<dimension-name>>>| +*--+--+ + <<Lens Dimension Commands>> + === - + +** Management of Facts + + These command provide CRUD for facts, associated storages, and fact partitions + *--+--+ |<<Command>>|<<Description>>| *--+--+ -| show dimensions| print all the dimension tables present in the current database| +|show facts [[--cube-name] \<cube-name\>]|display list of fact tables in current database. If optional <<<cube-name>>> is supplied, only facts belonging to cube <<<cube-name>>> will be displayed| +*--+--+ +|create fact [--path] \<path-to-fact-spec-file\>|create a fact table with spec from <<<path-to-fact-spec-file>>>| *--+--+ -| create dimension <dimension-spec> <storage-spec>| Creates a new dimesion table with specification specified in <dimension-spec> file and storage specified in <storage-spec> file| +|describe fact [--fact-name] \<fact-name\>|describe fact <<<fact-name>>>| *--+--+ -| update dimension <dimension-table> <dimension-spec>| Updates dimension table <dimension-table> as specified in the <dimension-spec> file| +|update fact [--fact-name] \<fact-name\> [--path] \<path-to-fact-spec\>|update fact <<<fact-name>>> taking spec from <<<path-to-fact-spec>>>| *--+--+ -| drop dimension <dimension-table> | drops dimension table <dimension-table> | +|drop fact [--fact-name] \<fact-name\> [--cascade \<cascade\>]|drops fact <<<fact-name>>>. If <<<cascade>>> is true, all the storage tables associated with the fact <<<fact-name>>> are also dropped. By default <<<cascade>>> is false| *--+--+ -| describe dimension <dimension-table> | Prints the Schema and property of Dimension table <dimension-table> | +|fact list storage [--fact-name] \<fact-name\>|display list of storages associated to fact <<<fact-name>>>| *--+--+ -| dim list storage <dimension-table> | Prints list of storages associated to a particular <dimension-table> | +|fact add storage [--fact-name] \<fact-name\> [--path] \<path-to-storage-spec\>|adds a new storage to fact <<<fact-name>>>, taking storage spec from <<<path-to-storage-spec>>>| *--+--+ -| dim add storage <dimension-table> <storage-spec>| Adds a storage specified in <storage-spec>file to <dimension-table> | +|fact get storage [--fact-name] \<fact-name\> [--storage-name] \<path-to-storage-spec\>|describe storage <<<storage-name>>> of fact <<<fact-name>>>| *--+--+ -| dim drop storage <dimension-table> <storage-name>| Drops <storage-name> specified in <dimension-table> | +|fact drop storage [--fact-name] \<fact-name\> [--storage-name] \<storage-name\>|drop storage <<<storage-name>>> from fact <<<fact-name>>>| *--+--+ -| dim get storage <dimension-table> <storage-name>| Prints schema of the <storage-name> in <dimension-table>| +|fact drop all storages [--fact-name] \<fact-name\>|drop all storages associated to fact <<<fact-name>>>| *--+--+ -| dim list partitions <dimension-table> <storage-name> | Prints list of partitions from <storage-name> in <dimension-table>| +|fact list partitions [--fact-name] \<fact-name\> [--storage] \<storage-name\> [[--filter] \<partition-filter\>]|get all partitions associated with fact <<<fact-name>>>, storage <<<storage-name>>> filtered by <<<partition-filter>>>| *--+--+ -| dim drop partitions <dimension-table> <storage-name> | drops all partitions from <storage-name> in <dimension-table>| +|fact drop partitions [--fact-name] \<fact-name\> [--storage] \<storage-name\> [[--filter] \<partition-filter\>]|drop all partitions associated with fact <<<fact-name>>>, storage <<<storage-name>>> filtered by <<<partition-filter>>>| *--+--+ -| dim add partition <dimension-table> <storage-name> <part-spec> | Add a partition specified in <part-spec> file to <storage-name> in <dimension-table>| +|fact add single-partition [--fact-name] \<fact-name\> [--storage] \<storage-name\> [--path] \<partition-spec-path\>|add single partition to fact <<<fact-name>>>'s storage <<<storage-name>>>, reading spec from <<<partition-spec-path>>>| *--+--+ - <<Lens Dimension Table Management Command list>> - +|fact add partitions [--fact-name] \<fact-name\> [--storage] \<storage-name\> [--path] \<partition-list-spec-path\>|add multiple partition to fact <<<fact-name>>>'s storage <<<storage-name>>>, reading partition list spec from <<<partition-list-spec-path>>>| +*--+--+ + <<Lens Fact Commands>> + === - + +** Commands for Dimension Tables + + These commands provide CRUD for dimension tables, associated storages, and fact partitions + *--+--+ |<<Command>>|<<Description>>| *--+--+ -| show facts| print all the fact tables present in the current database| +|show dimtables [[--dimension-name] \<dimension-name\>]|display list of dimtables in current database. If optional <<<dimension-name>>> is supplied, only facts belonging to dimension <<<dimension-name>>> will be displayed| +*--+--+ +|create dimtable [--path] \<path-to-dimtable-spec-file\>|Create a new dimension table taking spec from <<<path-to-dimtable-spec-file>>>| +*--+--+ +|describe dimtable [--dimtable-name] \<dimtable-name\>|describe dimtable <<<dimtable-name>>>| *--+--+ -| create fact <fact-spec> <storage-spec>| Creates a new fact table with specification specified in <fact-spec> file and storage specified in <storage-spec> file| +|update dimtable [--dimtable-name] \<dimtable-name\> [--path] \<path-to-dimtable-spec\>|update dimtable <<<dimtable-name>>> taking spec from <<<path-to-dimtable-spec>>>| *--+--+ -| update fact <fact-table> <fact-spec>| Updates fact table <fact-table> as specified in the <fact-spec> file| +|drop dimtable [--dimtable-name] \<dimtable-name\> [--cascade \<cascade\>]|drop dimtable <<<dimtable-name>>>. If <<<cascade>>> is true, all the storage tables associated with the dimtable <<<dimtable-name>>> are also dropped. By default <<<cascade>>> is false| *--+--+ -| drop fact <fact-table> | drops fact table <fact-table> | +|dimtable list storages [--dimtable-name] \<dimtable-name\>|display list of storage associated to dimtable <<<dimtable-name>>>| *--+--+ -| describe fact <fact-table> | Prints the Schema and property of fact table <fact-table> | +|dimtable add storage [--dimtable-name] \<dimtable-name\> [--path] \<path-to-storage-spec\>|adds a new storage to dimtable <<<dimtable-name>>>, taking storage spec from <<<path-to-storage-spec>>>| *--+--+ -| fact list storage <fact-table> | Prints list of storages associated to a particular <fact-table> | +|dimtable get storage [--dimtable-name] \<dimtable-name\> [--storage-name] \<storage-name\>|describe storage <<<storage-name>>> of dimtable <<<dimtable-name>>>| *--+--+ -| fact add storage <fact-table> <storage-spec>| Adds a storage specified in <storage-spec>file to <fact-table> | +|dimtable drop storage [--dimtable-name] \<dimtable-name\> [--storage-name] \<storage-name\>|drop storage <<<storage-name>>> from dimtable <<<dimtable-name>>>| *--+--+ -| fact drop storage <fact-table> <storage-name>| Drops <storage-name> specified in <fact-table> | +|dimtable drop all storages [--dimtable-name] \<dimtable-name\>|drop all storages associated to dimension table| *--+--+ -| fact get storage <fact-table> <storage-name>| Prints schema of the <storage-name> in <fact-table>| +|dimtable list partitions [--dimtable-name] \<dimtable-name\> [--storage-name] \<storage-name\> [[--filter] \<partition-filter\>]|get all partitions associated with dimtable <<<dimtable-name>>>, storage <<<storage-name>>> filtered by <<<partition-filter>>>| *--+--+ -| fact list partitions <fact-table> <storage-name> | Prints list of partitions from <storage-name> in <fact-table>| +|dimtable drop partitions [--dimtable-name] \<dimtable-name\> [--storage-name] \<storage-name\> [[--filter] \<partition-filter\>]|drop all partitions associated with dimtable <<<dimtable-name>>>, storage <<<storage-name>>> filtered by <<<partition-filter>>>| *--+--+ -| fact drop partitions <fact-table> <storage-name> | drops all partitions from <storage-name> in <fact-table>| +|dimtable add single-partition [--dimtable-name] \<dimtable-name\> [--storage-name] \<storage-name\> [--path] \<partition-spec-path\>|add single partition to dimtable <<<dimtable-name>>>'s storage <<<storage-name>>>, reading spec from <<<partition-spec-path>>>| *--+--+ -| fact add partition <fact-table> <storage-name> <part-spec> | Add a partition specified in <part-spec> file to <storage-name> in <fact-table>| +|dimtable add partitions [--dimtable-name] \<dimtable-name\> [--storage-name] \<storage-name\> [--path] \<partition-list-spec-path\>|add multiple partition to dimtable <<<dimtable-name>>>'s storage <<<storage-name>>>, reading partition list spec from <<<partition-list-spec-path>>>| *--+--+ - <<Lens Fact table Management list>> + <<Lens Dimension Table Commands>> -* Query Management +=== + +** Native Table management + + Read operations on native tables + +*--+--+ +|<<Command>>|<<Description>>| +*--+--+ +|describe nativetable [--name] \<native-table-name\>|describe nativetable named <<<native-table-name>>>| +*--+--+ +|show nativetables|show list of native tables belonging to current database| +*--+--+ + <<Lens Native Table Commands>> + +=== + +** Query Management This section provides commands for query life cycle - submit, check status, fetch results, kill or list all the queries. Also provides commands for @@ -181,35 +296,37 @@ User CLI Commands should be prefixed with another double quote. For example <<<query execute cube select id,name from dim_table where name != ""first"">>>, will be parsed as <<<cube select id,name from dim_table where name != "first">>> - + *--+--+ |<<Command>>|<<Description>>| *--+--+ -| query execute <sql-text> [async] | Executes Query specified in <sql-text> in synchronous manner unless <async> flag is passed. If <async> flag is passed then query handle is printed which can be used for query management| +|prepQuery prepare [--query] \<query-string\> [--name \<query-name\>]|Prepapre query <<<query-string>>> and return prepare handle. Can optionaly provide <<<query-name>>>| +*--+--+ +|query status [--query-handle] \<query-handle\>|Fetch status of executed query having query handle <<<query-handle>>>| *--+--+ -| query status <query-handle> | Prints the Status of query mentioned in Query Handle| +|query execute [--query] \<query-string\> [--async \<async\>] [--name \<query-name\>]|Execute query <<<query-string>>>. If <<<async>>> is true, The query is launched in async manner and query handle is returned. It's by default false. <<<query name>>> can also be provided, though not required| *--+--+ -| query explain <sql-text> | Prints query execution plan of <sql-text>| +|query details [--query-handle] \<query-handle\>|Get query details of query with handle <<<query-handle>>>| *--+--+ -| query list | Prints list of queries| +|query explain [--query] \<query-string\> [--save-location \<save-location\>]|Explain execution plan of query <<<query-string>>>. Can optionally save the plan to a file by providing <<<save-location>>>| *--+--+ -| query kill <query-handle> | Kill the execution of query specified by <query-handle>| +|query list [--state \<query-status\>] [--name \<query-name\>] [--user \<user-who-submitted-query\>] [--fromDate \<submission-time-is-after\>] [--toDate \<submission-time-is-before\>]|Get all queries. Various filter options can be provided(optionally), as can be seen from the command syntax| *--+--+ -| query results <query-handle> | Prints the result of Async query specified by <query-handle>| +|query kill [--query-handle] \<query-handle\>|Kill query with handle <<<query-handle>>>| *--+--+ -| prepQuery prepare <sql-text> | Prepares the query and gives a prepare handle| +|query results [--query-handle] \<query-handle\>|get results of async query with query handle <<<query-handle>>>| *--+--+ -| prepQuery explain <sql-text> | Explains and Prepares the query. Prints the query and a prepare handle| +|prepQuery list [--name \<query-name\>] [--user \<user-who-submitted-query\>] [--fromDate \<submission-time-is-after\>] [--toDate \<submission-time-is-before\>]|Get all prepared queries. Various filters can be provided(optionally) as can be seen from command syntax| *--+--+ -| prepQuery list | Prints list of prepared queries| +|prepQuery details [--prepare-handle] \<prepare-handle\>|Get prepared query with handle <<<prepare-handle>>>| *--+--+ -| prepQuery details <prepare-handle> | Prints details of the prepared query| +|prepQuery destroy [--prepare-handle] \<prepare-handle\>|Destroy prepared query with handle <<<prepare-handle>>>| *--+--+ -| prepQuery execute <prepare-handle> [async] | Submits the prepared query for execution. If <async> flag is passed then query handle is printed which can be used for query management. Otherwise, results will be shown on the CLI| +|prepQuery execute [--prepare-handle] Prepare handle to execute [--async \<async\>] [--name \<query-name\>]|Execute prepared query with handle <<<prepare-handle>>>. If <<<async>>> is supplied and is true, query is run in async manner and query handle is returned immediately. Optionally, <<<query-name>>> can be provided, though not required.| *--+--+ -| prepQuery destroy <prepare-handle> | Destroys the prepared query| +|prepQuery explain [--query] \<query-string\> [--name \<query-name\>]|Explain and prepare query <<<query-string>>>. Can optionally provide <<<query-name>>>| *--+--+ - <<Lens Query management Command>> + <<Lens Query Commands>> === http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/10917c25/tools/scripts/generate-site-public.sh ---------------------------------------------------------------------- diff --git a/tools/scripts/generate-site-public.sh b/tools/scripts/generate-site-public.sh index 8c67952..2afd653 100755 --- a/tools/scripts/generate-site-public.sh +++ b/tools/scripts/generate-site-public.sh @@ -42,7 +42,7 @@ VERSION=$(mvn org.apache.maven.plugins:maven-help-plugin:2.1.1:evaluate -Dexpres echo "Starting generate-site" CURR_BRANCH=`git branch | sed -n '/\* /s///p'` echo "Running site in current lens branch" $CURR_BRANCH -mvn clean test -Dtest=TestGenerateConfigDoc || die "Unable to generate config docs" +mvn clean test -Dtest=org.apache.lens.doc.TestGenerateConfigDoc,org.apache.lens.cli.doc.TestGenerateCLIUserDoc || die "Unable to generate config docs" mvn install -DskipTests mvn site site:stage -Ddependency.locations.enabled=false -Ddependency.details.enabled=false || die "unable to generate site"
