Skip to content

feat(format): add generic metadata API - #4544

Closed
lidavidm wants to merge 9 commits into
apache:spec-1.2.0from
lidavidm:gh-4400
Closed

feat(format): add generic metadata API#4544
lidavidm wants to merge 9 commits into
apache:spec-1.2.0from
lidavidm:gh-4400

Conversation

@lidavidm

@lidavidm lidavidm commented Jul 20, 2026

Copy link
Copy Markdown
Member
  • Add a generic API for fetching metadata, modeled on ADO.NET's GetSchema
  • Define the standard metadata collections
  • Revert the current revisions to GetObjects in favor of not changing it

Related:

For consideration:

  • Should filters be (optionally) named arguments? (Pointer to struct, or assuming that every filter is preceded by a pointer to a name string.) The justification: we could more easily implement/define "standard" arguments to handle things like the pagination token above without having to replicate it into every single definition. If we only have positional arguments, it starts to get annoying to handle.
  • Should filters be typed? (Pointer to struct containing union)
  • Should filters be replaced by just leveraging SetOption(Int,...)? (This would obviate the former two points but is rather clunky, and precludes a hypothetical driver that could handle these operations concurrently)

Closes #4400.

zeroshade and others added 6 commits February 17, 2026 21:36
Extracted from apache#3607 with influence by the comments there and
apache/arrow-adbc@main...CurtHagenlocher:arrow-adbc:MoreResults,
this contains a proposal for handling multi-result set query execution
via ADBC by adding a new function for drivers,
`AdbcStatementNextResultSet`.

This also includes the necessary changes for an ADBC API Revision 1.2.0
(macro defines and so on). The comment above the function includes all
the semantic definitions of the behavior.
- Add `constraint_expression`
- Add various fields for foreign keys

Closes apache#3987.
Closes apache#3989.
@lidavidm
lidavidm requested a review from CurtHagenlocher July 20, 2026 06:55
@lidavidm

Copy link
Copy Markdown
Member Author

Also CC @iconara

I've also been thinking about your request for stateless pagination, and I think it's reasonable enough to define a way to get/pass a pagination token. I think there are enough systems that could use it: Athena, BigQuery, Databricks, Snowflake, Iceberg REST catalog, etc.

@lidavidm

Copy link
Copy Markdown
Member Author

And also CC @mullinsms, who kicked all this off by listing all the types of metadata we didn't support 🙂

In particular, Curt's suggestion means we can support database-specific metadata (though, I'm still of the opinion that something truly database-specific is probably better handled by the application; if the application has a very specific metadata query it wants to issue I'm not sure how useful it is to build it into the driver).

@lidavidm
lidavidm requested a review from paleolimbot July 20, 2026 07:06
@lidavidm

Copy link
Copy Markdown
Member Author

At the risk of overcomplicating things: similar to #3623, it might be nice to have a way to request that certain extra fields be included/omitted, e.g. table properties (#3995), where it may be efficient to fetch the data at the same time as the "standard" fields, but where some (many) clients also may not want the field. Maybe it could optionally take an Arrow schema as input for that.

Similarly, maybe the application wants to opt in to run-length-encoding certain response columns to save memory. (Or is that not really a concern so long as things are properly streamed/paginated?)

@lidavidm lidavidm changed the title feat(format): add generic metadata API [WIP] feat(format): add generic metadata API Jul 22, 2026
@lidavidm
lidavidm marked this pull request as ready for review July 22, 2026 04:39
@lidavidm
lidavidm requested a review from zeroshade as a code owner July 22, 2026 04:39
@lidavidm
lidavidm requested a review from amoeba August 6, 2026 07:21
@lidavidm

Copy link
Copy Markdown
Member Author

I think I'm leaning towards having all options/filters be set by SetOption. This is perhaps inconvenient for C/C++ users, but language-level bindings can present higher level APIs, and allows us to express better type safety. This would also be consistent with my suggestion in #4317.

Either way, the current declaration needs to clarify the lifetime of the filter argument anyways (the driver should copy arguments as it is not allowed to assume filters will be valid during the returned record reader's lifetime).

I thought about having a SetOptionStringList. This would be useful if we do want to support Iceberg-style catalogs, as we need a way to pass a list of namespace parts, and I would rather avoid trying to encode strings into a single string (via e.g. JSON). But maybe we can embrace Curt's suggestions and lean on Parquet Variant for encoding these sorts of complex-type arguments. That said, I fear I'm reinventing COM or some sort of intraprocess RPC mechanism...

@paleolimbot

Copy link
Copy Markdown
Member

I think I'm leaning towards having all options/filters be set by SetOption.

This is kind of ugly but I see what you're getting at. GDAL handles this with const char** options where options is NULL terminated list of KEY=arbitrary value, with the downside that everything is serialized. If this is a get/set option on a connection is seems more problematic (on a statement it's more clear that options have a specific scope).

This would be useful if we do want to support Iceberg-style catalogs, as we need a way to pass a list of namespace parts

It's a hack, but some REST APIs use the unit separator (\x1f) or have a user-specified separator and just have "schemas" with potentially multiple parts.

I'm guessing you don't want to go this direction, but I can't help but notice there's a large amount of complexity associated with stuffing these concepts into Arrow arrays that are highly nested and very difficult to parse. I'll throw out that you could do something like

struct AdbcCatalogNode {
  AdbcStatus (*get_property)(struct AdbcCatalogNode* self, const char* what, struct ArrowSchema* out_schema, struct ArrowArray* out_array, AdbcError* err);
  AdbcStatus (*get_child)(struct AdbcCatalogNode* self, const char* what, AdbcError* err);
  void* private_data;
  void* private_driver;
}

AdbcStatus AdbcConnectionGetCatalogs(struct AdbcConnection* connection, const char** options, struct AdbcCatalogNode* out, AdbcError* err);

Not perfect, but maybe lets some of this complexity get pushed onto the driver instead of on the consumer since drivers might have abstractions for some of this already.

///
/// \param[in] connection The database connection.
/// \param[in] collection The collection to fetch.
/// \param[out] out The result set.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The filters params are missing from the docs here

ADBC_EXPORT
AdbcStatusCode AdbcConnectionGetMetadataCollection(
struct AdbcConnection* connection, const char* collection, size_t num_filters,
const char** filters, struct ArrowArrayStream* out, struct AdbcError* error);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did I miss it or does the docs not define the semantics of the filters in terms of prefix, a LIKE pattern, regex, etc.?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Er, the point of this is that each collection can define its own filters...see the collection definitions.

/// | db_schema_name | utf8 | |
/// | db_schema_remarks | utf8 | (1) |
///
/// (R) This field is run-length encoded by default; it can be disabled via

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why REE instead of dictionary encoded (which is more widely supported among arrow implementations)?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose I don't like the potential complexity around having to handle replacement/delta dictionaries (which I think are also not quite fully supported in all cases), and the statefulness that dictionaries bring (REE data is always fully decodable from a single batch).

@lidavidm

Copy link
Copy Markdown
Member Author

I think I'm leaning towards having all options/filters be set by SetOption.

This is kind of ugly but I see what you're getting at. GDAL handles this with const char** options where options is NULL terminated list of KEY=arbitrary value, with the downside that everything is serialized. If this is a get/set option on a connection is seems more problematic (on a statement it's more clear that options have a specific scope).

I agree that the scoping of the option feels a bit awkward. @paleolimbot do you mean that it's a flat list of alternating [key, value, key, value, key, value]? That could work well enough.

This would be useful if we do want to support Iceberg-style catalogs, as we need a way to pass a list of namespace parts

It's a hack, but some REST APIs use the unit separator (\x1f) or have a user-specified separator and just have "schemas" with potentially multiple parts.

I suppose the separator works but I dislike this sort of in-band encoding...that said we could also figure out some convention to encode multiple variadic arguments into a parameter list (e.g. terminating a variadic argument with a NULL element)

I'm guessing you don't want to go this direction, but I can't help but notice there's a large amount of complexity associated with stuffing these concepts into Arrow arrays that are highly nested and very difficult to parse. I'll throw out that you could do something like

struct AdbcCatalogNode {
  AdbcStatus (*get_property)(struct AdbcCatalogNode* self, const char* what, struct ArrowSchema* out_schema, struct ArrowArray* out_array, AdbcError* err);
  AdbcStatus (*get_child)(struct AdbcCatalogNode* self, const char* what, AdbcError* err);
  void* private_data;
  void* private_driver;
}

AdbcStatus AdbcConnectionGetCatalogs(struct AdbcConnection* connection, const char** options, struct AdbcCatalogNode* out, AdbcError* err);

Not perfect, but maybe lets some of this complexity get pushed onto the driver instead of on the consumer since drivers might have abstractions for some of this already.

The new collection definitions don't nest the data anymore, to hopefully avoid this.

@lidavidm

Copy link
Copy Markdown
Member Author

Also, I think encoding filter arguments is good enough. At least with current APIs, essentially all filter arguments are strings anyways.

@paleolimbot

Copy link
Copy Markdown
Member

do you mean that it's a flat list of alternating [key, value, key, value, key, value]

Yes, like auto options = {"METADATA_ENCODING=geoarrow", "FOOFY2=something else", nullptr};. No need to do anything if the existing filter specification works.

@lidavidm

Copy link
Copy Markdown
Member Author

Another thought: what if we just place this as a statement-level function? Even if it's not associated with a statement per se this lets us get access to existing functions like RequestSchema and lets us scope SetOption without "affecting" the entire connection.

@lidavidm

Copy link
Copy Markdown
Member Author

Drafted that at #4694.

I don't love that API either but I think it is more consistent than this one.

@lidavidm

Copy link
Copy Markdown
Member Author

I'll close this in favor of the reworked proposal at #4694.

@lidavidm lidavidm closed this Aug 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants