public boolean isSystemUser() { return getUserName().equals(SystemUser.SYSTEM_USERNAME); }
@Override public String getUser() { return options.getSchemaConfig().getUserName(); }
@Override public TranslatableTable apply(final List<Object> arguments) { try { SourceTableDefinition definition = plugin.getDatasetWithOptions(new NamespaceKey (tableSchemaPath), new TableInstance(sig, arguments), schemaConfig.getIgnoreAuthErrors(), schemaConfig.getUserName()); if(definition == null){ throw UserException.validationError().message("Unable to read table %s using provided options.", new NamespaceKey(tableSchemaPath).toString()).build(logger); } return new MaterializedDatasetTable(plugin, schemaConfig.getUserName(), new QuietAccessor(definition)); } catch (Exception e) { throw new RuntimeException(e); } }
private CatalogImpl( SabotContext context, MetadataRequestOptions options, PluginRetriever pluginRetriever, String username, CatalogServiceImpl.SourceModifier sourceModifier ) { this.context = context; this.options = options; this.pluginRetriever = pluginRetriever; this.username = username; this.systemNamespaceService = context.getNamespaceService(SystemUser.SYSTEM_USERNAME); this.userNamespaceService = context.getNamespaceService(username); this.datasets = new DatasetManager( pluginRetriever, userNamespaceService ); this.sourceModifier = sourceModifier; }
try { try { files = DotFileUtil.getDotFiles(getFS(schemaConfig.getUserName()), config.getPath(), tableSchemaPath.get(tableSchemaPath.size() - 1), DotFileType.VIEW); } catch (AccessControlException e) { if (!schemaConfig.getIgnoreAuthErrors()) {
/** * Get a new {@link CachingCatalog} that only considers metadata valid if it is newer than the * provided maxRequestTime. * * @param schemaConfig schema config * @param maxRequestTime max request time * @return catalog with given constraints */ @Override public Catalog getCatalog(SchemaConfig schemaConfig, long maxRequestTime) { final Catalog catalog = new CatalogImpl(context.get(), new MetadataRequestOptions(schemaConfig, maxRequestTime), new Retriever(), new SourceModifier(schemaConfig.getUserName())); return new CachingCatalog(catalog); }
public Iterable<String> getSubPartitions(List<String> table, List<String> partitionColumns, List<String> partitionValues, SchemaConfig schemaConfig ) throws PartitionNotFoundException { List<FileStatus> fileStatuses; try { Path fullPath = PathUtils.toFSPath(resolveTableNameToValidPath(table)); fileStatuses = getFS(schemaConfig.getUserName()).list(fullPath, false); } catch (IOException e) { throw new PartitionNotFoundException("Error finding partitions for table " + table, e); } return new SubDirectoryList(fileStatuses); }
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 dropView(SchemaConfig schemaConfig, List<String> tableSchemaPath) throws IOException { if(!getMutability().hasMutationCapability(MutationType.VIEW, schemaConfig.isSystemUser())) { throw UserException.parseError() .message("Unable to drop view. Schema [%s] is immutable for this user.", this.name) .build(logger); } getFS(schemaConfig.getUserName()).delete(getViewPath(tableSchemaPath), false); }
@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; }
final String userName = this.config.isImpersonationEnabled() ? config.getUserName() : ImpersonationUtil.getProcessUserName();
FileSystemWrapper fs = getFS(schemaConfig.getUserName()); List<String> fullPath = resolveTableNameToValidPath(tableSchemaPath); FileSelection fileSelection;
plugin.checkAccess(key, datasetConfig, options); final NamespaceKey canonicalKey = new NamespaceKey(datasetConfig.getFullPathList()); final NamespaceTable namespaceTable = new NamespaceTable(new TableMetadataImpl(plugin.getId(), datasetConfig, options.getSchemaConfig().getUserName(), DatasetSplitsPointer.of(userNamespaceService, datasetConfig))); options.getStatsCollector().addDatasetStat(canonicalKey.getSchemaPath(), MetadataAccessType.CACHED_METADATA.name(), stopwatch.elapsed(TimeUnit.MILLISECONDS)); return namespaceTable; TableMetadata metadata = new TableMetadataImpl(plugin.getId(), newDatasetConfig, options.getSchemaConfig().getUserName(), MaterializedSplitsPointer.of(splits, splits.size())); return new NamespaceTable(metadata); } catch(UserException ex) {