How to get table name from existing dataset in Cloud Bigquery

I am currently implementing our project to insert data from cloud storage into Bigquery. About the insertion method. Please follow the link below how I do it. How to load data from cloud storage into BigQuery using Java However, I want to check the existing table name in a dataset in Bigquery before inserting data into bigquery. I will be very happy if you can share your idea in resolving this matter?

Thank,

+4
source share
1 answer
private static void listTables(Bigquery service, String projectNumber, String datasetId) throws IOException {

    Bigquery.Tables.List listTablesReply = service.tables().list(projectNumber, datasetId);
    TableList tableList = listTablesReply.execute();

    if (tableList.getTables() != null) {

      List tables = tableList.getTables();

      System.out.println("Tables list:");

      for (TableList.Tables table : tables) {
         System.out.format("%s\n", table.getId());
      }
    }
}    

I think this will help us in this case :)

+4
source

Source: https://habr.com/ru/post/1545165/


All Articles