Skip to content

Commit 1739d57

Browse files
fix: update listPartitions() to support tables from other projects (#974)
* fix: update listPartitions() to support tables from other projects * code format Co-authored-by: yoshi-code-bot <[email protected]> Co-authored-by: yoshi-code-bot <[email protected]>
1 parent 9028ee4 commit 1739d57

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/BigQueryImpl.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -848,8 +848,12 @@ public Page<Routine> listRoutines(DatasetId datasetId, RoutineListOption... opti
848848
@Override
849849
public List<String> listPartitions(TableId tableId) {
850850
List<String> partitions = new ArrayList<String>();
851-
Table metaTable =
852-
getTable(TableId.of(tableId.getDataset(), tableId.getTable() + "$__PARTITIONS_SUMMARY__"));
851+
String partitionsTable = tableId.getTable() + "$__PARTITIONS_SUMMARY__";
852+
TableId metaTableId =
853+
tableId.getProject() == null
854+
? TableId.of(tableId.getDataset(), partitionsTable)
855+
: TableId.of(tableId.getProject(), tableId.getDataset(), partitionsTable);
856+
Table metaTable = getTable(metaTableId);
853857
Schema metaSchema = metaTable.getDefinition().getSchema();
854858
String partition_id = null;
855859
for (Field field : metaSchema.getFields()) {

0 commit comments

Comments
 (0)