Skip to content

feat(format): add AdbcConnectionSetWarningHandler#3872

Merged
lidavidm merged 2 commits intoapache:spec-1.2.0from
lidavidm:gh-1243
Feb 25, 2026
Merged

feat(format): add AdbcConnectionSetWarningHandler#3872
lidavidm merged 2 commits intoapache:spec-1.2.0from
lidavidm:gh-1243

Conversation

@lidavidm
Copy link
Member

@lidavidm lidavidm commented Jan 9, 2026

Closes #1243.

@lidavidm
Copy link
Member Author

lidavidm commented Jan 9, 2026

CC @CurtHagenlocher @zeroshade
This is obviously incomplete in terms of writing out all the definitions, but this is the core of the API I'd like to propose.

@lidavidm lidavidm changed the title feat(format): add AdbcDatabaseSetWarningHandler feat(format): add AdbcConnectionSetWarningHandler Feb 19, 2026
@lidavidm lidavidm marked this pull request as ready for review February 19, 2026 04:33
Copy link
Contributor

@CurtHagenlocher CurtHagenlocher left a comment

Choose a reason for hiding this comment

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

Looks great!

Copy link
Member

@paleolimbot paleolimbot left a comment

Choose a reason for hiding this comment

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

Looking forward to it!

Comment on lines +1099 to +1103
/// \param[in] warning The warning information. The application is
/// responsible for releasing the warning, but the warning pointer itself
/// may not be valid after the handler returns.
/// \param[in] user_data The user_data pointer.
typedef void (*AdbcWarningHandler)(const struct AdbcError* warning, void* user_data);
Copy link
Member

Choose a reason for hiding this comment

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

I think this is simpler and the right way to go, but just pointing out that it implies that the lifecycle of user_data must outlive the connection (i.e., if you want to do something like log to a file you're managing that file handle on your own).

Comment on lines +1632 to +1634
/// May be set before or after AdbcConnectionInit.
///
/// \since ADBC API revision 1.2.0
Copy link
Member

Choose a reason for hiding this comment

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

This may be a future clarification, but as somebody setting a warning handler it would probably be good to have some expectation about how frequently this would be called, or perhaps some guidance as a driver author about how frequently it should be called. For example, if this is somehow used to warn about a lossy conversion from the internal database wire format to Arrow, driver authors should probably just warn about the first lossy value to be polite (this makes implementing the handler a bit easier).

It would probably be a good idea to explicitly state the thread safety of the handler (i.e., is the expectation that this handler can be called from any thread at any time, or is it the driver's responsibility to serialize warning calls?). It would be easier to implement a handler if it were the driver's responsibility to serialize calls.

Copy link
Contributor

Choose a reason for hiding this comment

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

Agreed that we wouldn't want drivers to be too noisy. My ideal for something like a lossy conversion might be to warn about it the first time and then to report it at the end as a statistical summary e.g. "there were 3065 lossy conversions in this result".

I have a slight preference for this specific case to put serialization / concurrency safety onto the consumer but I don't feel strongly about it. The driver can't reasonably anticipate the host's concurrency requirements.

Copy link
Member

Choose a reason for hiding this comment

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

My ideal for something like a lossy conversion might be to warn about it the first time and then to report it at the end as a statistical summary e.g. "there were 3065 lossy conversions in this result".

👍

I have a slight preference for this specific case to put serialization / concurrency safety onto the consumer

That makes sense. As a host application you might want to be defensive anyway. In R we have to call Rf_warning() from a very specific thread and so just serializing the calls won't help anyway.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks, I updated the wording a bit to clarify this.

@lidavidm lidavidm merged commit 7db48f3 into apache:spec-1.2.0 Feb 25, 2026
2 checks passed
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