Skip to content

Commit 61d5e3a

Browse files
Update samples for the Feb 2025 Public Hyper API release (#112)
1 parent 75913ed commit 61d5e3a

File tree

3 files changed

+19
-19
lines changed

3 files changed

+19
-19
lines changed

Tableau-Supported/CPP/CMakeLists.txt

+5-5
Original file line numberDiff line numberDiff line change
@@ -105,13 +105,13 @@ add_test(
105105
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
106106

107107
# -----------------------------------------------------------------------------
108-
# `insert_spatial_data_to_a_hyper_file.cpp`
108+
# `insert_geospatial_data_to_a_hyper_file.cpp`
109109

110-
add_executable(insert_spatial_data_to_a_hyper_file insert_spatial_data_to_a_hyper_file.cpp)
111-
target_link_libraries(insert_spatial_data_to_a_hyper_file PRIVATE Tableau::tableauhyperapi-cxx)
110+
add_executable(insert_geospatial_data_to_a_hyper_file insert_geospatial_data_to_a_hyper_file.cpp)
111+
target_link_libraries(insert_geospatial_data_to_a_hyper_file PRIVATE Tableau::tableauhyperapi-cxx)
112112
add_test(
113-
NAME insert_spatial_data_to_a_hyper_file
114-
COMMAND ${CMAKE_COMMAND} -E env HYPER_PATH=${HYPER_PATH} $<TARGET_FILE:insert_spatial_data_to_a_hyper_file>
113+
NAME insert_geospatial_data_to_a_hyper_file
114+
COMMAND ${CMAKE_COMMAND} -E env HYPER_PATH=${HYPER_PATH} $<TARGET_FILE:insert_geospatial_data_to_a_hyper_file>
115115
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
116116

117117
# -----------------------------------------------------------------------------

Tableau-Supported/CPP/insert_spatial_data_to_a_hyper_file.cpp Tableau-Supported/CPP/insert_geospatial_data_to_a_hyper_file.cpp

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
2-
* \example insert_spatial_data_to_a_hyper_file.cpp
2+
* \example insert_geospatial_data_to_a_hyper_file.cpp
33
*
4-
* An example of how to insert spatial data into a single-table Hyper file.
4+
* An example of how to insert geospatial data into a single-table Hyper file.
55
*/
66

77
#include <hyperapi/hyperapi.hpp>
@@ -14,10 +14,10 @@
1414
static const hyperapi::TableDefinition extractTable{
1515
{"Extract", "Extract"},
1616
{hyperapi::TableDefinition::Column{"Name", hyperapi::SqlType::text(), hyperapi::Nullability::NotNullable},
17-
hyperapi::TableDefinition::Column{"Location", hyperapi::SqlType::geography(), hyperapi::Nullability::NotNullable}}};
17+
hyperapi::TableDefinition::Column{"Location", hyperapi::SqlType::tabgeography(), hyperapi::Nullability::NotNullable}}};
1818

1919
static void runInsertSpatialDataToAHyperFile() {
20-
std::cout << "EXAMPLE - Insert spatial data into a single table within a new Hyper file" << std::endl;
20+
std::cout << "EXAMPLE - Insert geospatial data into a single table within a new Hyper file" << std::endl;
2121
const std::string pathToDatabase = "data/spatial_data.hyper";
2222

2323
// Starts the Hyper Process with telemetry enabled to send data to Tableau.
@@ -56,15 +56,15 @@ static void runInsertSpatialDataToAHyperFile() {
5656
hyperapi::TableDefinition::Column{"Location_as_text", hyperapi::SqlType::text(), hyperapi::Nullability::NotNullable}};
5757

5858
// Column 'Name' is inserted into "Extract"."Extract" as-is.
59-
// Column 'Location' in "Extract"."Extract" of geography type is computed from Column 'Location_as_text' of text type
60-
// using the expression 'CAST("Location_as_text") AS GEOGRAPHY'.
59+
// Column 'Location' in "Extract"."Extract" of `tableau.tabgeography` type is computed from Column 'Location_as_text' of `text` type
60+
// using the expression 'CAST("Location_as_text") AS TABLEAU.TABGEOGRAPHY'.
6161
// hyperapi::Inserter::ColumnMapping is used for mapping the CAST expression to Column 'Location'.
62-
std::string textToGeographyCastExpression = "CAST(" + hyperapi::escapeName("Location_as_text") + " AS GEOGRAPHY)";
62+
std::string textToGeographyCastExpression = "CAST(" + hyperapi::escapeName("Location_as_text") + " AS TABLEAU.TABGEOGRAPHY)";
6363
std::vector<hyperapi::Inserter::ColumnMapping> columnMappings{
6464
hyperapi::Inserter::ColumnMapping{"Name"},
6565
hyperapi::Inserter::ColumnMapping{"Location", textToGeographyCastExpression}};
6666

67-
// Insert spatial data into the "Extract"."Extract" table using CAST expression.
67+
// Insert geospatial data into the "Extract"."Extract" table using CAST expression.
6868
{
6969
hyperapi::Inserter inserter(connection, extractTable, columnMappings, inserterDefinition);
7070
inserter.addRow("Seattle", "point(-122.338083 47.647528)");

Tableau-Supported/Java/insert-spatial-data-to-a-hyper-file/src/main/java/examples/InsertSpatialDataToAHyperFile.java

+6-6
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import static com.tableau.hyperapi.Sql.escapeStringLiteral;
1414

1515
/**
16-
* An example demonstrating spatial data insertion to a hyper file
16+
* An example demonstrating geospatial data insertion to a hyper file
1717
*/
1818
public class InsertSpatialDataToAHyperFile{
1919
/**
@@ -23,15 +23,15 @@ public class InsertSpatialDataToAHyperFile{
2323
private static TableDefinition EXTRACT_TABLE = new TableDefinition(
2424
new TableName("Extract","Extract"))
2525
.addColumn("Name", SqlType.text(), NOT_NULLABLE)
26-
.addColumn("Location", SqlType.geography(), NOT_NULLABLE);
26+
.addColumn("Location", SqlType.tabgeography(), NOT_NULLABLE);
2727

2828
/**
2929
* The main function
3030
*
3131
* @param args The args
3232
*/
3333
public static void main(String[] args) {
34-
System.out.println("EXAMPLE - Insert spatial data into a Hyper file");
34+
System.out.println("EXAMPLE - Insert geospatial data into a Hyper file");
3535

3636
Path spatialDataPath = Paths.get(getWorkingDirectory(), "spatial_data.hyper");
3737

@@ -70,10 +70,10 @@ public static void main(String[] args) {
7070
inserterDefintion.add(new TableDefinition.Column("Location_as_text", SqlType.text(), NOT_NULLABLE));
7171

7272
// Column 'Name' is inserted into "Extract"."Extract" as-is.
73-
// Column 'Location' in "Extract"."Extract" of geography type is computed from Column 'Location_as_text' of text type
74-
// using the expression 'CAST("Location_as_text") AS GEOGRAPHY'.
73+
// Column 'Location' in "Extract"."Extract" of `tableau.tabgeography` type is computed from Column 'Location_as_text' of `text` type
74+
// using the expression 'CAST("Location_as_text") AS TABLEAU.TABGEOGRAPHY'.
7575
// Inserter.ColumnMapping is used for mapping the CAST expression to Column 'Location'.
76-
String textToGeographyCastExpression = "CAST(" + escapeName("Location_as_text") + " AS GEOGRAPHY)";
76+
String textToGeographyCastExpression = "CAST(" + escapeName("Location_as_text") + " AS TABLEAU.TABGEOGRAPHY)";
7777
List<Inserter.ColumnMapping> columnMappings = new ArrayList<Inserter.ColumnMapping>();
7878
columnMappings.add(new Inserter.ColumnMapping("Name"));
7979
columnMappings.add(new Inserter.ColumnMapping("Location", textToGeographyCastExpression));

0 commit comments

Comments
 (0)