Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -219,13 +219,14 @@ private Map<String, Integer> getArrayColumnDimensions(Connection connection, Jdb
return ImmutableMap.of();
}
String sql = "" +
"SELECT att.attname, att.attndims " +
"SELECT att.attname, greatest(att.attndims, 1) AS attndims " +
"FROM pg_attribute att " +
" JOIN pg_type attyp ON att.atttypid = attyp.oid" +
" JOIN pg_class tbl ON tbl.oid = att.attrelid " +
" JOIN pg_namespace ns ON tbl.relnamespace = ns.oid " +
"WHERE ns.nspname = ? " +
"AND tbl.relname = ? " +
"AND att.attndims > 0 ";
"AND attyp.typcategory = 'A' ";
try (PreparedStatement statement = connection.prepareStatement(sql)) {
statement.setString(1, tableHandle.getSchemaName());
statement.setString(2, tableHandle.getTableName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -336,9 +336,10 @@ public void testArray()
@Test
public void testInternalArray()
{
// One can declare column using internal type name for an array. Such a column is not recognized
// as array in Presto, because it does not have correct value in pg_attribute.attndims.
testUnsupportedDataType("_int4");
DataTypeTest.create()
.addRoundTrip(arrayDataType(integerDataType(), "_int4"), asList(1, 2, 3))
.addRoundTrip(arrayDataType(varcharDataType(), "_text"), asList("a", "b"))
.execute(getQueryRunner(), postgresCreateAndInsert("tpch.test_array_with_native_name"));
}

@Test
Expand Down