mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-25 17:12:03 +00:00
Merge pull request #17857 from fastio/feature_hints_for_column_names
hints for column names
This commit is contained in:
commit
dae1e9ba31
@ -635,14 +635,24 @@ void TreeRewriterResult::collectUsedColumns(const ASTPtr & query, bool is_select
|
|||||||
for (const auto & name : columns_context.requiredColumns())
|
for (const auto & name : columns_context.requiredColumns())
|
||||||
ss << " '" << name << "'";
|
ss << " '" << name << "'";
|
||||||
|
|
||||||
if (!source_column_names.empty())
|
if (storage)
|
||||||
{
|
{
|
||||||
ss << ", source columns:";
|
ss << ", maybe you meant: ";
|
||||||
for (const auto & name : source_column_names)
|
for (const auto & name : columns_context.requiredColumns())
|
||||||
ss << " '" << name << "'";
|
{
|
||||||
|
auto hints = storage->getHints(name);
|
||||||
|
if (!hints.empty())
|
||||||
|
ss << " '" << toString(hints) << "'";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (!source_column_names.empty())
|
||||||
|
for (const auto & name : columns_context.requiredColumns())
|
||||||
|
ss << " '" << name << "'";
|
||||||
else
|
else
|
||||||
ss << ", no source columns";
|
ss << ", no source columns";
|
||||||
|
}
|
||||||
|
|
||||||
if (columns_context.has_table_join)
|
if (columns_context.has_table_join)
|
||||||
{
|
{
|
||||||
|
@ -17,7 +17,6 @@
|
|||||||
|
|
||||||
namespace DB
|
namespace DB
|
||||||
{
|
{
|
||||||
|
|
||||||
namespace ErrorCodes
|
namespace ErrorCodes
|
||||||
{
|
{
|
||||||
extern const int TABLE_IS_DROPPED;
|
extern const int TABLE_IS_DROPPED;
|
||||||
@ -39,8 +38,9 @@ RWLockImpl::LockHolder IStorage::tryLockTimed(
|
|||||||
{
|
{
|
||||||
const String type_str = type == RWLockImpl::Type::Read ? "READ" : "WRITE";
|
const String type_str = type == RWLockImpl::Type::Read ? "READ" : "WRITE";
|
||||||
throw Exception(
|
throw Exception(
|
||||||
type_str + " locking attempt on \"" + getStorageID().getFullTableName() +
|
type_str + " locking attempt on \"" + getStorageID().getFullTableName() + "\" has timed out! ("
|
||||||
"\" has timed out! (" + std::to_string(acquire_timeout.count()) + "ms) "
|
+ std::to_string(acquire_timeout.count())
|
||||||
|
+ "ms) "
|
||||||
"Possible deadlock avoided. Client should retry.",
|
"Possible deadlock avoided. Client should retry.",
|
||||||
ErrorCodes::DEADLOCK_AVOIDED);
|
ErrorCodes::DEADLOCK_AVOIDED);
|
||||||
}
|
}
|
||||||
@ -117,15 +117,12 @@ void IStorage::read(
|
|||||||
}
|
}
|
||||||
|
|
||||||
Pipe IStorage::alterPartition(
|
Pipe IStorage::alterPartition(
|
||||||
const StorageMetadataPtr & /* metadata_snapshot */,
|
const StorageMetadataPtr & /* metadata_snapshot */, const PartitionCommands & /* commands */, const Context & /* context */)
|
||||||
const PartitionCommands & /* commands */,
|
|
||||||
const Context & /* context */)
|
|
||||||
{
|
{
|
||||||
throw Exception("Partition operations are not supported by storage " + getName(), ErrorCodes::NOT_IMPLEMENTED);
|
throw Exception("Partition operations are not supported by storage " + getName(), ErrorCodes::NOT_IMPLEMENTED);
|
||||||
}
|
}
|
||||||
|
|
||||||
void IStorage::alter(
|
void IStorage::alter(const AlterCommands & params, const Context & context, TableLockHolder &)
|
||||||
const AlterCommands & params, const Context & context, TableLockHolder &)
|
|
||||||
{
|
{
|
||||||
auto table_id = getStorageID();
|
auto table_id = getStorageID();
|
||||||
StorageInMemoryMetadata new_metadata = getInMemoryMetadata();
|
StorageInMemoryMetadata new_metadata = getInMemoryMetadata();
|
||||||
@ -146,7 +143,8 @@ void IStorage::checkAlterIsPossible(const AlterCommands & commands, const Settin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void IStorage::checkAlterPartitionIsPossible(const PartitionCommands & /*commands*/, const StorageMetadataPtr & /*metadata_snapshot*/, const Settings & /*settings*/) const
|
void IStorage::checkAlterPartitionIsPossible(
|
||||||
|
const PartitionCommands & /*commands*/, const StorageMetadataPtr & /*metadata_snapshot*/, const Settings & /*settings*/) const
|
||||||
{
|
{
|
||||||
throw Exception("Table engine " + getName() + " doesn't support partitioning", ErrorCodes::NOT_IMPLEMENTED);
|
throw Exception("Table engine " + getName() + " doesn't support partitioning", ErrorCodes::NOT_IMPLEMENTED);
|
||||||
}
|
}
|
||||||
@ -168,4 +166,13 @@ NamesAndTypesList IStorage::getVirtuals() const
|
|||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Names IStorage::getAllRegisteredNames() const
|
||||||
|
{
|
||||||
|
Names result;
|
||||||
|
auto getter = [](const auto & column) { return column.name; };
|
||||||
|
const NamesAndTypesList & available_columns = getInMemoryMetadata().getColumns().getAllPhysical();
|
||||||
|
std::transform(available_columns.begin(), available_columns.end(), std::back_inserter(result), getter);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -78,7 +78,7 @@ struct ColumnSize
|
|||||||
* - data storage structure (compression, etc.)
|
* - data storage structure (compression, etc.)
|
||||||
* - concurrent access to data (locks, etc.)
|
* - concurrent access to data (locks, etc.)
|
||||||
*/
|
*/
|
||||||
class IStorage : public std::enable_shared_from_this<IStorage>, public TypePromotion<IStorage>
|
class IStorage : public std::enable_shared_from_this<IStorage>, public TypePromotion<IStorage>, public IHints<1, IStorage>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
IStorage() = delete;
|
IStorage() = delete;
|
||||||
@ -87,7 +87,6 @@ public:
|
|||||||
: storage_id(std::move(storage_id_))
|
: storage_id(std::move(storage_id_))
|
||||||
, metadata(std::make_unique<StorageInMemoryMetadata>()) {} //-V730
|
, metadata(std::make_unique<StorageInMemoryMetadata>()) {} //-V730
|
||||||
|
|
||||||
virtual ~IStorage() = default;
|
|
||||||
IStorage(const IStorage &) = delete;
|
IStorage(const IStorage &) = delete;
|
||||||
IStorage & operator=(const IStorage &) = delete;
|
IStorage & operator=(const IStorage &) = delete;
|
||||||
|
|
||||||
@ -169,6 +168,7 @@ public:
|
|||||||
/// By default return empty list of columns.
|
/// By default return empty list of columns.
|
||||||
virtual NamesAndTypesList getVirtuals() const;
|
virtual NamesAndTypesList getVirtuals() const;
|
||||||
|
|
||||||
|
Names getAllRegisteredNames() const override;
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
/// Returns whether the column is virtual - by default all columns are real.
|
/// Returns whether the column is virtual - by default all columns are real.
|
||||||
|
Loading…
Reference in New Issue
Block a user