MCPcopy Create free account
hub / github.com/ByConity/ByConity / getArrayJoinedColumns

Function getArrayJoinedColumns

src/Interpreters/TreeRewriter.cpp:655–700  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

653}
654
655void getArrayJoinedColumns(ASTPtr & query, TreeRewriterResult & result, const ASTSelectQuery * select_query,
656 const NamesAndTypesList & source_columns, const NameSet & source_columns_set)
657{
658 if (ASTPtr array_join_expression_list = select_query->arrayJoinExpressionList())
659 {
660 ArrayJoinedColumnsVisitor::Data visitor_data{result.aliases,
661 result.array_join_name_to_alias,
662 result.array_join_alias_to_name,
663 result.array_join_result_to_source};
664 ArrayJoinedColumnsVisitor(visitor_data).visit(query);
665
666 /// If the result of ARRAY JOIN is not used, it is necessary to ARRAY-JOIN any column,
667 /// to get the correct number of rows.
668 if (result.array_join_result_to_source.empty())
669 {
670 if (select_query->arrayJoinExpressionList()->children.empty())
671 throw DB::Exception("ARRAY JOIN requires an argument", ErrorCodes::NUMBER_OF_ARGUMENTS_DOESNT_MATCH);
672
673 ASTPtr expr = select_query->arrayJoinExpressionList()->children.at(0);
674 String source_name = expr->getColumnName();
675 String result_name = expr->getAliasOrColumnName();
676
677 /// This is an array.
678 if (!expr->as<ASTIdentifier>() || source_columns_set.count(source_name))
679 {
680 result.array_join_result_to_source[result_name] = source_name;
681 }
682 else /// This is a nested table.
683 {
684 bool found = false;
685 for (const auto & column : source_columns)
686 {
687 auto split = Nested::splitName(column.name);
688 if (split.first == source_name && !split.second.empty())
689 {
690 result.array_join_result_to_source[Nested::concatenateName(result_name, split.second)] = column.name;
691 found = true;
692 break;
693 }
694 }
695 if (!found)
696 throw Exception("No columns in nested table " + source_name, ErrorCodes::EMPTY_NESTED_TABLE);
697 }
698 }
699 }
700}
701
702void setJoinStrictness(ASTSelectQuery & select_query, JoinStrictness join_default_strictness, bool old_any, ASTTableJoin & out_table_join)
703{

Callers 1

analyzeSelectMethod · 0.85

Calls 10

splitNameFunction · 0.85
concatenateNameFunction · 0.85
ExceptionClass · 0.70
visitMethod · 0.45
emptyMethod · 0.45
atMethod · 0.45
getColumnNameMethod · 0.45
getAliasOrColumnNameMethod · 0.45
countMethod · 0.45

Tested by

no test coverage detected