Skip to content

Conversation

@lidavidm
Copy link
Member

@lidavidm lidavidm commented Jun 4, 2025

Fixes #2903.

@lidavidm lidavidm marked this pull request as ready for review June 4, 2025 08:41
@github-actions github-actions bot added this to the ADBC Libraries 19 milestone Jun 4, 2025
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.

Thank you!

It is worth a quick SQL check to make sure this actually can be piped all the way though (and that the SQL query that finds all the type OIDs finds the row for int2vector).

Comment on lines 483 to 490
case PostgresTypeId::kInt2vector: {
PostgresType child;
NANOARROW_RETURN_NOT_OK(Find(GetOID(PostgresTypeId::kInt2), &child, error));
mapping_.insert({item.oid, child.Array(item.oid, item.typname)});
reverse_mapping_.insert({static_cast<int32_t>(base.type_id()), item.oid});
array_mapping_.insert({child.oid(), item.oid});
break;
}
Copy link
Member

Choose a reason for hiding this comment

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

This seems like it might interfere with or overwrite the mapping for the array of int2, which is possibly a distinct type in the table?

Copy link
Member Author

Choose a reason for hiding this comment

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

item.oid is still the int2vector's OID here. I'm just grabbing the int2 OID so I can use it as the child.

Alternatively, I could ignore this, and in the int2vector special case above, I could just directly allocate a child schema (that probably makes more sense)

Comment on lines 454 to 457
EXPECT_EQ(type.typname(), "int2vector");
EXPECT_EQ(type.type_id(), PostgresTypeId::kArray);
EXPECT_EQ(type.child(0).oid(), int2_oid);
EXPECT_EQ(type.child(0).type_id(), PostgresTypeId::kInt2);
Copy link
Member

Choose a reason for hiding this comment

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

Is there a reason that type.type_id() can't just be PostgresTypeId::kInt2Vector?

Copy link
Member Author

Choose a reason for hiding this comment

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

Did you mean to put this on the line up above? But it's because I'm faking int2vector as effectively alias for array of int2.

Comment on lines 805 to 806
// We don't actually use int2vector for the reader; we treat it as
// equivalent to int2 ARRAY.
auto col_type = PostgresType(PostgresTypeId::kInt2).Array();
PostgresType input_type(PostgresTypeId::kRecord);
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 you probably do want the type id to be int2vector (instantiating the copy reader is an implementation detail I don't think needs to live outside that one function?)

@lidavidm
Copy link
Member Author

lidavidm commented Jun 5, 2025

I did manually test with Python that the query actually works but I'll add and commit a test in C++

@lidavidm
Copy link
Member Author

lidavidm commented Jun 5, 2025

Updated to push the special-case of int2vector around a bit

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.

Thank you!

@lidavidm lidavidm merged commit 46886b9 into apache:main Jun 6, 2025
66 of 68 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.

c/driver/postgresql: add parser for int2vector type

2 participants