mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-22 07:31:57 +00:00
Backport #68824 to 24.8: Fix resolving dynamic subcolumns from subqueries in analyzer
This commit is contained in:
parent
b8fca1c6c1
commit
10ab65fc49
@ -692,7 +692,7 @@ QueryTreeNodePtr IdentifierResolver::tryResolveIdentifierFromStorage(
|
||||
result_column_node = it->second;
|
||||
}
|
||||
/// Check if it's a dynamic subcolumn
|
||||
else
|
||||
else if (table_expression_data.supports_subcolumns)
|
||||
{
|
||||
auto [column_name, dynamic_subcolumn_name] = Nested::splitName(identifier_full_name);
|
||||
auto jt = table_expression_data.column_name_to_column_node.find(column_name);
|
||||
|
@ -4379,7 +4379,10 @@ void QueryAnalyzer::initializeTableExpressionData(const QueryTreeNodePtr & table
|
||||
|
||||
auto get_column_options = GetColumnsOptions(GetColumnsOptions::All).withExtendedObjects().withVirtuals();
|
||||
if (storage_snapshot->storage.supportsSubcolumns())
|
||||
{
|
||||
get_column_options.withSubcolumns();
|
||||
table_expression_data.supports_subcolumns = true;
|
||||
}
|
||||
|
||||
auto column_names_and_types = storage_snapshot->getColumns(get_column_options);
|
||||
table_expression_data.column_names_and_types = NamesAndTypes(column_names_and_types.begin(), column_names_and_types.end());
|
||||
|
@ -36,6 +36,7 @@ struct AnalysisTableExpressionData
|
||||
std::string database_name;
|
||||
std::string table_name;
|
||||
bool should_qualify_columns = true;
|
||||
bool supports_subcolumns = false;
|
||||
NamesAndTypes column_names_and_types;
|
||||
ColumnNameToColumnNodeMap column_name_to_column_node;
|
||||
std::unordered_set<std::string> subcolumn_names; /// Subset columns that are subcolumns of other columns
|
||||
|
@ -0,0 +1,4 @@
|
||||
str
|
||||
42
|
||||
42
|
||||
42
|
@ -0,0 +1,9 @@
|
||||
set allow_experimental_dynamic_type=1;
|
||||
set allow_experimental_json_type=1;
|
||||
set allow_experimental_analyzer=1;
|
||||
|
||||
select d.String from (select 'str'::Dynamic as d);
|
||||
select json.a from (select '{"a" : 42}'::JSON as json);
|
||||
select json.a from (select '{"a" : 42}'::JSON(a UInt32) as json);
|
||||
select json.a.:Int64 from (select materialize('{"a" : 42}')::JSON as json);
|
||||
|
Loading…
Reference in New Issue
Block a user