@Override public DatasetPath apply(Entry<NamespaceKey, NameSpaceContainer> input) { return new DatasetPath(input.getKey().getPathComponents()); } });
public TableWithPath(DremioTable table) { super(); this.table = table; this.path = table.getPath().getPathComponents(); } public DremioTable getTable() {
@Override public List<List<String>> get() { final List<String> table = dataset.getName().getPathComponents(); if (table == null) { return ImmutableList.of(); } return ImmutableList.of(table); } });
public static TableName getTableName(NamespaceKey key) { switch(key.size()) { case 2: return TableName.valueOf(key.getName()); case 3: final List<String> paths = key.getPathComponents(); return TableName.valueOf(paths.get(1), paths.get(2)); default: throw new IllegalStateException("Unexpected key length: " + key); } } }
public DremioCatalogReader( SimpleCatalog<?> catalog, RelDataTypeFactory typeFactory) { this.catalog = catalog; this.typeFactory = (JavaTypeFactory) typeFactory; ImmutableList.Builder<List<String>> schemaPaths = ImmutableList.builder(); if (catalog.getDefaultSchema() != null) { schemaPaths.add(ImmutableList.copyOf(catalog.getDefaultSchema().getPathComponents())); } schemaPaths.add(ImmutableList.of()); this.schemaPaths = schemaPaths.build(); }
@Override public boolean datasetExists(NamespaceKey key) { if(key.size() != 3){ return false; } return getClient(SystemUser.SYSTEM_USERNAME).tableExists(key.getPathComponents().get(1), key.getPathComponents().get(2)); }
protected static String getTableName(final NamespaceKey key) { final String tableName; if(key.size() == 2) { tableName = key.getLeaf(); } else { List<String> subString = key.getPathComponents().subList(1, key.size()); tableName = Joiner.on('/').join(subString); } return tableName; }
@Override public DatasetConfig buildDataset() throws Exception { final DatasetConfig datasetConfig = getDatasetInternal(fs, fileSelection, datasetPath.getPathComponents()); buildAll(datasetConfig); return datasetConfig; }
@Override public DatasetConfig buildDataset() throws Exception { final DatasetConfig datasetConfig = super.getDatasetInternal(fs, fileSelection, datasetPath.getPathComponents()); buildAll(datasetConfig); return datasetConfig; }
@Override public NamespaceKey resolveToDefault(NamespaceKey key) { if(options.getSchemaConfig().getDefaultSchema() == null) { return null; } return new NamespaceKey( ImmutableList.copyOf( Iterables.concat( options.getSchemaConfig().getDefaultSchema().getPathComponents(), key.getPathComponents()))); }
@Override public void write(final Kryo kryo, final Output output, final TableMetadata table) { try{ Preconditions.checkArgument(!table.isPruned(), "Cannot serialize a pruned table."); }catch(NamespaceException ex){ throw Throwables.propagate(ex); } kryo.writeObject(output, table.getName().getPathComponents()); }
@Override public boolean containerExists(NamespaceKey key) { if(key.size() != 2){ return false; } return getClient(SystemUser.SYSTEM_USERNAME).databaseExists(key.getPathComponents().get(1)); }
@Override public boolean datasetExists(NamespaceKey key) { final List<String> filePath = key.getPathComponents(); try { return getFS(SYSTEM_USERNAME).exists(PathUtils.toFSPath(resolveTableNameToValidPath(filePath))); } catch (IOException e) { logger.debug("Failure reading path.", e); return false; } }
@Override public boolean containerExists(NamespaceKey key) { final List<String> folderPath = key.getPathComponents(); try { return getFS(SYSTEM_USERNAME).isDirectory(PathUtils.toFSPath(resolveTableNameToValidPath(folderPath))); } catch (IOException e) { logger.debug("Failure reading path.", e); return false; } }
@Override public void dropTable(NamespaceKey key) { asMutable(key, "does not support dropping tables").dropTable(key.getPathComponents(), options.getSchemaConfig()); try { systemNamespaceService.deleteEntity(key); } catch (NamespaceException e) { throw Throwables.propagate(e); } }
public ViewTable getView(NamespaceKey key, final MetadataRequestOptions options) { try(AutoCloseableLock l = readLock()) { checkState(); // TODO: move views to namespace and out of filesystem. return plugin.getView(key.getPathComponents(), options.getSchemaConfig()); } }
void shallowSave(SourceTableDefinition accessor) throws NamespaceException{ NamespaceKey key = accessor.getName(); DatasetConfig shallow = new DatasetConfig(); shallow.setId(new EntityId().setId(UUID.randomUUID().toString())); shallow.setCreatedAt(System.currentTimeMillis()); shallow.setName(key.getName()); shallow.setFullPathList(key.getPathComponents()); shallow.setType(accessor.getType()); shallow.setSchemaVersion(DatasetHelper.CURRENT_VERSION); systemUserNamespaceService.addOrUpdateDataset(key, shallow); }
@Override public void deleteDataset(final NamespaceKey datasetPath, String version) throws NamespaceException { NameSpaceContainer container = deleteEntity(datasetPath, DATASET, version, true); if (container.getDataset().getType() == PHYSICAL_DATASET_SOURCE_FOLDER) { // create a folder so that any existing datasets under the folder are now visible addOrUpdateFolder(datasetPath, new FolderConfig() .setFullPathList(datasetPath.getPathComponents()) .setName(datasetPath.getName()) ); } }
public static void addFolder(NamespaceService ns, String name) throws Exception { final FolderConfig folder = new FolderConfig(); final NamespaceKey folderPath = new NamespaceKey(PathUtils.parseFullPath(name)); folder.setName(folderPath.getName()); folder.setFullPathList(folderPath.getPathComponents()); ns.addOrUpdateFolder(folderPath, folder); }
public static void addDS(NamespaceService ns, String name) throws Exception { final NamespaceKey dsPath = new NamespaceKey(PathUtils.parseFullPath(name)); final DatasetConfig ds = new DatasetConfig(); final VirtualDataset vds = new VirtualDataset(); vds.setVersion(DatasetVersion.newVersion()); ds.setType(DatasetType.VIRTUAL_DATASET); ds.setVirtualDataset(vds); ds.setFullPathList(dsPath.getPathComponents()); ds.setName(dsPath.getName()); ns.addOrUpdateDataset(dsPath, ds); }