@VisibleForTesting public Catalog getSystemUserCatalog() { return getCatalog(SchemaConfig.newBuilder(SystemUser.SYSTEM_USERNAME).build()); }
.getCatalog(SchemaConfig.newBuilder(SystemUser.SYSTEM_USERNAME).build()) .createDataset(new NamespaceKey(getMaterializationPath(materialization)), datasetMutator);
private Catalog createCatalog() { return catalogService.getCatalog(SchemaConfig.newBuilder(security.getUserPrincipal().getName()).build()); }
req.getTableNameFilter()); if (tableName != null ) { dContext.getCatalogService().getCatalog(SchemaConfig.newBuilder(session.getCredentials().getUserName()).build()) .getTable(tableName);
.exposeInternalSources(session.exposeInternalSources()) .setDatasetValidityChecker(datasetValidityChecker) .build();
.setViewExpansionContext(viewExpansionContext) .exposeInternalSources(session.exposeInternalSources()) .build();
/** * @throws UserException if reflection goal is invalid */ public void validate(ReflectionGoal goal) { ReflectionUtils.validateReflectionGoalWithoutSchema(goal); // The dataset that the reflection refers to must exist. DatasetConfig dataset = namespaceService.get().findDatasetByUUID(goal.getDatasetId()); Preconditions.checkNotNull(dataset, "datasetId must reference an existing dataset"); Catalog catalog = catalogService.get().getCatalog(SchemaConfig.newBuilder(SystemUser.SYSTEM_USERNAME).build()); DremioTable table = catalog.getTable(new NamespaceKey(dataset.getFullPathList())); List<ViewFieldType> schemaFields = ViewFieldsHelper.getBatchSchemaFields(table.getSchema()); Map<String, ViewFieldType> schemaMap = Maps.newHashMap(); for (ViewFieldType type : schemaFields) { schemaMap.put(type.getName(), type); } // Array, List, Map, and Union types cannot be used as dimension or measure field. They also cannot be used for sorting, partitioning or distribution in raw reflections. validateFields(goal.getDetails().getDisplayFieldList(), schemaMap, "Display", false); validateMeasures(goal.getDetails().getMeasureFieldList(), schemaMap, "Measure"); validateFields(goal.getDetails().getDistributionFieldList(), schemaMap, "Distribution", true); validateFields(goal.getDetails().getSortFieldList(), schemaMap, "Sort", true); validateFields(goal.getDetails().getPartitionFieldList(), schemaMap, "Partition", true); validateDimensions(goal.getDetails().getDimensionFieldList(), schemaMap); }
public static void uploadFile(HomeFileConf homeFileStore, Path inputFile, String name, String extension ,FileFormat fileFormat, FolderPath parent) throws Exception { FilePath filePath; if (parent == null) { filePath = new FilePath(ImmutableList.of(HomeName.getUserHomePath(DEFAULT_USER_NAME).getName(), name)); } else { List<String> path = Lists.newArrayList(parent.toPathList()); path.add(name); filePath = new FilePath(path); } FSDataInputStream inputStream = FileSystem.getLocal(new Configuration()).open(inputFile); FileSystem fs = homeFileStore.getFilesystemAndCreatePaths(null); Path stagingLocation = new HomeFileTool(homeFileStore, fs, "localhost").stageFile(filePath, extension, inputStream); Path finalLocation = new HomeFileTool(homeFileStore, fs, "localhost").saveFile(stagingLocation, filePath, extension); inputStream.close(); // create file in namespace fileFormat.setFullPath(filePath.toPathList()); fileFormat.setName(name); fileFormat.setLocation(finalLocation.toString()); DatasetConfig datasetConfig = DatasetsUtil.toDatasetConfig(fileFormat.asFileConfig(), DatasetType.PHYSICAL_DATASET_HOME_FILE, null, null); newCatalogService().getCatalog(SchemaConfig.newBuilder(SystemUser.SYSTEM_USERNAME).build()).createOrUpdateDataset(newNamespaceService(), new NamespaceKey(HomeFileSystemStoragePlugin.HOME_PLUGIN_NAME), filePath.toNamespaceKey(), datasetConfig); }
protected Catalog cat() { return l(CatalogService.class).getCatalog(SchemaConfig.newBuilder(SYSTEM_USERNAME).build()); }
private List<String> getPartitionColumnsForDataSet(String folder) throws Exception { URL stream = (TestParquetPartitionColumns.class.getClassLoader() .getResource(folder)); File fileDir = new File(stream.getFile()); DatasetPath parquet = new DatasetPath(ImmutableList.of("dfs", fileDir.getAbsolutePath())); DatasetConfig config = addDataSet(parquet); DremioTable table = p(CatalogService.class).get().getCatalog(SchemaConfig.newBuilder (DEFAULT_USERNAME) .build()) .getTable(config.getId().getId()); return table.getDatasetConfig().getReadDefinition() .getPartitionColumnsList(); }
public MetadataRequestOptions cloneWith(String newUser, NamespaceKey newDefaultSchema) { SchemaConfig newSchemaConfig = SchemaConfig.newBuilder(newUser) .defaultSchema(newDefaultSchema) .exposeInternalSources(schemaConfig.exposeInternalSources()) .setIgnoreAuthErrors(schemaConfig.getIgnoreAuthErrors()) .optionManager(schemaConfig.getOptions()) .setViewExpansionContext(schemaConfig.getViewExpansionContext()) .setDatasetValidityChecker(schemaConfig.getDatasetValidityChecker()) .build(); return new MetadataRequestOptions(newSchemaConfig, statsCollector, maxRequestTime); } }
@Override @RequestScoped public Catalog provide() { return catalogService.getCatalog(SchemaConfig.newBuilder(context.getUserPrincipal().getName()).build()); }
public List<String> getColumnList(final String username, DatasetPath path) { Catalog catalog = catalogService.getCatalog(SchemaConfig.newBuilder(context.getUserPrincipal().getName()).build()); DremioTable table = catalog.getTable(path.toNamespaceKey()); return table.getRowType(SqlTypeFactoryImpl.INSTANCE).getFieldNames(); }
private Catalog createCatalog(String userName) { return catalogService.getCatalog(SchemaConfig.newBuilder(userName).build()); }
public RelDataType getRowType(final NamespaceKey path) { DremioTable table = catalogService.getCatalog(SchemaConfig.newBuilder(SystemUser.SYSTEM_USERNAME).build()).getTable(path); Preconditions.checkNotNull(table, "Unknown dataset %s", path); return table.getRowType(JavaTypeFactoryImpl.INSTANCE); }
private Reflection createReflection() { // create a reflection List<ReflectionField> displayFields = new ArrayList<>(); DremioTable table = newCatalogService().getCatalog(SchemaConfig.newBuilder(SystemUser.SYSTEM_USERNAME).build()).getTable(datasetId); for (int i = 0; i < table.getSchema().getFieldCount(); i++) { Field field = table.getSchema().getColumn(i); displayFields.add(new ReflectionField(field.getName())); } return Reflection.newRawReflection(null, "My Raw", null, null, null, table.getDatasetConfig().getId().getId(), null, null, true, null, displayFields, null, null, null, PartitionDistributionStrategy.CONSOLIDATED); }