Skip to content

Commit

Permalink
Merge pull request #11902 from Tishj/copy_info_serialization_exception
Browse files Browse the repository at this point in the history
[Dev] Fix a SerializationException on CopyInfo
  • Loading branch information
Mytherin committed May 2, 2024
2 parents 6393d55 + b8d5613 commit 5b36f52
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
6 changes: 3 additions & 3 deletions extension/json/json_functions/copy_json.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,10 @@ static BoundStatement CopyToJSONPlan(Binder &binder, CopyStatement &stmt) {
auto select_stmt = make_uniq<SelectStatement>();
select_stmt->node = std::move(copied_info.select_statement);
auto subquery_ref = make_uniq<SubqueryRef>(std::move(select_stmt));

copied_info.select_statement = make_uniq_base<QueryNode, SelectNode>();
auto &new_select_node = copied_info.select_statement->Cast<SelectNode>();
new_select_node.from_table = std::move(subquery_ref);
auto &select_node = copied_info.select_statement->Cast<SelectNode>();
select_node.from_table = std::move(subquery_ref);

// Create new select list
vector<unique_ptr<ParsedExpression>> select_list;
Expand Down Expand Up @@ -95,7 +96,6 @@ static BoundStatement CopyToJSONPlan(Binder &binder, CopyStatement &stmt) {
}

// Now create the struct_pack/to_json to create a JSON object per row
auto &select_node = copied_info.select_statement->Cast<SelectNode>();
vector<unique_ptr<ParsedExpression>> struct_pack_child;
struct_pack_child.emplace_back(make_uniq<FunctionExpression>("struct_pack", std::move(select_list)));
select_node.select_list.emplace_back(make_uniq<FunctionExpression>("to_json", std::move(struct_pack_child)));
Expand Down
3 changes: 2 additions & 1 deletion src/planner/binder/statement/bind_copy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ BoundStatement Binder::BindCopyTo(CopyStatement &stmt) {

auto &copy_info = *stmt.info;
// bind the select statement
auto select_node = Bind(*copy_info.select_statement);
auto node_copy = copy_info.select_statement->Copy();
auto select_node = Bind(*node_copy);

if (!copy_function.function.copy_to_bind) {
throw NotImplementedException("COPY TO is not supported for FORMAT \"%s\"", stmt.info->format);
Expand Down
14 changes: 10 additions & 4 deletions src/planner/planner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,10 +182,16 @@ void Planner::VerifyPlan(ClientContext &context, unique_ptr<LogicalOperator> &op
*map = std::move(parameters);
}
op = std::move(new_plan);
} catch (SerializationException &ex) { // NOLINT: explicitly allowing these errors (for now)
// pass
} catch (NotImplementedException &ex) { // NOLINT: explicitly allowing these errors (for now)
// pass
} catch (std::exception &ex) {
ErrorData error(ex);
switch (error.Type()) {
case ExceptionType::SERIALIZATION: // NOLINT: explicitly allowing these errors (for now)
break; // pass
case ExceptionType::NOT_IMPLEMENTED: // NOLINT: explicitly allowing these errors (for now)
break; // pass
default:
throw;
}
}
}

Expand Down

0 comments on commit 5b36f52

Please sign in to comment.