--- a/bash-completion.sh Sat Oct 24 00:08:18 2020 +0200
+++ b/bash-completion.sh Sun Apr 18 10:42:54 2021 +0200
@@ -27,10 +27,12 @@
"false"
)
- if [[ "$w1" == "--write-header" ]]; then COMPREPLY=($(compgen -W "${WRITE_HEADER[*]}" -- "$w0"))
+ if [[ "$w1" == "--write-header" ]]; then COMPREPLY=($(compgen -W "${WRITE_HEADER[*]}" -- "$w0"))
+ elif [[ "$w1" == "--write-types" ]]; then COMPREPLY=($(compgen -W "${WRITE_HEADER[*]}" -- "$w0"))
else
OPTIONS=(
"--write-header"
+ "--write-types"
)
COMPREPLY=($(compgen -W "${OPTIONS[*]}" -- "$w0"))
fi
--- a/src/CLIParser.h Sat Oct 24 00:08:18 2020 +0200
+++ b/src/CLIParser.h Sun Apr 18 10:42:54 2021 +0200
@@ -49,6 +49,7 @@
public:
static const relpipe::reader::string_t OPTION_WRITE_HEADER;
+ static const relpipe::reader::string_t OPTION_WRITE_TYPES;
Configuration parse(const std::vector<relpipe::reader::string_t>& arguments) {
Configuration c;
@@ -58,6 +59,8 @@
if (option == OPTION_WRITE_HEADER) {
c.writeHeader = parseBoolean(readNext(arguments, i));
+ } else if (option == OPTION_WRITE_TYPES) {
+ c.writeTypes = parseBoolean(readNext(arguments, i));
} else throw relpipe::cli::RelpipeCLIException(L"Unsupported CLI option: " + option, relpipe::cli::CLI::EXIT_CODE_BAD_CLI_ARGUMENTS);
}
@@ -69,6 +72,7 @@
};
const relpipe::reader::string_t CLIParser::OPTION_WRITE_HEADER = L"--write-header";
+const relpipe::reader::string_t CLIParser::OPTION_WRITE_TYPES = L"--write-types";
}
}
--- a/src/CSVHandler.h Sat Oct 24 00:08:18 2020 +0200
+++ b/src/CSVHandler.h Sun Apr 18 10:42:54 2021 +0200
@@ -56,7 +56,7 @@
void startRelation(string_t name, std::vector<AttributeMetadata> attributes) override {
if (firstAttributes.empty()) {
firstAttributes = attributes;
- if (configuration.writeHeader) for (auto attr : attributes) attribute(attr.getAttributeName());
+ if (configuration.writeHeader) for (auto attr : attributes) attribute(configuration.writeTypes ? attr.getAttributeName() + L"::" + attr.getTypeName() : attr.getAttributeName());
} else {
// TODO: UNION ALL if data types and attribute count matches
throw RelpipeCSVWriterException(L"Only a single relation can be converted to the CSV format.");
--- a/src/Configuration.h Sat Oct 24 00:08:18 2020 +0200
+++ b/src/Configuration.h Sun Apr 18 10:42:54 2021 +0200
@@ -29,6 +29,7 @@
class Configuration {
public:
relpipe::reader::boolean_t writeHeader = true;
+ relpipe::reader::boolean_t writeTypes = false;
virtual ~Configuration() {
}