Simplify bridges

This commit is contained in:
Alexey Milovidov 2024-03-09 08:42:33 +01:00
parent 1c44f3d091
commit 47b308d234
5 changed files with 16 additions and 43 deletions

View File

@ -1,6 +1,5 @@
#include "LibraryBridgeHandlers.h" #include "LibraryBridgeHandlers.h"
#include "CatBoostLibraryHandler.h"
#include "CatBoostLibraryHandlerFactory.h" #include "CatBoostLibraryHandlerFactory.h"
#include "Common/ProfileEvents.h" #include "Common/ProfileEvents.h"
#include "ExternalDictionaryLibraryHandler.h" #include "ExternalDictionaryLibraryHandler.h"
@ -11,10 +10,8 @@
#include <IO/ReadHelpers.h> #include <IO/ReadHelpers.h>
#include <Common/BridgeProtocolVersion.h> #include <Common/BridgeProtocolVersion.h>
#include <IO/WriteHelpers.h> #include <IO/WriteHelpers.h>
#include <Poco/Net/HTMLForm.h>
#include <Poco/Net/HTTPServerRequest.h> #include <Poco/Net/HTTPServerRequest.h>
#include <Poco/Net/HTTPServerResponse.h> #include <Poco/Net/HTTPServerResponse.h>
#include <Poco/ThreadPool.h>
#include <Processors/Executors/CompletedPipelineExecutor.h> #include <Processors/Executors/CompletedPipelineExecutor.h>
#include <Processors/Executors/PullingPipelineExecutor.h> #include <Processors/Executors/PullingPipelineExecutor.h>
#include <Processors/Formats/IInputFormat.h> #include <Processors/Formats/IInputFormat.h>

View File

@ -8,13 +8,11 @@
#include <IO/ReadHelpers.h> #include <IO/ReadHelpers.h>
#include <IO/WriteHelpers.h> #include <IO/WriteHelpers.h>
#include <Parsers/ParserQueryWithOutput.h> #include <Parsers/ParserQueryWithOutput.h>
#include <Parsers/parseQuery.h>
#include <Server/HTTP/HTMLForm.h> #include <Server/HTTP/HTMLForm.h>
#include <Poco/Net/HTTPServerRequest.h> #include <Poco/Net/HTTPServerRequest.h>
#include <Poco/Net/HTTPServerResponse.h> #include <Poco/Net/HTTPServerResponse.h>
#include <Poco/NumberParser.h> #include <Poco/NumberParser.h>
#include <Common/logger_useful.h> #include <Common/logger_useful.h>
#include <base/scope_guard.h>
#include <Common/BridgeProtocolVersion.h> #include <Common/BridgeProtocolVersion.h>
#include <Common/quoteString.h> #include <Common/quoteString.h>
#include "getIdentifierQuote.h" #include "getIdentifierQuote.h"

View File

@ -7,13 +7,10 @@
#include <Server/HTTP/WriteBufferFromHTTPServerResponse.h> #include <Server/HTTP/WriteBufferFromHTTPServerResponse.h>
#include <IO/ReadHelpers.h> #include <IO/ReadHelpers.h>
#include <IO/WriteHelpers.h> #include <IO/WriteHelpers.h>
#include <Parsers/ParserQueryWithOutput.h>
#include <Parsers/parseQuery.h>
#include <Poco/Net/HTTPServerRequest.h> #include <Poco/Net/HTTPServerRequest.h>
#include <Poco/Net/HTTPServerResponse.h> #include <Poco/Net/HTTPServerResponse.h>
#include <Common/BridgeProtocolVersion.h> #include <Common/BridgeProtocolVersion.h>
#include <Common/logger_useful.h> #include <Common/logger_useful.h>
#include <base/scope_guard.h>
#include "getIdentifierQuote.h" #include "getIdentifierQuote.h"
#include "validateODBCConnectionString.h" #include "validateODBCConnectionString.h"
#include "ODBCPooledConnectionFactory.h" #include "ODBCPooledConnectionFactory.h"

View File

@ -3,12 +3,8 @@
#include <IO/ReadBufferFromString.h> #include <IO/ReadBufferFromString.h>
#include <DataTypes/DataTypeNullable.h> #include <DataTypes/DataTypeNullable.h>
#include <DataTypes/DataTypeDateTime64.h> #include <DataTypes/DataTypeDateTime64.h>
#include <Columns/ColumnNullable.h>
#include <Columns/ColumnString.h>
#include <Columns/ColumnsNumber.h>
#include <Common/assert_cast.h> #include <Common/assert_cast.h>
#include <IO/ReadHelpers.h> #include <IO/ReadHelpers.h>
#include <IO/WriteHelpers.h>
#include <Common/logger_useful.h> #include <Common/logger_useful.h>
@ -54,21 +50,7 @@ Chunk ODBCSource::generate()
const auto & sample = description.sample_block.getByPosition(idx); const auto & sample = description.sample_block.getByPosition(idx);
if (!result.is_null(idx)) if (!result.is_null(idx))
{ insertValue(*columns[idx], sample.type, description.types[idx].first, result, idx);
bool is_nullable = description.types[idx].second;
if (is_nullable)
{
ColumnNullable & column_nullable = assert_cast<ColumnNullable &>(*columns[idx]);
const auto & data_type = assert_cast<const DataTypeNullable &>(*sample.type);
insertValue(column_nullable.getNestedColumn(), data_type.getNestedType(), description.types[idx].first, result, idx);
column_nullable.getNullMapData().emplace_back(0);
}
else
{
insertValue(*columns[idx], sample.type, description.types[idx].first, result, idx);
}
}
else else
insertDefaultValue(*columns[idx], *sample.column); insertDefaultValue(*columns[idx], *sample.column);
} }
@ -87,49 +69,49 @@ void ODBCSource::insertValue(
switch (type) switch (type)
{ {
case ValueType::vtUInt8: case ValueType::vtUInt8:
assert_cast<ColumnUInt8 &>(column).insertValue(row.get<uint16_t>(idx)); column.insert(row.get<uint16_t>(idx));
break; break;
case ValueType::vtUInt16: case ValueType::vtUInt16:
assert_cast<ColumnUInt16 &>(column).insertValue(row.get<uint16_t>(idx)); column.insert(row.get<uint16_t>(idx));
break; break;
case ValueType::vtUInt32: case ValueType::vtUInt32:
assert_cast<ColumnUInt32 &>(column).insertValue(row.get<uint32_t>(idx)); column.insert(row.get<uint32_t>(idx));
break; break;
case ValueType::vtUInt64: case ValueType::vtUInt64:
assert_cast<ColumnUInt64 &>(column).insertValue(row.get<uint64_t>(idx)); column.insert(row.get<uint64_t>(idx));
break; break;
case ValueType::vtInt8: case ValueType::vtInt8:
assert_cast<ColumnInt8 &>(column).insertValue(row.get<int16_t>(idx)); column.insert(row.get<int16_t>(idx));
break; break;
case ValueType::vtInt16: case ValueType::vtInt16:
assert_cast<ColumnInt16 &>(column).insertValue(row.get<int16_t>(idx)); column.insert(row.get<int16_t>(idx));
break; break;
case ValueType::vtInt32: case ValueType::vtInt32:
assert_cast<ColumnInt32 &>(column).insertValue(row.get<int32_t>(idx)); column.insert(row.get<int32_t>(idx));
break; break;
case ValueType::vtInt64: case ValueType::vtInt64:
assert_cast<ColumnInt64 &>(column).insertValue(row.get<int64_t>(idx)); column.insert(row.get<int64_t>(idx));
break; break;
case ValueType::vtFloat32: case ValueType::vtFloat32:
assert_cast<ColumnFloat32 &>(column).insertValue(row.get<float>(idx)); column.insert(row.get<float>(idx));
break; break;
case ValueType::vtFloat64: case ValueType::vtFloat64:
assert_cast<ColumnFloat64 &>(column).insertValue(row.get<double>(idx)); column.insert(row.get<double>(idx));
break; break;
case ValueType::vtFixedString:[[fallthrough]]; case ValueType::vtFixedString:[[fallthrough]];
case ValueType::vtEnum8: case ValueType::vtEnum8:
case ValueType::vtEnum16: case ValueType::vtEnum16:
case ValueType::vtString: case ValueType::vtString:
assert_cast<ColumnString &>(column).insert(row.get<std::string>(idx)); column.insert(row.get<std::string>(idx));
break; break;
case ValueType::vtUUID: case ValueType::vtUUID:
{ {
auto value = row.get<std::string>(idx); auto value = row.get<std::string>(idx);
assert_cast<ColumnUInt128 &>(column).insert(parse<UUID>(value.data(), value.size())); column.insert(parse<UUID>(value.data(), value.size()));
break; break;
} }
case ValueType::vtDate: case ValueType::vtDate:
assert_cast<ColumnUInt16 &>(column).insertValue(UInt16{LocalDate{row.get<std::string>(idx)}.getDayNum()}); column.insert(UInt16{LocalDate{row.get<std::string>(idx)}.getDayNum()});
break; break;
case ValueType::vtDateTime: case ValueType::vtDateTime:
{ {
@ -139,7 +121,7 @@ void ODBCSource::insertValue(
readDateTimeText(time, in, assert_cast<const DataTypeDateTime *>(data_type.get())->getTimeZone()); readDateTimeText(time, in, assert_cast<const DataTypeDateTime *>(data_type.get())->getTimeZone());
if (time < 0) if (time < 0)
time = 0; time = 0;
assert_cast<ColumnUInt32 &>(column).insertValue(static_cast<UInt32>(time)); column.insert(static_cast<UInt32>(time));
break; break;
} }
case ValueType::vtDateTime64: case ValueType::vtDateTime64:
@ -149,7 +131,7 @@ void ODBCSource::insertValue(
DateTime64 time = 0; DateTime64 time = 0;
const auto * datetime_type = assert_cast<const DataTypeDateTime64 *>(data_type.get()); const auto * datetime_type = assert_cast<const DataTypeDateTime64 *>(data_type.get());
readDateTime64Text(time, datetime_type->getScale(), in, datetime_type->getTimeZone()); readDateTime64Text(time, datetime_type->getScale(), in, datetime_type->getTimeZone());
assert_cast<DataTypeDateTime64::ColumnType &>(column).insertValue(time); column.insert(time);
break; break;
} }
case ValueType::vtDecimal32: [[fallthrough]]; case ValueType::vtDecimal32: [[fallthrough]];

View File

@ -1,6 +1,5 @@
#include "ODBCBlockOutputStream.h" #include "ODBCBlockOutputStream.h"
#include <Common/logger_useful.h>
#include <IO/WriteBufferFromString.h> #include <IO/WriteBufferFromString.h>
#include <Interpreters/Context.h> #include <Interpreters/Context.h>
#include <Processors/Formats/IOutputFormat.h> #include <Processors/Formats/IOutputFormat.h>