Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(c/driver): Date32 support #948

Merged
merged 18 commits into from
Aug 1, 2023
Merged

Conversation

WillAyd
Copy link
Contributor

@WillAyd WillAyd commented Jul 28, 2023

No description provided.

@@ -1095,8 +1100,12 @@ void StatementTest::TestSqlIngestBinary() {
NANOARROW_TYPE_BINARY, {std::nullopt, "", "\x00\x01\x02\x04", "\xFE\xFF"}));
}

void StatementTest::TestSqlIngestDate32() {
ASSERT_NO_FATAL_FAILURE(TestSqlIngestNumericType<int32_t>(NANOARROW_TYPE_DATE32));
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right now this tests the postgres implementation, but the SQLite implementation doesn't get tested since the roundtrip value is a string.

For the timestamps we have separate test bodies and a function like ValidateIngestedTimestampData that the tests use to override what should be returned. We could follow that same pattern here though it is a bit heavy-handed given how this fits into TestSqlIngestNumericType pretty easily

The general problem is finding the right pattern to round trip tests for things where the input type doesn't match the output type

Copy link
Member

Choose a reason for hiding this comment

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

What about something like this? #787

What I envision there is a set of directories, one per vendor, where each has a .sql file that creates tables and inserts data and a reference .arrow file for the expected output.

Copy link
Member

Choose a reason for hiding this comment

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

More verbose, but then for drivers where there's overlap (e.g. Postgres in Java, Postgres in C++) we can also use them to assert that the behavior matches. The problem is checking in binaries; I was thinking we could borrow the arrow-testing submodule to do that to avoid cluttering the main repo.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think this makes sense. Before I go too deep - when looking at this I figured we would have to vendor nanoarrow_ipc, which in turn would require us to at flatcc. Does that make sense or am I overcomplicating?

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, and to be clear, I think there's no need to go that far in this PR - just something for later evaluation

@WillAyd WillAyd marked this pull request as ready for review July 31, 2023 19:38
@@ -1037,6 +1037,10 @@ void StatementTest::TestSqlIngestNumericType(ArrowType type) {
// values. Likely a bug on our side, but for now, avoid them.
values.push_back(static_cast<CType>(-1.5));
values.push_back(static_cast<CType>(1.5));
} else if (type == ArrowType::NANOARROW_TYPE_DATE32) {
// Windows does not seem to support negative date values
values.push_back(static_cast<CType>(0));
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Having to use 0 as a minimum value here is unfortunate. I couldn't find any real documentation on gmtime_s limitations in Windows, except that the upper limit on 64 bit systems is through the year 3000

https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/gmtime-s-gmtime32-s-gmtime64-s?view=msvc-170

Guessing it may also just not support negative dates in a way that is undocumented? Unfortunately I do not have a windows machine available to test

Copy link
Member

Choose a reason for hiding this comment

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

Ugh.

I wonder if we shouldn't also consider vendoring a library for that down the line...that would be easier if/when we also consolidate the driver codebases

Copy link
Member

@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.

Thanks!

@@ -1037,6 +1037,10 @@ void StatementTest::TestSqlIngestNumericType(ArrowType type) {
// values. Likely a bug on our side, but for now, avoid them.
values.push_back(static_cast<CType>(-1.5));
values.push_back(static_cast<CType>(1.5));
} else if (type == ArrowType::NANOARROW_TYPE_DATE32) {
// Windows does not seem to support negative date values
values.push_back(static_cast<CType>(0));
Copy link
Member

Choose a reason for hiding this comment

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

Ugh.

I wonder if we shouldn't also consider vendoring a library for that down the line...that would be easier if/when we also consolidate the driver codebases

@lidavidm
Copy link
Member

lidavidm commented Aug 1, 2023

I restarted CI, but I think the problem is probably on main, which shouldn't hold this up

@lidavidm lidavidm merged commit 995a02d into apache:main Aug 1, 2023
45 of 65 checks passed
@lidavidm lidavidm added this to the ADBC Libraries 0.6.0 milestone Aug 1, 2023
@WillAyd WillAyd deleted the date32-support branch August 2, 2023 03:10
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.

2 participants