Skip to content

fix: Fix Column Type Name for PostgreSQL ARRAY types#2409

Open
sakthivelmanii wants to merge 1 commit intomainfrom
fix_column_type_for_array_in_pg
Open

fix: Fix Column Type Name for PostgreSQL ARRAY types#2409
sakthivelmanii wants to merge 1 commit intomainfrom
fix_column_type_for_array_in_pg

Conversation

@sakthivelmanii
Copy link
Contributor

PostgreSQL usually returns _ as column name for ARRAY types

@sakthivelmanii sakthivelmanii requested a review from a team as a code owner February 27, 2026 10:33
@product-auto-label product-auto-label bot added size: s Pull request size is small. api: spanner Issues related to the googleapis/java-spanner-jdbc API. labels Feb 27, 2026
}

@Test
public void getColumnTypeNameForPostgreSQL() throws SQLException {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we add a test that verifies a type name in 'plain text'. That is: I suspect that the current implementation will return something like _varchar[] as the type name for a PostgreSQL array of varchar. That would be incorrect, as the correct name would be either _varchar or varchar[].

Copy link
Contributor Author

Choose a reason for hiding this comment

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

now it will return _varchar. Maybe I will update the test to not to use TEST_COLUMNS but have two examples, only for ARRAY, REGULAR TYPE..

return "_" + columnType.getArrayElementType().getSpannerTypeName(dialect);
}
}
return columnType.getCode().name();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should we fix this for more than only PostgreSQL arrays? The current implementation will (I think)

  1. Return ARRAY for all GoogleSQL arrays
  2. STRING for PostgreSQL varchar columns (and so forth for each non-array type)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The current implementation will (I think)
Return ARRAY for all GoogleSQL arrays
STRING for PostgreSQL varchar columns (and so forth for each non-array type)

Yes

Should we fix this for more than only PostgreSQL arrays?

Sorry? What do you mean by this?

Copy link
Collaborator

Choose a reason for hiding this comment

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

What I mean is that it is a bit weird that:

  1. GoogleSQL ARRAY<STRING> returns ARRAY, while PostgreSQL ARRAY<STRING> returns _varchar
  2. PostgreSQL STRING returns STRING (instead of varchar), while PostgreSQL ARRAY<STRING> returns _varchar

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 see. we can change it. I don't think there will be a problem if we change it. So far ARRAY is the only thing which was concerning for me so I changed it.. Right now, there's a complex handling of types in PG. text == varchar == charater varying. We need to maintain one type which will be easy.

If you feel, we should do it, I can incorporate the change.

@sakthivelmanii sakthivelmanii force-pushed the fix_column_type_for_array_in_pg branch from 465f42d to 1ee4d0b Compare February 27, 2026 11:46
@sakthivelmanii sakthivelmanii force-pushed the fix_column_type_for_array_in_pg branch from 1ee4d0b to 9affb40 Compare February 27, 2026 11:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: spanner Issues related to the googleapis/java-spanner-jdbc API. size: s Pull request size is small.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants