use of org.talend.components.bigquery.BigQueryDatasetProperties in project components by Talend.
the class BigQueryDatasetTestIT method createDatasetProperties.
/**
* @return the properties for this dataset, fully initialized with the default values and the datastore credentials
* from the System environment.
*/
public static BigQueryDatasetProperties createDatasetProperties() {
// Configure the dataset.
BigQueryDatastoreProperties datastoreProps = new BigQueryDatastoreProperties(null);
datastoreProps.init();
datastoreProps.projectName.setValue(System.getProperty("bigquery.project"));
datastoreProps.serviceAccountFile.setValue(System.getProperty("bigquery.service.account.file"));
datastoreProps.tempGsFolder.setValue(System.getProperty("bigquery.gcp.temp.folder"));
BigQueryDatasetProperties datasetProps = new BigQueryDatasetProperties(null);
datasetProps.init();
datasetProps.setDatastoreProperties(datastoreProps);
return datasetProps;
}
use of org.talend.components.bigquery.BigQueryDatasetProperties in project components by Talend.
the class BigQueryTestConstants method createDatasetFromTable.
public static BigQueryDatasetProperties createDatasetFromTable(BigQueryDatastoreProperties datastore, String datasetName, String tableName) {
BigQueryDatasetProperties dataset = new BigQueryDatasetProperties("dataset");
dataset.init();
dataset.setDatastoreProperties(datastore);
dataset.bqDataset.setValue(datasetName);
dataset.sourceType.setValue(BigQueryDatasetProperties.SourceType.TABLE_NAME);
dataset.tableName.setValue(tableName);
return dataset;
}
use of org.talend.components.bigquery.BigQueryDatasetProperties in project components by Talend.
the class BigQueryTestConstants method createDatasetFromQuery.
public static BigQueryDatasetProperties createDatasetFromQuery(BigQueryDatastoreProperties datastore, String query, boolean useLegacy) {
BigQueryDatasetProperties dataset = new BigQueryDatasetProperties("dataset");
dataset.init();
dataset.setDatastoreProperties(datastore);
dataset.sourceType.setValue(BigQueryDatasetProperties.SourceType.QUERY);
dataset.query.setValue(query);
dataset.useLegacySql.setValue(useLegacy);
return dataset;
}
use of org.talend.components.bigquery.BigQueryDatasetProperties in project components by Talend.
the class BigQueryDatasetTestIT method testBasic.
@Test
public void testBasic() throws Exception {
BigQueryDatasetProperties props = createDatasetProperties();
props.sourceType.setValue(SourceType.QUERY);
props.query.setValue("SELECT * FROM [bigquery-public-data:samples.shakespeare] LIMIT 1");
props.useLegacySql.setValue(true);
final List<IndexedRecord> consumed = new ArrayList<>();
RuntimeInfo ri = def.getRuntimeInfo(props);
try (SandboxedInstance si = RuntimeUtil.createRuntimeClass(ri, getClass().getClassLoader())) {
DatasetRuntime runtime = (DatasetRuntime) si.getInstance();
runtime.initialize(null, props);
assertThat(runtime, not(nullValue()));
Schema s = runtime.getSchema();
assertThat(s, not(nullValue()));
runtime.getSample(100, new Consumer<IndexedRecord>() {
@Override
public void accept(IndexedRecord ir) {
consumed.add(ir);
}
});
}
assertThat(consumed, hasSize(1));
}
Aggregations