#include <boost/filesystem.hpp>
#include <boost/program_options.hpp>
#include <exception>
#include <iostream>
#include "DBEngine.h"
#include <arrow/api.h>
#include <arrow/csv/reader.h>
#include <arrow/io/file.h>
#include "Shared/ArrowUtil.h"
Go to the source code of this file.
|
int | main (int argc, char *argv[]) |
|
int main |
( |
int |
argc, |
|
|
char * |
argv[] |
|
) |
| |
Definition at line 30 of file EmbeddedDbFSITest.cpp.
References EmbeddedDatabase::DBEngine::create(), setup::dbe, run, and to_string().
31 std::string base_path, csv_path;
32 int calcite_port = 5555;
33 bool columnar_output =
true;
34 namespace po = boost::program_options;
36 po::options_description desc(
"Options");
37 desc.add_options()(
"help,h",
"Print help messages ")(
39 po::value<std::string>(&base_path)->required(),
40 "Directory path to OmniSci catalogs")(
41 "csv", po::value<std::string>(&csv_path)->required(),
"Directory path to CSV file")(
43 po::value<int>(&calcite_port)->default_value(calcite_port),
44 "Calcite port")(
"columnar-output",
45 po::value<bool>(&columnar_output)->default_value(columnar_output),
46 "Enable columnar_output");
48 po::positional_options_description positionalOptions;
49 positionalOptions.add(
"data", 1);
54 po::store(po::command_line_parser(argc, argv)
56 .positional(positionalOptions)
59 if (vm.count(
"help")) {
64 }
catch (boost::program_options::error& e) {
65 std::cerr <<
"Usage Error: " << e.what() << std::endl;
70 auto opt_str = base_path +
" --calcite-port " +
std::to_string(calcite_port);
71 if (columnar_output) {
72 opt_str +=
"--columnar-output";
76 dbe->executeDDL(std::string(R
"(
CREATE TEMPORARY TABLE test (
trip_id BIGINT,
vendor_id TEXT ENCODING NONE,
pickup_datetime TIMESTAMP,
dropoff_datetime TIMESTAMP,
store_and_fwd_flag TEXT ENCODING DICT,
rate_code_id BIGINT,
pickup_longitude DOUBLE,
pickup_latitude DOUBLE,
dropoff_longitude DOUBLE,
dropoff_latitude DOUBLE,
passenger_count BIGINT,
trip_distance DOUBLE,
fare_amount DOUBLE,
extra DOUBLE,
mta_tax DOUBLE,
tip_amount DOUBLE,
tolls_amount DOUBLE,
ehail_fee DOUBLE,
improvement_surcharge DOUBLE,
total_amount DOUBLE,
payment_type TEXT ENCODING DICT,
trip_type BIGINT,
pickup TEXT ENCODING DICT,
dropoff TEXT ENCODING NONE,
cab_type TEXT ENCODING DICT,
precipitation DOUBLE,
snow_depth BIGINT,
snowfall DOUBLE,
max_temperature BIGINT,
min_temperature BIGINT,
average_wind_speed DOUBLE,
pickup_nyct2010_gid BIGINT,
pickup_ctlabel DOUBLE,
pickup_borocode BIGINT,
pickup_boroname TEXT ENCODING NONE,
pickup_ct2010 BIGINT,
pickup_boroct2010 BIGINT,
pickup_cdeligibil TEXT ENCODING DICT,
pickup_ntacode TEXT ENCODING DICT,
pickup_ntaname TEXT ENCODING DICT,
pickup_puma BIGINT,
dropoff_nyct2010_gid BIGINT,
dropoff_ctlabel DOUBLE,
dropoff_borocode BIGINT,
dropoff_boroname TEXT ENCODING NONE,
dropoff_ct2010 BIGINT,
dropoff_boroct2010 BIGINT,
dropoff_cdeligibil TEXT ENCODING NONE,
dropoff_ntacode TEXT ENCODING NONE,
dropoff_ntaname TEXT ENCODING NONE,
dropoff_puma BIGINT) WITH (storage_type='CSV:") + csv_path + std::string("', fragment_size=100);)"));
77 auto schema =
dbe->getTableDetails(
"test");
78 for (
auto& item : schema) {
79 std::cout << item.col_name << std::endl;
81 auto cursor =
dbe->executeDML(
"select count(*) from test");
83 std::cout << cursor->getRowCount() <<
" rows selected" << std::endl;
84 std::shared_ptr<arrow::RecordBatch> rbatch = cursor->getArrowRecordBatch();
86 std::cerr <<
"Cursor is NULL" << std::endl;
89 }
catch (std::exception& e) {
90 std::cerr << e.what() <<
"\n";
94 std::pair< FILE *, std::string > create(const std::string &basePath, const int fileId, const size_t pageSize, const size_t numPages)