@Test public void testAddProperty() throws Exception { command.datasets = Lists.newArrayList("users"); command.properties = Lists.newArrayList( "new.property=1234", "prop=with=equals" ); command.run(); DatasetDescriptor updated = new DatasetDescriptor.Builder(original) .property("new.property", "1234") .property("prop", "with=equals") .build(); verify(repo).load("default", "users"); verify(ds).getDescriptor(); verify(repo).update(eq("default"), eq("users"), argThat(TestUtil.matches(updated))); verify(console).debug(contains("Updated"), eq("users")); }
@Override public int run() throws IOException { if (datasets == null || datasets.size() != 1) { throw new IllegalArgumentException( "Exactly one dataset name must be specified."); } String dataset = datasets.remove(0); Dataset<GenericRecord> currentDataset = load(dataset).getDataset(); DatasetDescriptor.Builder descriptorBuilder = new DatasetDescriptor .Builder(currentDataset.getDescriptor()); if (avroSchemaFile != null) { descriptorBuilder.schemaUri(qualifiedURI(avroSchemaFile)); } if (partitionStrategyFile != null) { descriptorBuilder.partitionStrategyUri( qualifiedURI(partitionStrategyFile)); } if (properties != null) { for (String propValue : properties) { Iterator<String> parts = PROP_VALUE_SEP.split(propValue).iterator(); descriptorBuilder.property( Iterators.getNext(parts, null), Iterators.getNext(parts, null)); } } DatasetDescriptor descriptor = descriptorBuilder.build(); if (isDatasetOrViewUri(dataset)) { Datasets.<GenericData.Record, Dataset<GenericData.Record>> update(dataset, descriptor, GenericData.Record.class); } else { getDatasetRepository().update(namespace, dataset, descriptor); } console.debug("Updated {}", dataset); return 0; }
UpdateDatasetCommand extends BaseDatasetCommand { @Override public int run() throws IOException { if (datasets == null || datasets.size() != 1) { throw new IllegalArgumentException( "Exactly one dataset name must be specified."); } String dataset = datasets.remove(0); Dataset<GenericRecord> currentDataset = load(dataset).getDataset(); DatasetDescriptor.Builder descriptorBuilder = new DatasetDescriptor .Builder(currentDataset.getDescriptor()); if (avroSchemaFile != null) { descriptorBuilder.schemaUri(qualifiedURI(avroSchemaFile)); } if (partitionStrategyFile != null) { descriptorBuilder.partitionStrategyUri( qualifiedURI(partitionStrategyFile)); } if (properties != null) { for (String propValue : properties) { Iterator<String> parts = PROP_VALUE_SEP.split(propValue).iterator(); descriptorBuilder.property( Iterators.getNext(parts, null), Iterators.getNext(parts, null)); } } DatasetDescriptor descriptor = descriptorBuilder.build(); if (isDatasetOrViewUri(dataset)) { Datasets.<GenericData.Record, Dataset<GenericData.Record>> update(dataset, descriptor, GenericData.Record.class); } else { getDatasetRepository().update(namespace, dataset, descriptor); } console.debug("Updated {}", dataset); return 0; } }
UpdateDatasetCommand extends BaseDatasetCommand { @Override public int run() throws IOException { if (datasets == null || datasets.size() != 1) { throw new IllegalArgumentException( "Exactly one dataset name must be specified."); } String dataset = datasets.remove(0); Dataset<GenericRecord> currentDataset = load(dataset).getDataset(); DatasetDescriptor.Builder descriptorBuilder = new DatasetDescriptor .Builder(currentDataset.getDescriptor()); if (avroSchemaFile != null) { descriptorBuilder.schemaUri(qualifiedURI(avroSchemaFile)); } if (partitionStrategyFile != null) { descriptorBuilder.partitionStrategyUri( qualifiedURI(partitionStrategyFile)); } if (properties != null) { for (String propValue : properties) { Iterator<String> parts = PROP_VALUE_SEP.split(propValue).iterator(); descriptorBuilder.property( Iterators.getNext(parts, null), Iterators.getNext(parts, null)); } } DatasetDescriptor descriptor = descriptorBuilder.build(); if (isDatasetOrViewUri(dataset)) { Datasets.<GenericData.Record, Dataset<GenericData.Record>> update(dataset, descriptor, GenericData.Record.class); } else { getDatasetRepository().update(namespace, dataset, descriptor); } console.debug("Updated {}", dataset); return 0; } UpdateDatasetCommand(Logger console); }
UpdateDatasetCommand extends BaseDatasetCommand { @Override public int run() throws IOException { if (datasets == null || datasets.size() != 1) { throw new IllegalArgumentException( "Exactly one dataset name must be specified."); } String dataset = datasets.remove(0); Dataset<GenericRecord> currentDataset = load(dataset).getDataset(); DatasetDescriptor.Builder descriptorBuilder = new DatasetDescriptor .Builder(currentDataset.getDescriptor()); if (avroSchemaFile != null) { descriptorBuilder.schemaUri(qualifiedURI(avroSchemaFile)); } if (partitionStrategyFile != null) { descriptorBuilder.partitionStrategyUri( qualifiedURI(partitionStrategyFile)); } if (properties != null) { for (String propValue : properties) { Iterator<String> parts = PROP_VALUE_SEP.split(propValue).iterator(); descriptorBuilder.property( Iterators.getNext(parts, null), Iterators.getNext(parts, null)); } } DatasetDescriptor descriptor = descriptorBuilder.build(); if (isDatasetOrViewUri(dataset)) { Datasets.<GenericData.Record, Dataset<GenericData.Record>> update(dataset, descriptor, GenericData.Record.class); } else { getDatasetRepository().update(namespace, dataset, descriptor); } console.debug("Updated {}", dataset); return 0; } UpdateDatasetCommand(Logger console); @Override int run(); @Override List<String> getExamples(); }
UpdateDatasetCommand extends BaseDatasetCommand { @Override public int run() throws IOException { if (datasets == null || datasets.size() != 1) { throw new IllegalArgumentException( "Exactly one dataset name must be specified."); } String dataset = datasets.remove(0); Dataset<GenericRecord> currentDataset = load(dataset).getDataset(); DatasetDescriptor.Builder descriptorBuilder = new DatasetDescriptor .Builder(currentDataset.getDescriptor()); if (avroSchemaFile != null) { descriptorBuilder.schemaUri(qualifiedURI(avroSchemaFile)); } if (partitionStrategyFile != null) { descriptorBuilder.partitionStrategyUri( qualifiedURI(partitionStrategyFile)); } if (properties != null) { for (String propValue : properties) { Iterator<String> parts = PROP_VALUE_SEP.split(propValue).iterator(); descriptorBuilder.property( Iterators.getNext(parts, null), Iterators.getNext(parts, null)); } } DatasetDescriptor descriptor = descriptorBuilder.build(); if (isDatasetOrViewUri(dataset)) { Datasets.<GenericData.Record, Dataset<GenericData.Record>> update(dataset, descriptor, GenericData.Record.class); } else { getDatasetRepository().update(namespace, dataset, descriptor); } console.debug("Updated {}", dataset); return 0; } UpdateDatasetCommand(Logger console); @Override int run(); @Override List<String> getExamples();  }