/// <summary> /// Load Job main processing function. /// *This is written using Apis.BigQuery.v2 becuase Cloud.BigQuery did not /// support Load opertations at the time of writing. /// </summary> public Apis.Bigquery.v2.Data.Job DoLoad() { if (ShouldProcess($"{Destination.TableId} (LOAD)")) { try { var loadjob = new Apis.Bigquery.v2.Data.Job { Configuration = new JobConfiguration { Load = new JobConfigurationLoad { DestinationTable = Destination, SourceFormat = (Type == DataFormats.JSON) ? JSON_TEXT : Type.ToString(), SourceUris = SourceUris, Encoding = Encoding, FieldDelimiter = FieldDelimiter, Quote = Quote, SkipLeadingRows = SkipLeadingRows, IgnoreUnknownValues = AllowUnknownFields, AllowJaggedRows = AllowJaggedRows, AllowQuotedNewlines = AllowQuotedNewlines, WriteDisposition = WriteMode.ToString(), MaxBadRecords = MaxBadRecords ?? 0 } } }; return(Service.Jobs.Insert(loadjob, Project).Execute()); } catch (GoogleApiException ex) when(ex.HttpStatusCode == HttpStatusCode.Forbidden) { ThrowTerminatingError(new ErrorRecord(ex, "Load failed: Access denied", ErrorCategory.InvalidOperation, this)); } catch (GoogleApiException ex) when(ex.HttpStatusCode == HttpStatusCode.NotFound) { ThrowTerminatingError(new ErrorRecord(ex, "Load failed: Resource not found", ErrorCategory.InvalidOperation, this)); } catch (GoogleApiException ex) when(ex.HttpStatusCode == HttpStatusCode.Conflict) { ThrowTerminatingError(new ErrorRecord(ex, "Load failed: Duplicate resource", ErrorCategory.InvalidOperation, this)); } } return(null); }
/// <summary> /// Copy Job main processing function. /// *This is written using Apis.BigQuery.v2 becuase Cloud.BigQuery did not /// support Copy opertations at the time of writing. /// </summary> public Apis.Bigquery.v2.Data.Job DoCopy() { if (ShouldProcess($"Copying {Source.TableId} to {Destination.TableId}")) { try { var copyjob = new Apis.Bigquery.v2.Data.Job { Configuration = new JobConfiguration { Copy = new JobConfigurationTableCopy { DestinationTable = Destination, SourceTable = Source, WriteDisposition = WriteMode?.ToString() ?? WriteDisposition.WriteIfEmpty.ToString() } } }; return(Service.Jobs.Insert(copyjob, Project).Execute()); } catch (GoogleApiException ex) when(ex.HttpStatusCode == HttpStatusCode.Forbidden) { ThrowTerminatingError(new ErrorRecord(ex, "Copy failed: Access denied", ErrorCategory.InvalidOperation, this)); } catch (GoogleApiException ex) when(ex.HttpStatusCode == HttpStatusCode.NotFound) { ThrowTerminatingError(new ErrorRecord(ex, "Copy failed: Resource not found", ErrorCategory.InvalidOperation, this)); } catch (GoogleApiException ex) when(ex.HttpStatusCode == HttpStatusCode.Conflict) { ThrowTerminatingError(new ErrorRecord(ex, "Copy failed: Duplicate resource", ErrorCategory.InvalidOperation, this)); } } return(null); }