| 12 | namespace binder { |
| 13 | |
| 14 | void 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 | |
| 33 | void validateIsAllUnionOrUnionAll(const BoundRegularQuery& regularQuery) { |
| 34 | auto unionAllExpressionCounter = 0u; |
no test coverage detected