19 #include <boost/variant/get.hpp>
25 namespace import_export {
32 const std::string& layer_name,
34 const std::vector<TargetMetaInfo>& column_infos,
40 auto actual_file_path{file_path};
43 throw std::runtime_error(
"Compression not yet supported for this file type");
49 throw std::runtime_error(
"Failed to create file '" + actual_file_path +
"'");
54 bool not_first{
false};
56 for (
auto const& column_info : column_infos) {
58 auto column_name =
safeColumnName(column_info.get_resname(), column_index + 1);
76 for (
auto& agg_result : query_results) {
77 auto results = agg_result.rs;
78 auto const& targets = agg_result.targets_meta;
81 auto const crt_row = results->getNextRow(
true,
true);
82 if (crt_row.empty()) {
85 bool not_first =
false;
86 for (
size_t i = 0;
i < results->colCount(); ++
i) {
88 auto const tv = crt_row[
i];
89 auto const scalar_tv = boost::get<ScalarTargetValue>(&tv);
98 auto const& ti = targets[
i].get_type_info();
106 if (boost::get<int64_t>(scalar_tv)) {
107 auto int_val = *(boost::get<int64_t>(scalar_tv));
108 switch (ti.get_type()) {
134 }
else if (ti.get_type() ==
kTIME) {
135 constexpr
size_t buf_size = 9;
143 }
else if (boost::get<double>(scalar_tv)) {
144 auto real_val = *(boost::get<double>(scalar_tv));
145 if (ti.get_type() ==
kFLOAT) {
152 }
else if (ti.get_type() ==
kNUMERIC) {
153 outfile_ << std::setprecision(ti.get_precision()) << real_val;
155 outfile_ << std::setprecision(std::numeric_limits<double>::digits10 + 1)
158 }
else if (boost::get<float>(scalar_tv)) {
160 auto real_val = *(boost::get<float>(scalar_tv));
164 outfile_ << std::setprecision(std::numeric_limits<float>::digits10 + 1)
168 auto s = boost::get<NullableString>(scalar_tv);
169 is_null = !s || boost::get<void*>(s);
173 auto s_notnull = boost::get<std::string>(s);
179 if (q == std::string::npos) {
182 std::string str(*s_notnull);
183 while (q != std::string::npos) {
std::string datum_to_string(const TargetValue &tv, const SQLTypeInfo &ti, const std::string &delim)
std::string safeColumnName(const std::string &resname, const int column_index)
void exportResults(const std::vector< AggregatedResult > &query_results) final
size_t formatHMS(char *buf, size_t const max, int64_t const unixtime)
ImportHeaderRow has_header
CONSTEXPR DEVICE bool is_null(const T &value)
void beginExport(const std::string &file_path, const std::string &layer_name, const CopyParams ©_params, const std::vector< TargetMetaInfo > &column_infos, const FileCompression file_compression, const ArrayNullHandling array_null_handling) final
Basic constructors and methods of the row set interface.
void validateFileExtensions(const std::string &file_path, const std::string &file_type, const std::unordered_set< std::string > &valid_extensions) const