Load data from Teradata

Schedule recurring load jobs from Teradata into BigQuery.

Explore further

For detailed documentation that includes this code sample, see the following:

Code sample

Java

Before trying this sample, follow theJava setup instructions in theBigQuery quickstart using client libraries. For more information, see theBigQueryJava API reference documentation.

To authenticate to BigQuery, set up Application Default Credentials. For more information, seeSet up authentication for client libraries.

importcom.google.api.gax.rpc.ApiException;importcom.google.cloud.bigquery.datatransfer.v1.CreateTransferConfigRequest;importcom.google.cloud.bigquery.datatransfer.v1.DataTransferServiceClient;importcom.google.cloud.bigquery.datatransfer.v1.ProjectName;importcom.google.cloud.bigquery.datatransfer.v1.TransferConfig;importcom.google.protobuf.Struct;importcom.google.protobuf.Value;importjava.io.IOException;importjava.util.HashMap;importjava.util.Map;// Sample to create a teradata transfer config.publicclassCreateTeradataTransfer{publicstaticvoidmain(String[]args)throwsIOException{// TODO(developer): Replace these variables before running the sample.finalStringprojectId="MY_PROJECT_ID";StringdatasetId="MY_DATASET_ID";StringdatabaseType="Teradata";Stringbucket="cloud-sample-data";StringdatabaseName="MY_DATABASE_NAME";StringtableNamePatterns="*";StringserviceAccount="MY_SERVICE_ACCOUNT";StringschemaFilePath="/your-schema-path";Map<String,Value>params=newHashMap<>();params.put("database_type",Value.newBuilder().setStringValue(databaseType).build());params.put("bucket",Value.newBuilder().setStringValue(bucket).build());params.put("database_name",Value.newBuilder().setStringValue(databaseName).build());params.put("table_name_patterns",Value.newBuilder().setStringValue(tableNamePatterns).build());params.put("agent_service_account",Value.newBuilder().setStringValue(serviceAccount).build());params.put("schema_file_path",Value.newBuilder().setStringValue(schemaFilePath).build());TransferConfigtransferConfig=TransferConfig.newBuilder().setDestinationDatasetId(datasetId).setDisplayName("Your Teradata Config Name").setDataSourceId("on_premises").setParams(Struct.newBuilder().putAllFields(params).build()).setSchedule("every 24 hours").build();createTeradataTransfer(projectId,transferConfig);}publicstaticvoidcreateTeradataTransfer(StringprojectId,TransferConfigtransferConfig)throwsIOException{try(DataTransferServiceClientclient=DataTransferServiceClient.create()){ProjectNameparent=ProjectName.of(projectId);CreateTransferConfigRequestrequest=CreateTransferConfigRequest.newBuilder().setParent(parent.toString()).setTransferConfig(transferConfig).build();TransferConfigconfig=client.createTransferConfig(request);System.out.println("Cloud teradata transfer created successfully :"+config.getName());}catch(ApiExceptionex){System.out.print("Cloud teradata transfer was not created."+ex.toString());}}}

What's next

To search and filter code samples for other Google Cloud products, see theGoogle Cloud sample browser.

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.