@POST @Path("/rename") @Produces(MediaType.APPLICATION_JSON) public Space renameSpace(@QueryParam("renameTo") String renameTo) throws NamespaceException, SpaceNotFoundException { throw UserException.unsupportedError() .message("Renaming a space is not supported") .build(logger); }
private LogicalExpression doUnknown(RexNode o){ final String message = String.format(UNSUPPORTED_REX_NODE_ERROR + "RexNode Class: %s, RexNode Digest: %s", o.getClass().getName(), o.toString()); if(throwUserException) { throw UserException.planError().message(message).build(logger); } else { throw new IllegalStateException(message); } }
@Override public Void run() throws Exception { try { connection = ConnectionFactory.createConnection(config); logger.info("Connection created: {}.", connection); } catch (IOException ex) { throw UserException.dataReadError(ex).message("Failure while connecting to HBase.").build(logger); } return null; } },
@Override public boolean createOrUpdateDataset(NamespaceService userNamespaceService, NamespaceKey source, NamespaceKey datasetPath, DatasetConfig datasetConfig, NamespaceAttribute... attributes) throws NamespaceException { ManagedStoragePlugin plugin = pluginRetriever.getPlugin(source.getRoot(), true); if(plugin == null){ throw UserException.validationError().message("Unknown source %s", datasetPath.getRoot()).build(logger); } return datasets.createOrUpdateDataset(userNamespaceService, plugin, source, datasetPath, datasetConfig, attributes); }
@Override public boolean refreshSource(NamespaceKey source, MetadataPolicy metadataPolicy, UpdateType updateType) throws NamespaceException { ManagedStoragePlugin plugin = plugins.get(source.getRoot()); if(plugin == null){ throw UserException.validationError().message("Unknown source %s", source.getRoot()).build(logger); } return plugin.refresh(updateType, metadataPolicy); }
public List<DatasetSplit> getSplits() { try{ return delegate.getSplits(); }catch(Exception e){ throw UserException.dataReadError(e).message("Failure while attempting to retrieve parallelization information for table %s.", getName()).build(logger); } }
public void checkAccess(NamespaceKey key, DatasetConfig datasetConfig, final MetadataRequestOptions options) { try(AutoCloseableLock l = readLock()) { checkState(); if (!permissionsCache.hasAccess(options.getSchemaConfig().getUserName(), key, datasetConfig, options.getStatsCollector())) { throw UserException.permissionError() .message("Access denied reading dataset %s.", key) .build(logger); } } }
@Override public void validate(final OptionValue v) { super.validate(v); if (!isValid(v.getStringVal())) { throw UserException.validationError() .message(String.format("Option %s must be one of: %s.", getOptionName(), valuesSet)) .build(logger); } }
@Override public void validate(OptionValue v) { if (v.getType() != OptionType.QUERY) { throw UserException.validationError() .message("Query level options can only be set at QUERY level scope. Given scope '%s'.", v.getType()) .build(logger); } inner.validate(v); } }
private UserException getConvertFunctionInvalidTypeException(final RexCall function) { // Caused by user entering a value with a numeric type final String functionName = function.getOperator().getName(); final String typeName = function.getOperands().get(1).getType().getFullTypeString(); return UserException.parseError() .message("Invalid type %s passed as second argument to function '%s'. " + "The function expects a literal argument.", typeName, functionName) .build(logger); }
private int numTilesFromExpression(LogicalExpression numTilesExpr) { if ((numTilesExpr instanceof ValueExpressions.IntExpression)) { int nt = ((ValueExpressions.IntExpression) numTilesExpr).getInt(); if (nt > 0) { return nt; } } throw UserException.functionError().message("NTILE only accepts positive integer argument").build(logger); }
@Override public Field visitGeneric(ArrowType type) { if(field.getName().equals(column.getAsUnescapedPath())){ throw UserException.validationError().message("You're trying to flatten a field that is not a list. The offending field is %s.", Describer.describe(field)).build(logger); } return super.visitGeneric(type); }
@Override public void startPartition(WritePartition partition) { if(!partition.isSinglePartition()){ throw UserException.dataWriteError().message("Arrow writer doesn't support data partitioning.").build(logger); } }
@Override public void validate(OptionValue v) { super.validate(v); if (v.getNumVal() > max || v.getNumVal() < min) { throw UserException.validationError() .message(String.format("Option %s must be between %d and %d.", getOptionName(), min, max)) .build(logger); } } }
private static <T extends CompleteWork> void verify(final List<NodeEndpoint> endpoints, final List<T> units, final boolean condition, final String msg, Object... args) { if (!condition) { throw UserException.resourceError() .message(msg, args) .addContext("endpoints %s", endpoints) .addContext("workunits %s", units) .build(logger); } } }
public TransformRuleWrapper<ExtractRule> wrapRule(ExtractRule extractRule) { switch (extractRule.getType()) { case pattern: return new ExtractPatternTransformRuleWrapper(extractRule); case position: return new ExtractPositionTransformRuleWrapper(extractRule); default: throw UserException.unsupportedError() .message("Unexpected extract rule type: %s", extractRule.getType()) .build(logger); } }
@Override public void createDataset(NamespaceKey key, com.google.common.base.Function<DatasetConfig, DatasetConfig> datasetMutator) { ManagedStoragePlugin plugin = pluginRetriever.getPlugin(key.getRoot(), true); if(plugin == null){ throw UserException.validationError().message("Unknown source %s", key.getRoot()).build(logger); } datasets.createDataset(key, plugin, datasetMutator); }
public static void throwUnsupportedHiveDataTypeError(String unsupportedType) { throw UserException.unsupportedError() .message(ERROR_MSG, unsupportedType) .build(logger); }
private void confirmLast() throws IOException{ parser.nextToken(); if(!parser.isClosed()){ throw getExceptionWithContext( UserException.dataReadError(), currentFieldName, null) .message("Dremio attempted to unwrap a toplevel list " + "in your document. However, it appears that there is trailing content after this top level list. Dremio only " + "supports querying a set of distinct maps or a single json array with multiple inner maps.") .build(logger); } }
public SqlNode parse(String sql) { try { SqlParser parser = SqlParser.create(sql, parserConfig); return parser.parseStmt().accept(STRING_LITERAL_CONVERTER); } catch (SqlParseException e) { UserException.Builder builder = SqlExceptionHelper.parseError(sql, e); builder.message(isInnerQuery ? SqlExceptionHelper.INNER_QUERY_PARSING_ERROR : SqlExceptionHelper.QUERY_PARSING_ERROR); throw builder.build(logger); } }