cut can also do DROP of whole relation: just use regex that matches no attributes like $^ v_0
authorFrantišek Kučera <franta-hg@frantovo.cz>
Mon, 17 Dec 2018 20:06:29 +0100
branchv_0
changeset 11 9d528c98912d
parent 10 9ec1290b4a9d
child 12 f6fba79c1ed1
cut can also do DROP of whole relation: just use regex that matches no attributes like $^
src/CutHandler.h
--- a/src/CutHandler.h	Thu Dec 13 01:28:55 2018 +0100
+++ b/src/CutHandler.h	Mon Dec 17 20:06:29 2018 +0100
@@ -70,6 +70,7 @@
 	}
 
 	void startRelation(string_t name, vector<AttributeMetadata> attributes) override {
+		currentRecord.resize(attributes.size());
 		// TODO: move to a reusable method (or use same metadata on both reader and writer side?)
 		vector<writer::AttributeMetadata> allWriterMetadata;
 		for (AttributeMetadata readerMetadata : attributes) {
@@ -87,13 +88,12 @@
 				}
 			}
 
-			if (currentAttributeMapping.empty()) throw cli::RelpipeCLIException(L"No attribute matches. Relation must have at least one attribute.", cli::CLI::EXIT_CODE_BAD_SYNTAX); // TODO: review exit code
+			if (currentAttributeMapping.empty()) return; // No attribute matches → DROP whole relation
 			for (integer_t i : currentAttributeMapping) writerMetadata.push_back(allWriterMetadata[i]);
 		} else {
 			writerMetadata = allWriterMetadata;
 		}
 
-		currentRecord.resize(allWriterMetadata.size());
 		relationalWriter->startRelation(name, writerMetadata, true);
 	}