예제 #1
0
 /**
  * Explain and prepare.
  *
  * @param sql the sql
  * @param queryName the query name
  * @return the string
  * @throws UnsupportedEncodingException the unsupported encoding exception
  * @throws LensAPIException
  */
 @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-string>")
         String sql,
     @CliOption(
             key = {"name"},
             mandatory = false,
             help = "<query-name>")
         String queryName)
     throws UnsupportedEncodingException, LensAPIException {
   PrettyPrintable cliOutput;
   try {
     QueryPlan plan = getClient().explainAndPrepare(sql, queryName).getData();
     return plan.getPlanString() + "\n" + "Prepare handle:" + plan.getPrepareHandle();
   } catch (final LensAPIException e) {
     BriefError briefError = new BriefError(e.getLensAPIErrorCode(), e.getLensAPIErrorMessage());
     cliOutput =
         new IdBriefErrorTemplate(
             IdBriefErrorTemplateKey.REQUEST_ID, e.getLensAPIRequestId(), briefError);
   } catch (final LensBriefErrorException e) {
     cliOutput = e.getIdBriefErrorTemplate();
   }
   return cliOutput.toPrettyString();
 }