@@ -475,48 +475,8 @@ std::vector<uint8_t> SerializeForeignKeyToIpcBytes(const std::vector<std::string
475475 const std::vector<std::string> &pk_columns,
476476 const std::string &referenced_table,
477477 const std::string &referenced_schema) {
478- // Build a single-row batch matching the Python ForeignKeyDef format. This
479- // nested dataclass is not currently emitted as a standalone generated schema.
480- auto fk_schema = arrow::schema ({
481- arrow::field (" fk_columns" , arrow::list (arrow::utf8 ())),
482- arrow::field (" pk_columns" , arrow::list (arrow::utf8 ())),
483- arrow::field (" referenced_table" , arrow::utf8 ()),
484- arrow::field (" referenced_schema_path" , arrow::list (arrow::utf8 ())),
485- });
486-
487- // Build fk_columns array
488- auto fk_builder = std::make_shared<arrow::ListBuilder>(arrow::default_memory_pool (),
489- std::make_shared<arrow::StringBuilder>());
490- auto fk_val_builder = dynamic_cast <arrow::StringBuilder *>(fk_builder->value_builder ());
491- CheckStatus (fk_builder->Append (), " fk list append" );
492- for (auto &col : fk_columns) {
493- CheckStatus (fk_val_builder->Append (col), " fk col append" );
494- }
495- auto fk_arr_result = fk_builder->Finish ();
496- CheckStatus (fk_arr_result.status (), " fk finish" );
497-
498- // Build pk_columns array
499- auto pk_builder = std::make_shared<arrow::ListBuilder>(arrow::default_memory_pool (),
500- std::make_shared<arrow::StringBuilder>());
501- auto pk_val_builder = dynamic_cast <arrow::StringBuilder *>(pk_builder->value_builder ());
502- CheckStatus (pk_builder->Append (), " pk list append" );
503- for (auto &col : pk_columns) {
504- CheckStatus (pk_val_builder->Append (col), " pk col append" );
505- }
506- auto pk_arr_result = pk_builder->Finish ();
507- CheckStatus (pk_arr_result.status (), " pk finish" );
508-
509- // Build scalar string arrays
510- arrow::StringBuilder ref_table_builder;
511- CheckStatus (ref_table_builder.Append (referenced_table), " ref table" );
512- auto ref_table_result = ref_table_builder.Finish ();
513- CheckStatus (ref_table_result.status (), " ref table finish" );
514-
515- auto batch = arrow::RecordBatch::Make (fk_schema, 1 ,
516- {fk_arr_result.ValueUnsafe (), pk_arr_result.ValueUnsafe (),
517- ref_table_result.ValueUnsafe (),
518- BuildStringListScalar (SingleSchemaPath (referenced_schema))});
519- return SerializeToIpcBytes (batch);
478+ return SerializeToIpcBytes (
479+ generated::BuildForeignKeyInfo (fk_columns, pk_columns, referenced_table, SingleSchemaPath (referenced_schema)));
520480}
521481
522482// ============================================================================
@@ -1364,40 +1324,11 @@ TableFunctionCardinalityResult ParseTableFunctionCardinalityResult(const std::sh
13641324// ! because whether they are loadable is a per-session question this static list
13651325// ! cannot answer.
13661326static std::vector<uint8_t > BuildClientCapabilitiesBytes () {
1367- auto schema = arrow::schema ({
1368- arrow::field (" engine" , arrow::utf8 (), false ),
1369- arrow::field (" native_formats" , arrow::list (arrow::utf8 ()), false ),
1370- arrow::field (" catalogs" , arrow::list (arrow::utf8 ()), false ),
1371- arrow::field (" can_stream" , arrow::boolean (), false ),
1372- arrow::field (" filter_encodings" , arrow::list (arrow::utf8 ()), false ),
1373- });
1374-
1375- auto string_list = [](const std::vector<std::string> &values) {
1376- auto value_builder = std::make_shared<arrow::StringBuilder>();
1377- arrow::ListBuilder list_builder (arrow::default_memory_pool (), value_builder);
1378- CheckStatus (list_builder.Append (), " open list" );
1379- for (const auto &v : values) {
1380- CheckStatus (value_builder->Append (v), " append list value" );
1381- }
1382- return FinishArray (list_builder, " string list" );
1383- };
1384-
1385- std::vector<std::shared_ptr<arrow::Array>> arrays;
1386- arrays.push_back (BuildStringScalar (" duckdb" ));
1387- arrays.push_back (string_list ({" parquet" , " csv" , " json" }));
1388- arrays.push_back (string_list ({" ducklake" , " iceberg" , " postgres" , " mysql" , " sqlite" , " duckdb" }));
1389- {
1390- arrow::BooleanBuilder b;
1391- // DuckDB has no streaming scan: positions ride the wire but nothing reads
1392- // them. Saying false here is what stops a worker handing back an unbounded
1393- // split this client could never terminate.
1394- CheckStatus (b.Append (false ), " can_stream" );
1395- arrays.push_back (FinishArray (b, " can_stream" ));
1396- }
1397- arrays.push_back (string_list ({" vgi.filters.v1" }));
1398-
1399- auto batch = arrow::RecordBatch::Make (schema, 1 , arrays);
1400- return SerializeToIpcBytes (batch);
1327+ // DuckDB has no streaming scan: saying false prevents a worker from
1328+ // returning an unbounded split this client could never terminate.
1329+ return SerializeToIpcBytes (generated::BuildClientCapabilities (
1330+ " duckdb" , {" parquet" , " csv" , " json" }, {" ducklake" , " iceberg" , " postgres" , " mysql" , " sqlite" , " duckdb" }, false ,
1331+ {" vgi.filters.v1" }));
14011332}
14021333
14031334std::shared_ptr<arrow::RecordBatch> BuildCatalogAttachRequest (
0 commit comments