Skip to content

Commit 27c635b

Browse files
committed
Support type="double" for columns,
It already supports `real`, which is single precision floating point in PostgreSQL. This patch adds `type = "double"` for PostgreSQL `double precision` columns
1 parent 5be21e7 commit 27c635b

3 files changed

Lines changed: 14 additions & 0 deletions

File tree

src/flex-table-column.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ std::vector<column_type_lookup> const COLUMN_TYPES = {
4545
{"int8", table_column_type::int8},
4646
{"bigint", table_column_type::int8},
4747
{"real", table_column_type::real},
48+
{"double", table_column_type::double_},
4849
{"timestamp", table_column_type::timestamp},
4950
{"timestamptz", table_column_type::timestamptz},
5051
{"hstore", table_column_type::hstore},
@@ -146,6 +147,8 @@ std::string flex_table_column_t::sql_type_name() const
146147
return "int8";
147148
case table_column_type::real:
148149
return "real";
150+
case table_column_type::double_:
151+
return "double precision";
149152
case table_column_type::timestamp:
150153
return "timestamp";
151154
case table_column_type::timestamptz:

src/flex-table-column.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ enum class table_column_type : uint8_t
3232
int8,
3333

3434
real,
35+
double_,
3536

3637
timestamp,
3738
timestamptz,

src/flex-write.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,16 @@ void flex_write_column(lua_State *lua_state, geometry_cache_t *geom_cache,
359359
throw fmt_error("Invalid type '{}' for real column.",
360360
lua_typename(lua_state, ltype));
361361
}
362+
} else if (column.type() == table_column_type::double_) {
363+
if (ltype == LUA_TNUMBER) {
364+
copy_mgr->add_column(lua_tonumber(lua_state, -1));
365+
} else if (ltype == LUA_TSTRING) {
366+
write_double(copy_mgr, column,
367+
lua_tolstring(lua_state, -1, nullptr));
368+
} else {
369+
throw fmt_error("Invalid type '{}' for double column.",
370+
lua_typename(lua_state, ltype));
371+
}
362372
} else if (column.type() == table_column_type::timestamp) {
363373
if (ltype == LUA_TNUMBER) {
364374
auto const ts = osmium::Timestamp{lua_tointeger(lua_state, -1)};

0 commit comments

Comments
 (0)