MCPcopy Create free account
hub / github.com/LadybugDB/ladybug / validateUnionColumnsOfTheSameType

Function validateUnionColumnsOfTheSameType

src/binder/bind/bind_query.cpp:14–31  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

12namespace binder {
13
14void validateUnionColumnsOfTheSameType(
15 const std::vector<NormalizedSingleQuery>& normalizedSingleQueries) {
16 if (normalizedSingleQueries.size() <= 1) {
17 return;
18 }
19 auto columns = normalizedSingleQueries[0].getStatementResult()->getColumns();
20 for (auto i = 1u; i < normalizedSingleQueries.size(); i++) {
21 auto otherColumns = normalizedSingleQueries[i].getStatementResult()->getColumns();
22 if (columns.size() != otherColumns.size()) {
23 throw BinderException("The number of columns to union/union all must be the same.");
24 }
25 // Check whether the dataTypes in union expressions are exactly the same in each single
26 // query.
27 for (auto j = 0u; j < columns.size(); j++) {
28 ExpressionUtil::validateDataType(*otherColumns[j], columns[j]->getDataType());
29 }
30 }
31}
32
33void validateIsAllUnionOrUnionAll(const BoundRegularQuery& regularQuery) {
34 auto unionAllExpressionCounter = 0u;

Callers 1

bindQueryMethod · 0.85

Calls 4

getDataTypeMethod · 0.80
sizeMethod · 0.45
getColumnsMethod · 0.45
getStatementResultMethod · 0.45

Tested by

no test coverage detected