14 {
"Extract",
"Extract"},
18static void runInsertSpatialDataToAHyperFile() {
19 std::cout <<
"EXAMPLE - Insert geospatial data into a single table within a new Hyper file" << std::endl;
20 const std::string pathToDatabase =
"data/spatial_data.hyper";
53 std::vector<hyperapi::TableDefinition::Column> inserterDefinition{
61 std::string textToGeographyCastExpression =
"CAST(" +
hyperapi::escapeName(
"Location_as_text") +
" AS TABLEAU.TABGEOGRAPHY)";
62 std::vector<hyperapi::Inserter::ColumnMapping> columnMappings{
68 hyperapi::Inserter inserter(connection, extractTable, columnMappings, inserterDefinition);
69 inserter.addRow(
"Seattle",
"point(-122.338083 47.647528)");
70 inserter.addRow(
"Munich",
"point(11.584329 48.139257)");
76 int64_t rowCount = connection.executeScalarQuery<int64_t>(
"SELECT COUNT(*) FROM " + extractTable.
getTableName().
toString());
77 std::cout <<
"The number of rows in table " << extractTable.
getTableName() <<
" is " << rowCount <<
"." << std::endl;
79 std::cout <<
"The connection to the Hyper file has been closed." << std::endl;
81 std::cout <<
"The Hyper Process has been shut down." << std::endl;
86 runInsertSpatialDataToAHyperFile();
88 std::cout << e.
toString() << std::endl;
The catalog class gives access to the metadata of the attached databases of a connection.
void createSchema(const SchemaName &schemaName) const
Creates a SQL schema with the given name.
void createTable(const hyperapi::TableDefinition &table_definition) const
Creates a SQL table with the given table definition.
Defines a Hyper connection.
Defines an exception object that is thrown on failure by the functions in the Hyper API C++ library.
std::string toString() const
Returns a formatted string containing the message and hint of the error and all causes.
Maps an expression to a column
static SqlType tabgeography() noexcept
Returns the TABGEOGRAPHY SQL type.
static SqlType text() noexcept
Returns the TEXT SQL type.
A Column of a table definition.
const TableName & getTableName() const noexcept
Returns the name of the table.
std::string toString() const
The main header of the Hyper API for C++.
@ NotNullable
The column cannot contain NULL values.
@ SendUsageDataToTableau
Telemetry data will be sent to tableau to help improve the Hyper API.
@ CreateAndReplace
Create the database. If it already exists, drop the old one first.
std::string escapeName(string_view input)
Escapes the given string for safe usage in SQL query or command strings as an identifier.