1#include "duckdb/execution/operator/schema/physical_create_table.hpp"
2
3#include "duckdb/catalog/catalog_entry/schema_catalog_entry.hpp"
4#include "duckdb/catalog/catalog_entry/table_catalog_entry.hpp"
5#include "duckdb/execution/expression_executor.hpp"
6#include "duckdb/storage/data_table.hpp"
7
8using namespace duckdb;
9using namespace std;
10
11void PhysicalCreateTable::GetChunkInternal(ClientContext &context, DataChunk &chunk, PhysicalOperatorState *state) {
12 int64_t inserted_count = 0;
13
14 auto table = (TableCatalogEntry *)schema->CreateTable(context, info.get());
15 if (table && children.size() > 0) {
16 while (true) {
17 children[0]->GetChunk(context, state->child_chunk, state->child_state.get());
18 if (state->child_chunk.size() == 0) {
19 break;
20 }
21 inserted_count += state->child_chunk.size();
22 table->storage->Append(*table, context, state->child_chunk);
23 }
24 chunk.SetCardinality(1);
25 chunk.SetValue(0, 0, Value::BIGINT(inserted_count));
26 }
27
28 state->finished = true;
29}
30