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

Function arrayFunc

utils/db-generator/query_db_generator.cpp:725–772  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

723}
724
725FuncRet arrayFunc(DB::ASTPtr ch, std::map<std::string, Column> & columns)
726{
727 auto x = std::dynamic_pointer_cast<DB::ASTFunction>(ch);
728 if (x)
729 {
730 std::set<std::string> indents = {};
731 std::string value = "[";
732 ColumnType type_value = Type::i | Type::f | Type::d | Type::dt | Type::s;
733 bool no_indent = true;
734 for (const auto & arg : x->arguments->children)
735 {
736 auto ident = std::dynamic_pointer_cast<DB::ASTIdentifier>(arg);
737 if (ident)
738 {
739 no_indent = false;
740 indents.insert(ident->name());
741 }
742 auto literal = std::dynamic_pointer_cast<DB::ASTLiteral>(arg);
743 if (literal)
744 {
745 ColumnType type = type_cast(literal->value.getType());
746 if (type == Type::s || type == Type::d || type == Type::dt)
747 type = time_type(value);
748 type_value &= type;
749
750 if (value != "[")
751 value += ", ";
752 value += applyVisitor(DB::FieldVisitorToString(), literal->value);
753 }
754 }
755 for (const auto & indent : indents)
756 {
757 auto c = Column(indent);
758 c.type = type_value;
759 if (columns.count(indent))
760 columns[indent].merge(c);
761 else
762 columns[indent] = c;
763 }
764 value += ']';
765 FuncRet r(type_value, "");
766 r.is_array = true;
767 if (no_indent)
768 r.value = value;
769 return r;
770 }
771 return FuncRet();
772}
773FuncRet arithmeticFunc(DB::ASTPtr ch, std::map<std::string, Column> & columns)
774{
775 auto x = std::dynamic_pointer_cast<DB::ASTFunction>(ch);

Callers

nothing calls this directly

Calls 11

type_castFunction · 0.85
time_typeFunction · 0.85
applyVisitorFunction · 0.85
ColumnClass · 0.85
FuncRetClass · 0.85
insertMethod · 0.45
nameMethod · 0.45
getTypeMethod · 0.45
countMethod · 0.45
mergeMethod · 0.45

Tested by

no test coverage detected