From a2916c23a55aee1d210898b0ded23e4c61617320 Mon Sep 17 00:00:00 2001 From: bobrovskij artemij Date: Wed, 6 May 2020 02:42:44 +0300 Subject: [PATCH] fixes/style --- .../odbc-bridge/ODBCBlockOutputStream.cpp | 29 +++++++++++-------- programs/odbc-bridge/ODBCBlockOutputStream.h | 6 ++-- src/Storages/StorageXDBC.cpp | 5 ++-- 3 files changed, 24 insertions(+), 16 deletions(-) diff --git a/programs/odbc-bridge/ODBCBlockOutputStream.cpp b/programs/odbc-bridge/ODBCBlockOutputStream.cpp index 72cf2e509ce..148f38087cd 100644 --- a/programs/odbc-bridge/ODBCBlockOutputStream.cpp +++ b/programs/odbc-bridge/ODBCBlockOutputStream.cpp @@ -3,17 +3,20 @@ #include #include #include +#include namespace DB { -namespace { +namespace +{ using ValueType = ExternalResultDescription::ValueType; std::string commaSeparateColumnNames(const ColumnsWithTypeAndName & columns) { std::string result = "("; - for (size_t i = 0; i < columns.size(); ++i) { + for (size_t i = 0; i < columns.size(); ++i) + { if (i > 0) result += ","; result += columns[i].name; @@ -24,7 +27,8 @@ namespace { std::string getQuestionMarks(size_t n) { std::string result = "("; - for (size_t i = 0; i < n; ++i) { + for (size_t i = 0; i < n; ++i) + { if (i > 0) result += ","; result += "?"; @@ -34,21 +38,22 @@ namespace { Poco::Dynamic::Var getVarFromField(const Field & field, const ValueType type) { - switch (type) { + switch (type) + { case ValueType::vtUInt8: - return Poco::Dynamic::Var(static_cast(field.get())).convert(); + return Poco::Dynamic::Var(static_cast(field.get())).convert(); case ValueType::vtUInt16: - return Poco::Dynamic::Var(static_cast(field.get())).convert(); + return Poco::Dynamic::Var(static_cast(field.get())).convert(); case ValueType::vtUInt32: - return Poco::Dynamic::Var(static_cast(field.get())).convert(); + return Poco::Dynamic::Var(static_cast(field.get())).convert(); case ValueType::vtUInt64: return Poco::Dynamic::Var(field.get()).convert(); case ValueType::vtInt8: - return Poco::Dynamic::Var(static_cast(field.get())).convert(); + return Poco::Dynamic::Var(static_cast(field.get())).convert(); case ValueType::vtInt16: - return Poco::Dynamic::Var(static_cast(field.get())).convert(); + return Poco::Dynamic::Var(static_cast(field.get())).convert(); case ValueType::vtInt32: - return Poco::Dynamic::Var(static_cast(field.get())).convert(); + return Poco::Dynamic::Var(static_cast(field.get())).convert(); case ValueType::vtInt64: return Poco::Dynamic::Var(field.get()).convert(); case ValueType::vtFloat32: @@ -58,9 +63,9 @@ namespace { case ValueType::vtString: return Poco::Dynamic::Var(field.get()).convert(); case ValueType::vtDate: - return Poco::Dynamic::Var(LocalDate(DayNum(field.get())).toString()).convert(); + return Poco::Dynamic::Var(LocalDate(DayNum(field.get())).toString()).convert(); case ValueType::vtDateTime: - return Poco::Dynamic::Var(LocalDate(time_t(field.get())).toString()).convert(); + return Poco::Dynamic::Var(std::to_string(LocalDateTime(time_t(field.get())))).convert(); case ValueType::vtUUID: return Poco::Dynamic::Var(UUID(field.get()).toUnderType().toHexString()).convert(); } diff --git a/programs/odbc-bridge/ODBCBlockOutputStream.h b/programs/odbc-bridge/ODBCBlockOutputStream.h index 5de283f1c8b..544f19682f4 100644 --- a/programs/odbc-bridge/ODBCBlockOutputStream.h +++ b/programs/odbc-bridge/ODBCBlockOutputStream.h @@ -5,8 +5,10 @@ #include #include -namespace DB{ -class ODBCBlockOutputStream : public IBlockOutputStream { +namespace DB +{ +class ODBCBlockOutputStream : public IBlockOutputStream +{ public: ODBCBlockOutputStream(Poco::Data::Session && session_, const std::string & remote_database_name_, const std::string & remote_table_name_, const Block & sample_block_); diff --git a/src/Storages/StorageXDBC.cpp b/src/Storages/StorageXDBC.cpp index e4db7aa1fd9..a6e26b7482d 100644 --- a/src/Storages/StorageXDBC.cpp +++ b/src/Storages/StorageXDBC.cpp @@ -95,10 +95,10 @@ Pipes StorageXDBC::read(const Names & column_names, return IStorageURLBase::read(column_names, query_info, context, processed_stage, max_block_size, num_streams); } -BlockOutputStreamPtr StorageXDBC::write(const ASTPtr & /*query*/, const Context & context) { +BlockOutputStreamPtr StorageXDBC::write(const ASTPtr & /*query*/, const Context & context) +{ bridge_helper->startBridgeSync(); - // some copypaste NamesAndTypesList cols; Poco::URI request_uri = uri; request_uri.setPath("/write"); @@ -112,6 +112,7 @@ BlockOutputStreamPtr StorageXDBC::write(const ASTPtr & /*query*/, const Context request_uri.addQueryParameter(param, value); request_uri.addQueryParameter("db_name", remote_database_name); request_uri.addQueryParameter("table_name", remote_table_name); + request_uri.addQueryParameter("format_name", format_name); return std::make_shared( request_uri, format_name, getSampleBlock(), context,