Skip to content

How to get the names of all accessible Datasets? #2404

@Electricks94

Description

@Electricks94

Hello,
I got a small problem. Basically, I just want to receive the names of all the datasets which I can access. My code looks like BigQuery API described how to do it:


import java.util.Iterator;
import java.util.List;

import com.google.api.gax.paging.Page;
//import com.google.appengine.repackaged.org.apache.lucene.analysis.compound.hyphenation.TernaryTree.Iterator;
import com.google.cloud.bigquery.*;
import com.google.cloud.bigquery.BigQuery.DatasetListOption;

public class GetBQInfo {
	public static void getinfo (){
	BigQuery bigquery = BigQueryOptions.getDefaultInstance()
		    .toBuilder()
		    .setProjectId("testprojekt-175408")
		    .build()
		    .getService();
	 String projectId = "testprojekt-175408";
	 Page<Dataset> datasets = bigquery.listDatasets(projectId, DatasetListOption.pageSize(100));
	 Iterator<Dataset> datasetIterator = datasets.iterateAll();
	 while (datasetIterator.hasNext()) {
	   Dataset dataset = datasetIterator.next();
	   // do something with the dataset
	 }
	 }
}

But I cannot compile the code because I get this message from eclipse:
Type mismatch: cannot convert from Iterable<Dataset> to Iterator<Dataset>
I tried a lot of things but nothing worked for me yet. Does anyone know how I can solve this?

Metadata

Metadata

Assignees

Labels

api: bigqueryIssues related to the BigQuery API.priority: p2Moderately-important priority. Fix may not be included in next release.type: questionRequest for information or clarification. Not an issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions