Commit 0469e5e
authored
feat(catalog): expose InformationSchemataBuilder as public API (#22499)
## Which issue does this PR close?
No linked issue. Happy to file one if reviewers prefer.
## Rationale for this change
Downstream catalog implementations that resolve schemas asynchronously
cannot reuse `InformationSchemaProvider` — it enumerates schemas via
`CatalogProvider::schema_names()`, which is synchronous, so an
async-only catalog has to provide its own `information_schema.schemata`
view. Today that requires either duplicating the column layout and
the row-building logic, or reaching into private items.
Exposing `InformationSchemataBuilder` and a `schemata_schema()` factory
lets external crates emit byte-for-byte-compatible `schemata` batches
without copy-pasting the contract.
## What changes are included in this PR?
- `pub fn schemata_schema() -> SchemaRef` — extracts the column-layout
factory. `InformationSchemata::new` now calls it instead of inlining
the schema, so there is a single source of truth.
- `InformationSchemataBuilder` becomes `pub` (was private) with a
`Default` impl and a public `new()`. `add_schemata` and `finish` are
bumped to `pub`. The function bodies and parameter types
(`&str` / `Option<&str>`) are unchanged.
- `finish` now returns `Result<RecordBatch>` instead of panicking via
an internal `.unwrap()`. The one internal caller
(`PartitionStream::execute` for `InformationSchemata`) was previously
wrapping `Ok(builder.finish())` and is updated to just
`builder.finish()` since the inner expression now produces the
`Result` directly.
## Are these changes tested?
Yes. A new unit test `schemata_builder_emits_canonical_schema_and_rows`
exercises the public API end-to-end via `Default::default()`, asserts
the produced batch's schema matches `schemata_schema()`, and verifies
the null pattern for `schema_owner`, the three `default_character_set_*`
columns, and `sql_path`. The pre-existing internal users
(`InformationSchemata::new`, `PartitionStream::execute`) continue to
exercise the same code path through the unchanged
`InformationSchemata::builder()` constructor.
## Are there any user-facing changes?
Yes — three new public items in `datafusion-catalog`: `schemata_schema`,
`InformationSchemataBuilder` (with its `new` / `add_schemata` / `finish`
methods + `Default` impl). No existing public API is broken. The
`Result<RecordBatch>` return on `finish` is a first-time-public surface,
not a regression.1 parent 7c39318 commit 0469e5e
1 file changed
Lines changed: 121 additions & 17 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
967 | 967 | | |
968 | 968 | | |
969 | 969 | | |
| 970 | + | |
| 971 | + | |
| 972 | + | |
| 973 | + | |
| 974 | + | |
| 975 | + | |
| 976 | + | |
| 977 | + | |
| 978 | + | |
| 979 | + | |
| 980 | + | |
| 981 | + | |
| 982 | + | |
| 983 | + | |
| 984 | + | |
| 985 | + | |
| 986 | + | |
| 987 | + | |
| 988 | + | |
| 989 | + | |
| 990 | + | |
| 991 | + | |
970 | 992 | | |
971 | 993 | | |
972 | | - | |
973 | | - | |
974 | | - | |
975 | | - | |
976 | | - | |
977 | | - | |
978 | | - | |
979 | | - | |
980 | | - | |
981 | | - | |
| 994 | + | |
| 995 | + | |
| 996 | + | |
| 997 | + | |
982 | 998 | | |
983 | 999 | | |
984 | 1000 | | |
| |||
995 | 1011 | | |
996 | 1012 | | |
997 | 1013 | | |
998 | | - | |
| 1014 | + | |
| 1015 | + | |
| 1016 | + | |
| 1017 | + | |
| 1018 | + | |
| 1019 | + | |
| 1020 | + | |
| 1021 | + | |
| 1022 | + | |
| 1023 | + | |
999 | 1024 | | |
1000 | 1025 | | |
1001 | 1026 | | |
| |||
1006 | 1031 | | |
1007 | 1032 | | |
1008 | 1033 | | |
| 1034 | + | |
| 1035 | + | |
| 1036 | + | |
| 1037 | + | |
| 1038 | + | |
| 1039 | + | |
1009 | 1040 | | |
1010 | | - | |
| 1041 | + | |
| 1042 | + | |
| 1043 | + | |
| 1044 | + | |
| 1045 | + | |
| 1046 | + | |
| 1047 | + | |
| 1048 | + | |
| 1049 | + | |
| 1050 | + | |
| 1051 | + | |
| 1052 | + | |
| 1053 | + | |
| 1054 | + | |
| 1055 | + | |
| 1056 | + | |
| 1057 | + | |
| 1058 | + | |
| 1059 | + | |
1011 | 1060 | | |
1012 | 1061 | | |
1013 | 1062 | | |
| |||
1019 | 1068 | | |
1020 | 1069 | | |
1021 | 1070 | | |
1022 | | - | |
1023 | | - | |
1024 | 1071 | | |
1025 | 1072 | | |
1026 | 1073 | | |
1027 | 1074 | | |
1028 | 1075 | | |
1029 | 1076 | | |
1030 | | - | |
| 1077 | + | |
| 1078 | + | |
| 1079 | + | |
| 1080 | + | |
| 1081 | + | |
| 1082 | + | |
| 1083 | + | |
1031 | 1084 | | |
1032 | 1085 | | |
1033 | 1086 | | |
| |||
1040 | 1093 | | |
1041 | 1094 | | |
1042 | 1095 | | |
1043 | | - | |
| 1096 | + | |
1044 | 1097 | | |
1045 | 1098 | | |
1046 | 1099 | | |
| |||
1057 | 1110 | | |
1058 | 1111 | | |
1059 | 1112 | | |
1060 | | - | |
| 1113 | + | |
1061 | 1114 | | |
1062 | 1115 | | |
1063 | 1116 | | |
| |||
1413 | 1466 | | |
1414 | 1467 | | |
1415 | 1468 | | |
| 1469 | + | |
| 1470 | + | |
| 1471 | + | |
| 1472 | + | |
| 1473 | + | |
| 1474 | + | |
| 1475 | + | |
| 1476 | + | |
| 1477 | + | |
| 1478 | + | |
| 1479 | + | |
| 1480 | + | |
| 1481 | + | |
| 1482 | + | |
| 1483 | + | |
| 1484 | + | |
| 1485 | + | |
| 1486 | + | |
| 1487 | + | |
| 1488 | + | |
| 1489 | + | |
| 1490 | + | |
| 1491 | + | |
| 1492 | + | |
| 1493 | + | |
| 1494 | + | |
| 1495 | + | |
| 1496 | + | |
| 1497 | + | |
| 1498 | + | |
| 1499 | + | |
| 1500 | + | |
| 1501 | + | |
| 1502 | + | |
| 1503 | + | |
| 1504 | + | |
| 1505 | + | |
| 1506 | + | |
| 1507 | + | |
| 1508 | + | |
| 1509 | + | |
| 1510 | + | |
| 1511 | + | |
| 1512 | + | |
| 1513 | + | |
| 1514 | + | |
| 1515 | + | |
| 1516 | + | |
| 1517 | + | |
| 1518 | + | |
| 1519 | + | |
1416 | 1520 | | |
1417 | 1521 | | |
1418 | 1522 | | |
| |||
0 commit comments