|
@@ -45,7 +45,27 @@ void check_where_clause(const vector<string> table_names, const json& j) {
|
|
|
fmt::format("column `{}` not exists in `{}`\n",
|
|
|
select_column_get_name(curr_branch),
|
|
|
fmt::join(table_names, ", ")));
|
|
|
+ } else {
|
|
|
+ if (curr_branch_name == "right" &&
|
|
|
+ op_type_of(j) == OpType::OP_COMPARE) {
|
|
|
+ // 如果左右分支都是普通列, 并且当前节点操作符是比较,
|
|
|
+ // 那么应当判断类型是否一致 如果能走到right,
|
|
|
+ // 说明left也是普通列
|
|
|
+ let curr_left_col_def =
|
|
|
+ tables.get_select_column_define(table_names, left);
|
|
|
+ if (curr_left_col_def.value().data_type !=
|
|
|
+ col_def.value().data_type) {
|
|
|
+ throw std::runtime_error(
|
|
|
+ fmt::format("column `{}` type is `{}`, but `{}` "
|
|
|
+ "type is `{}`, cannot `{}` \n",
|
|
|
+ select_column_get_name(left),
|
|
|
+ curr_left_col_def.value().data_type,
|
|
|
+ select_column_get_name(curr_branch),
|
|
|
+ col_def.value().data_type, j["type"]));
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
} else {
|
|
|
check_where_clause(table_names, curr_branch);
|
|
|
}
|