public static LensException wrap(Exception e) { if (e instanceof LensException) { return (LensException) e; } return new LensException(e); }
private ResultSetMetaData getRsMetadata() throws LensException { if (resultMeta == null) { try { resultMeta = resultSet.getMetaData(); } catch (SQLException e) { throw new LensException(e); } } return resultMeta; }
String toJsonString() throws LensException { try(ByteArrayOutputStream out = new ByteArrayOutputStream()) { ObjectMapper mapper = new ObjectMapper(); mapper.writeValue(out, this); return out.toString("UTF-8"); } catch (Exception e) { throw new LensException("Error writing fact pruning messages", e); } } }
public CubeVirtualFactTable getCubeVirtualFactTable(String factName) throws LensException { FactTable factTable = getFactTable(factName); if (factTable instanceof CubeVirtualFactTable) { return (CubeVirtualFactTable) factTable; } else { throw new LensException(new LensException(LensCubeErrorCode.ENTITY_TYPE_NOT_AS_EXPECTED.getLensErrorInfo(), factName, "VirtualFact")); } }
@Override public boolean cancelQuery(QueryHandle handle) throws LensException { try { boolean cancelled = resultSetMap.get(handle).cancel(true); if (cancelled) { handleContextMap.get(handle).setDriverStatus(DriverQueryStatus.DriverQueryState.CANCELED); } return cancelled; } catch (NullPointerException e) { throw new LensException("The query does not exist or was already purged", e); } }
@Override public synchronized boolean hasNext() throws LensException { try { boolean hasMore = resultSet.next(); if (!hasMore && closeAfterFetch) { close(); } return hasMore; } catch (SQLException e) { throw new LensException(e); } }
public static TimePartition of(UpdatePeriod updatePeriod, Date date) throws LensException { if (date == null) { throw new LensException("time parition date is null"); } return new TimePartition(updatePeriod, date); }
private void validateQuery(String query) throws LensException { if (StringUtils.isBlank(query)) { throw new LensException(NULL_OR_EMPTY_OR_BLANK_QUERY.getLensErrorInfo()); } } /**
private Table refreshTable(String tableName) throws LensException { Table tbl; try { tableName = tableName.trim().toLowerCase(); tbl = getClient().getTable(tableName); allHiveTables.put(tableName, tbl); } catch (HiveException e) { throw new LensException("Could not get table: " + tableName, e); } return tbl; }
public void dropHiveTable(String table) throws LensException { try { getClient().dropTable(table); } catch (HiveException e) { throw new LensException("Couldn't drop hive table: " + table, e); } allHiveTables.remove(table.trim().toLowerCase()); }
public ReferencedDimAttribute(FieldSchema column, String displayString, List<ChainRefCol> chainRefCols, Date startTime, Date endTime, Double cost, Long numOfDistinctValues, List<String> values, Map<String, String> tags) throws LensException { super(column, displayString, startTime, endTime, cost, numOfDistinctValues, values, tags); if (chainRefCols.isEmpty()) { throw new LensException(LensCubeErrorCode.ERROR_IN_ENTITY_DEFINITION.getLensErrorInfo(), " Ref column: " + getName() + " does not have any chain_ref_column defined"); } chainRefColumns.addAll(chainRefCols); }
static Storage createInstance(Table tbl) throws LensException { String storageName = tbl.getTableName(); String storageClassName = tbl.getParameters().get(MetastoreUtil.getStorageClassKey(storageName)); try { Class<?> clazz = Class.forName(storageClassName); Constructor<?> constructor = clazz.getConstructor(Table.class); return (Storage) constructor.newInstance(tbl); } catch (Exception e) { throw new LensException("Could not create storage class" + storageClassName, e); } } }
public void validate() throws LensException { if (partitionColumn == null || fromDate == null || toDate == null || fromEqualsTo()) { throw new LensException(LensCubeErrorCode.INVALID_TIME_RANGE.getLensErrorInfo()); } if (fromAfterTo()) { throw new LensException(LensCubeErrorCode.FROM_AFTER_TO.getLensErrorInfo(), fromDate.toString(), toDate.toString()); } }
public static UpdatePeriod fromUnitName(String unitName) throws LensException { for (UpdatePeriod up : values()) { if (up.getUnitName().equals(unitName)) { return up; } } throw new LensException(LensCubeErrorCode.INVALID_TIME_UNIT.getLensErrorInfo(), unitName); }
public void validateTransition(final QueryStatus newStatus) throws LensException { if (!this.status.isValidTransition(newStatus.getStatus())) { throw new LensException("Invalid state transition:from[" + this.status.getStatus() + " to " + newStatus.getStatus() + "]"); } }
private boolean partitionExists(String storageTableName, Map<String, String> partSpec) throws LensException { try { Table storageTbl = getTable(storageTableName); Partition p = getClient().getPartition(storageTbl, partSpec, false); return (p != null && p.getTPartition() != null); } catch (HiveException e) { throw new LensException("Could not check whether table exists", e); } }
public static ASTNode parseExpr(String expr, Configuration conf) throws LensException { ASTNode tree; try { tree = parseExpression(expr, conf); } catch (ParseException|RecognitionException e) { throw new LensException(COULD_NOT_PARSE_EXPRESSION.getLensErrorInfo(), e, expr); } return ParseUtils.findRootNonNullToken(tree); } public static ASTNode parseExpression(String command, Configuration conf)
static ASTNode parseExpr(String expr) throws LensException { ParseDriver driver = new ParseDriver(); ASTNode tree; try { tree = driver.parseExpression(expr); } catch (org.apache.hadoop.hive.ql.parse.ParseException e) { throw new LensException(EXPRESSION_NOT_PARSABLE.getLensErrorInfo(), e, e.getMessage(), expr); } return ParseUtils.findRootNonNullToken(tree); }
private void extractTimeRange(CubeQueryContext cubeql) throws LensException { // get time range - // Time range should be direct child of where condition // TOK_WHERE.TOK_FUNCTION.Identifier Or, it should be right hand child of // AND condition TOK_WHERE.KW_AND.TOK_FUNCTION.Identifier if (cubeql.getWhereAST() == null || cubeql.getWhereAST().getChildCount() < 1) { throw new LensException(LensCubeErrorCode.NO_TIMERANGE_FILTER.getLensErrorInfo()); } searchTimeRanges(cubeql.getWhereAST(), cubeql, null, 0); }
private void extractTimeRange(CubeQueryContext cubeql) throws LensException { // get time range - // Time range should be direct child of where condition // TOK_WHERE.TOK_FUNCTION.Identifier Or, it should be right hand child of // AND condition TOK_WHERE.KW_AND.TOK_FUNCTION.Identifier if (cubeql.getWhereAST() == null || cubeql.getWhereAST().getChildCount() < 1) { throw new LensException(LensCubeErrorCode.NO_TIMERANGE_FILTER.getLensErrorInfo()); } searchTimeRanges(cubeql.getWhereAST(), cubeql, null, 0); }