lidavidm commented on code in PR #2919:
URL: https://github.com/apache/arrow-adbc/pull/2919#discussion_r2128082704
##########
c/driver/postgresql/postgres_type_test.cc:
##########
@@ -441,4 +441,20 @@ TEST(PostgresTypeTest, PostgresTypeResolveRecord) {
EXPECT_EQ(type.child(1).type_id(), PostgresTypeId::kText);
}
+TEST(PostgresTypeTest, PostgresTypeResolveInt2vector) {
+ MockTypeResolver resolver;
+ ASSERT_EQ(resolver.Init(), NANOARROW_OK);
+
+ PostgresType type;
+
+ const auto int2vector_oid = resolver.GetOID(PostgresTypeId::kInt2vector);
+ const auto int2_oid = resolver.GetOID(PostgresTypeId::kInt2);
+ EXPECT_EQ(resolver.Find(int2vector_oid, &type, nullptr), NANOARROW_OK);
+ EXPECT_EQ(type.oid(), int2vector_oid);
+ 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);
Review Comment:
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.
##########
c/driver/postgresql/postgres_type.h:
##########
@@ -475,6 +480,15 @@ class PostgresTypeResolver {
break;
}
+ 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;
+ }
Review Comment:
`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)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]