private static void removeFoldersOnPathFromOprhanSet(NamespaceKey dsKey, Set<NamespaceKey> existingFolderSet) { NamespaceKey key = dsKey; while(key.hasParent()) { // a folder always has a parent key = key.getParent(); existingFolderSet.remove(key); } }
@Override public Collection<Function> getFunctions(NamespaceKey path) { NamespaceKey resolved = resolveSingle(path); if( resolved != null ) { if(containerExists(resolved.getParent())) { List<Function> functions = new ArrayList<>(); Collection<Function> resolvedFunctions = getFunctionsInternal(resolved); functions.addAll(resolvedFunctions); return functions; } } List<Function> functions = new ArrayList<>(); if(containerExists(path.getParent())) { functions.addAll(getFunctionsInternal(path)); } return functions; }
/** * Helper method that returns the list of the namespace entities on the given path. Except the last entity on the path * all other entities should return a non-null value. * * @param entityPath * @return */ protected List<NameSpaceContainer> getEntitiesOnPath(NamespaceKey entityPath) throws NamespaceException { final List<byte[]> keys = Lists.newArrayListWithExpectedSize(entityPath.getPathComponents().size()); NamespaceKey currentPath = entityPath; for (int i = 0; i < entityPath.getPathComponents().size(); i++) { keys.add(new NamespaceInternalKey(currentPath, keyNormalization).getKey()); if (currentPath.hasParent()) { currentPath = currentPath.getParent(); } } // reverse the keys so that the order of keys is from root to leaf level entity. Collections.reverse(keys); final List<NameSpaceContainer> entitiesOnPath = namespace.get(keys); for (int i = 0; i < entitiesOnPath.size() - 1; i++) { if (entitiesOnPath.get(i) == null) { throw new NamespaceNotFoundException(entityPath, "one or more elements on the path are not found in namespace"); } } return entitiesOnPath; }
@Override public boolean createOrUpdateView(NamespaceKey key, View view, SchemaConfig schemaConfig) throws IOException { if(!getMutability().hasMutationCapability(MutationType.VIEW, schemaConfig.isSystemUser())) { throw UserException.parseError() .message("Unable to create view. Schema [%s] is immutable for this user.", key.getParent()) .build(logger); } Path viewPath = getViewPath(key.getPathComponents()); FileSystemWrapper fs = getFS(schemaConfig.getUserName()); boolean replaced = fs.exists(viewPath); final FsPermission viewPerms = new FsPermission(schemaConfig.getOption(ExecConstants.NEW_VIEW_DEFAULT_PERMS_KEY).getStringVal()); try (OutputStream stream = FileSystemWrapper.create(fs, viewPath, viewPerms)) { lpPersistance.getMapper().writeValue(stream, view); } return replaced; }
ColumnsTable.Column c = new ColumnsTable.Column("dremio", path.getParent().toUnescapedString(), path.getLeaf(), field); if(column == null || column.equals(field.getName())){ DescribeResult r = new DescribeResult(field.getName(), c.DATA_TYPE);
if(!getMutability().hasMutationCapability(MutationType.TABLE, config.isSystemUser())) { throw UserException.parseError() .message("Unable to create table. Schema [%s] is immutable for this user.", key.getParent()) .build(logger);
if(path.getParent().getPathComponents().equals(sqlContext)) { vds.setSql(String.format("SELECT * FROM %s", SqlUtils.quoteIdentifier(path.getLeaf())));