@@ -164,13 +164,26 @@ public enum TableType {
164164 private final TableType tableType ;
165165 private final List <PostgresStatisticsObject > statistics ;
166166 private final boolean isInsertable ;
167+ private final boolean isPartitioned ;
167168
168169 public PostgresTable (String tableName , List <PostgresColumn > columns , List <PostgresIndex > indexes ,
169170 TableType tableType , List <PostgresStatisticsObject > statistics , boolean isView , boolean isInsertable ) {
170171 super (tableName , columns , indexes , isView );
171172 this .statistics = statistics ;
172173 this .isInsertable = isInsertable ;
173174 this .tableType = tableType ;
175+ //TODO: simple adapter for other implementations
176+ this .isPartitioned = false ;
177+ }
178+
179+ public PostgresTable (String tableName , List <PostgresColumn > columns , List <PostgresIndex > indexes ,
180+ TableType tableType , List <PostgresStatisticsObject > statistics , boolean isView , boolean isInsertable ,
181+ boolean isPartitioned ) {
182+ super (tableName , columns , indexes , isView );
183+ this .statistics = statistics ;
184+ this .isInsertable = isInsertable ;
185+ this .tableType = tableType ;
186+ this .isPartitioned = isPartitioned ;
174187 }
175188
176189 public List <PostgresStatisticsObject > getStatistics () {
@@ -185,6 +198,10 @@ public boolean isInsertable() {
185198 return isInsertable ;
186199 }
187200
201+ public boolean isPartitioned () {
202+ return isPartitioned ;
203+ }
204+
188205 }
189206
190207 public static final class PostgresStatisticsObject {
@@ -225,11 +242,12 @@ public static PostgresSchema fromConnection(SQLConnection con, String databaseNa
225242 List <PostgresTable > databaseTables = new ArrayList <>();
226243 try (Statement s = con .createStatement ()) {
227244 try (ResultSet rs = s .executeQuery (
228- "SELECT table_name, table_schema, table_type, is_insertable_into FROM information_schema.tables WHERE table_schema='public' OR table_schema LIKE 'pg_temp_%' ORDER BY table_name;" )) {
245+ "SELECT t. table_name, t. table_schema, t. table_type, t. is_insertable_into, c.relkind FROM information_schema.tables t JOIN pg_class c ON c.relname = t.table_name JOIN pg_namespace n ON n.oid = c.relnamespace AND n.nspname = t.table_schema WHERE t. table_schema='public' OR t. table_schema LIKE 'pg_temp_%' ORDER BY t. table_name;" )) {
229246 while (rs .next ()) {
230247 String tableName = rs .getString ("table_name" );
231248 String tableTypeSchema = rs .getString ("table_schema" );
232249 boolean isInsertable = rs .getBoolean ("is_insertable_into" );
250+ boolean isPartitioned = "p" .equals (rs .getString ("relkind" ));
233251 // TODO: also check insertable
234252 // TODO: insert into view?
235253 boolean isView = tableName .startsWith ("v" ); // tableTypeStr.contains("VIEW") ||
@@ -240,7 +258,7 @@ public static PostgresSchema fromConnection(SQLConnection con, String databaseNa
240258 List <PostgresIndex > indexes = getIndexes (con , tableName );
241259 List <PostgresStatisticsObject > statistics = getStatistics (con );
242260 PostgresTable t = new PostgresTable (tableName , databaseColumns , indexes , tableType , statistics ,
243- isView , isInsertable );
261+ isView , isInsertable , isPartitioned );
244262 for (PostgresColumn c : databaseColumns ) {
245263 c .setTable (t );
246264 }
@@ -324,4 +342,4 @@ public String getDatabaseName() {
324342 return databaseName ;
325343 }
326344
327- }
345+ }
0 commit comments