Skip to content

feat: add GetStatistics test#187

Open
Mandukhai-Alimaa wants to merge 3 commits intoadbc-drivers:mainfrom
Mandukhai-Alimaa:feat/implement-get-statistics-test
Open

feat: add GetStatistics test#187
Mandukhai-Alimaa wants to merge 3 commits intoadbc-drivers:mainfrom
Mandukhai-Alimaa:feat/implement-get-statistics-test

Conversation

@Mandukhai-Alimaa
Copy link
Copy Markdown
Contributor

@Mandukhai-Alimaa Mandukhai-Alimaa commented Mar 22, 2026

What's Changed

apache/arrow-adbc#4129 need to be merged in first.

Closes #182



class TestConnection:
@staticmethod
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We can just use a constant at global level - this isn't Java :)

Comment on lines +1067 to +1068
if not driver.features.connection_get_statistics:
pytest.skip("not implemented")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It would be better to do this in generate_tests since currently the fixture will run even if the driver doesn't support this

Comment on lines +1070 to +1071
if not hasattr(conn, "adbc_get_statistics"):
pytest.skip("adbc_driver_manager DBAPI does not expose GetStatistics")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

IMO this should be an error, why enable the test and then silently skip it?

)

# Verify statistic_is_approximate is a boolean
assert isinstance(stat["statistic_is_approximate"], bool), (
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The data is typed, and we validated the Arrow schema above, so there's no point validating this

Comment on lines +1146 to +1152
# Verify statistic value is a scalar (int, float, bytes, or None)
assert isinstance(
stat["statistic_value"], (int, float, bytes, type(None))
), (
f"statistic_value should be int|float|bytes|None, "
f"got {type(stat['statistic_value'])}"
)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Ditto here

f"got {type(stat['statistic_value'])}"
)

# If row count statistic is present, verify it's reasonable since approx = true
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think this works OK to start but it may be good to extend DriverFeatures with a list of expected statistic names, sort of like with xdbc

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

sounds good. we can merge this first and tackle this later with seperate PR.

Copy link
Copy Markdown
Contributor

@lidavidm lidavidm left a comment

Choose a reason for hiding this comment

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

LGTM, we can merge once adbc-driver-manager is updated

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.

Implement test for GetStatistics

2 participants