mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-27 01:51:59 +00:00
Merge pull request #54635 from Avogar/cluster-func-names-with-spaces
Fix schema inference for *Cluster functions for column names with spaces
This commit is contained in:
commit
5fb8e46967
@ -240,4 +240,19 @@ size_t NamesAndTypesList::getPosByName(const std::string &name) const noexcept
|
||||
return pos;
|
||||
}
|
||||
|
||||
String NamesAndTypesList::toNamesAndTypesDescription() const
|
||||
{
|
||||
WriteBufferFromOwnString buf;
|
||||
bool first = true;
|
||||
for (const auto & name_and_type : *this)
|
||||
{
|
||||
if (!std::exchange(first, false))
|
||||
writeCString(", ", buf);
|
||||
writeBackQuotedString(name_and_type.name, buf);
|
||||
writeChar(' ', buf);
|
||||
writeString(name_and_type.type->getName(), buf);
|
||||
}
|
||||
return buf.str();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -122,6 +122,8 @@ public:
|
||||
|
||||
/// Try to get column position by name, returns number of columns if column isn't found
|
||||
size_t getPosByName(const std::string & name) const noexcept;
|
||||
|
||||
String toNamesAndTypesDescription() const;
|
||||
};
|
||||
|
||||
using NamesAndTypesLists = std::vector<NamesAndTypesList>;
|
||||
|
@ -105,7 +105,7 @@ ASTPtr DatabaseDictionary::getCreateTableQueryImpl(const String & table_name, Co
|
||||
|
||||
auto names_and_types = StorageDictionary::getNamesAndTypes(ExternalDictionariesLoader::getDictionaryStructure(*load_result.config));
|
||||
buffer << "CREATE TABLE " << backQuoteIfNeed(getDatabaseName()) << '.' << backQuoteIfNeed(table_name) << " (";
|
||||
buffer << StorageDictionary::generateNamesAndTypesDescription(names_and_types);
|
||||
buffer << names_and_types.toNamesAndTypesDescription();
|
||||
buffer << ") Engine = Dictionary(" << backQuoteIfNeed(table_name) << ")";
|
||||
}
|
||||
|
||||
|
@ -77,7 +77,7 @@ Pipe IStorageCluster::read(
|
||||
const bool add_agg_info = processed_stage == QueryProcessingStage::WithMergeableState;
|
||||
|
||||
if (!structure_argument_was_provided)
|
||||
addColumnsStructureToQuery(query_to_send, StorageDictionary::generateNamesAndTypesDescription(storage_snapshot->metadata->getColumns().getAll()), context);
|
||||
addColumnsStructureToQuery(query_to_send, storage_snapshot->metadata->getColumns().getAll().toNamesAndTypesDescription(), context);
|
||||
|
||||
RestoreQualifiedNamesVisitor::Data data;
|
||||
data.distributed_table = DatabaseAndTableWithAlias(*getTableExpression(query_info.query->as<ASTSelectQuery &>(), 0));
|
||||
|
@ -39,7 +39,7 @@ namespace
|
||||
{
|
||||
throw Exception(ErrorCodes::THERE_IS_NO_COLUMN, "Not found column {} {} in dictionary {}. There are only columns {}",
|
||||
column.name, column.type->getName(), backQuote(dictionary_name),
|
||||
StorageDictionary::generateNamesAndTypesDescription(dictionary_names_and_types));
|
||||
dictionary_names_and_types.toNamesAndTypesDescription());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -80,20 +80,6 @@ NamesAndTypesList StorageDictionary::getNamesAndTypes(const DictionaryStructure
|
||||
return dictionary_names_and_types;
|
||||
}
|
||||
|
||||
|
||||
String StorageDictionary::generateNamesAndTypesDescription(const NamesAndTypesList & list)
|
||||
{
|
||||
WriteBufferFromOwnString ss;
|
||||
bool first = true;
|
||||
for (const auto & name_and_type : list)
|
||||
{
|
||||
if (!std::exchange(first, false))
|
||||
ss << ", ";
|
||||
ss << name_and_type.name << ' ' << name_and_type.type->getName();
|
||||
}
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
StorageDictionary::StorageDictionary(
|
||||
const StorageID & table_id_,
|
||||
const String & dictionary_name_,
|
||||
|
@ -81,7 +81,6 @@ public:
|
||||
std::shared_ptr<const IDictionary> getDictionary() const;
|
||||
|
||||
static NamesAndTypesList getNamesAndTypes(const DictionaryStructure & dictionary_structure);
|
||||
static String generateNamesAndTypesDescription(const NamesAndTypesList & list);
|
||||
|
||||
bool isDictionary() const override { return true; }
|
||||
void shutdown() override;
|
||||
|
@ -0,0 +1,2 @@
|
||||
a b c Nullable(UInt8)
|
||||
42
|
@ -0,0 +1,6 @@
|
||||
-- Tags: no-fasttest
|
||||
-- Tag no-fasttest: Depends on AWS
|
||||
|
||||
desc s3Cluster(test_cluster_one_shard_three_replicas_localhost, 'http://localhost:11111/test/02876.parquet');
|
||||
select * from s3Cluster(test_cluster_one_shard_three_replicas_localhost, 'http://localhost:11111/test/02876.parquet');
|
||||
|
BIN
tests/queries/0_stateless/data_minio/02876.parquet
Normal file
BIN
tests/queries/0_stateless/data_minio/02876.parquet
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user