Remove garbage from code

This commit is contained in:
Alexey Milovidov 2022-02-12 22:49:01 +03:00
parent ccfc41bce5
commit fee7ff1ddf

View File

@ -1,9 +1,6 @@
#include <type_traits>
#include <base/scope_guard.h>
#include <Core/Defines.h>
#include <DataTypes/DataTypeFactory.h>
#include <IO/ReadHelpers.h>
#include <IO/WriteHelpers.h>
#include <IO/ReadWriteBufferFromHTTP.h>
#include <IO/ConnectionTimeoutsContext.h>
#include <Interpreters/evaluateConstantExpression.h>
@ -16,10 +13,9 @@
#include <TableFunctions/TableFunctionFactory.h>
#include <Poco/Net/HTTPRequest.h>
#include <Common/Exception.h>
#include <Common/typeid_cast.h>
#include <Poco/NumberFormatter.h>
#include "registerTableFunctions.h"
namespace DB
{
namespace ErrorCodes
@ -33,13 +29,12 @@ void ITableFunctionXDBC::parseArguments(const ASTPtr & ast_function, ContextPtr
const auto & args_func = ast_function->as<ASTFunction &>();
if (!args_func.arguments)
throw Exception("Table function '" + getName() + "' must have arguments.", ErrorCodes::LOGICAL_ERROR);
throw Exception(ErrorCodes::LOGICAL_ERROR, "Table function '{}' must have arguments.", getName());
ASTs & args = args_func.arguments->children;
if (args.size() != 2 && args.size() != 3)
throw Exception("Table function '" + getName() + "' requires 2 or 3 arguments: " + getName() + "('DSN', table) or " + getName()
+ "('DSN', schema, table)",
ErrorCodes::NUMBER_OF_ARGUMENTS_DOESNT_MATCH);
throw Exception(ErrorCodes::NUMBER_OF_ARGUMENTS_DOESNT_MATCH,
"Table function '{0}' requires 2 or 3 arguments: {0}('DSN', table) or {0}('DSN', schema, table)", getName());
for (auto & arg : args)
arg = evaluateConstantExpressionOrIdentifierAsLiteral(arg, context);
@ -61,7 +56,6 @@ void ITableFunctionXDBC::startBridgeIfNot(ContextPtr context) const
{
if (!helper)
{
/// Have to const_cast, because bridges store their commands inside context
helper = createBridgeHelper(context, context->getSettingsRef().http_receive_timeout.value, connection_string);
helper->startBridgeSync();
}
@ -71,16 +65,15 @@ ColumnsDescription ITableFunctionXDBC::getActualTableStructure(ContextPtr contex
{
startBridgeIfNot(context);
/* Infer external table structure */
/// Infer external table structure.
Poco::URI columns_info_uri = helper->getColumnsInfoURI();
columns_info_uri.addQueryParameter("connection_string", connection_string);
if (!schema_name.empty())
columns_info_uri.addQueryParameter("schema", schema_name);
columns_info_uri.addQueryParameter("table", remote_table_name);
const auto use_nulls = context->getSettingsRef().external_table_functions_use_nulls;
columns_info_uri.addQueryParameter("external_table_functions_use_nulls",
Poco::NumberFormatter::format(use_nulls));
bool use_nulls = context->getSettingsRef().external_table_functions_use_nulls;
columns_info_uri.addQueryParameter("external_table_functions_use_nulls", toString(use_nulls));
Poco::Net::HTTPBasicCredentials credentials{};
ReadWriteBufferFromHTTP buf(columns_info_uri, Poco::Net::HTTPRequest::HTTP_POST, {}, ConnectionTimeouts::getHTTPTimeouts(context), credentials);