.setAllowJaggedRows(csvOptions.allowJaggedRows()) .setAllowQuotedNewlines(csvOptions.allowQuotedNewLines()) .setEncoding(csvOptions.getEncoding()) .setQuote(csvOptions.getQuote()); if (csvOptions.getSkipLeadingRows() != null) {
.setAllowJaggedRows(csvOptions.allowJaggedRows()) .setAllowQuotedNewlines(csvOptions.allowQuotedNewLines()) .setEncoding(csvOptions.getEncoding()) .setQuote(csvOptions.getQuote()); if (csvOptions.getSkipLeadingRows() != null) {
TableSchema schema = new TableSchema(); schema.setFields(new ArrayList<TableFieldSchema>()); JacksonFactory JACKSON = new JacksonFactory(); JACKSON.createJsonParser(new FileInputStream("schema.json")) .parseArrayAndClose(schema.getFields(), TableFieldSchema.class, null); schema.setFactory(JACKSON); TableReference destTable = new TableReference(); destTable.setProjectId(projectId); destTable.setDatasetId(datasetId); destTable.setTableId(tableId); FileContent content = new FileContent("application/octet-stream", new File(csv)); Job job = new Job(); JobConfiguration config = new JobConfiguration(); JobConfigurationLoad configLoad = new JobConfigurationLoad(); configLoad.setSchema(schema); configLoad.setDestinationTable(destTable); configLoad.setEncoding("UTF-8"); configLoad.setCreateDisposition("CREATE_IF_NEEDED"); config.setLoad(configLoad); job.setConfiguration(config); Insert insert = bigquery.jobs().insert(projectId, job, content); insert.setProjectId(projectId); JobReference jobRef = insert.execute().getJobReference(); String jobId = jobRef.getJobId();
.setAllowJaggedRows(csvOptions.allowJaggedRows()) .setAllowQuotedNewlines(csvOptions.allowQuotedNewLines()) .setEncoding(csvOptions.getEncoding()) .setQuote(csvOptions.getQuote()); if (csvOptions.getSkipLeadingRows() != null) {
.setAllowJaggedRows(csvOptions.allowJaggedRows()) .setAllowQuotedNewlines(csvOptions.allowQuotedNewLines()) .setEncoding(csvOptions.encoding()) .setQuote(csvOptions.quote()); if (csvOptions.skipLeadingRows() != null) {
.setAllowJaggedRows(csvOptions.allowJaggedRows()) .setAllowQuotedNewlines(csvOptions.allowQuotedNewLines()) .setEncoding(csvOptions.getEncoding()) .setQuote(csvOptions.getQuote()); if (csvOptions.getSkipLeadingRows() != null) {
.setAllowJaggedRows(csvOptions.allowJaggedRows()) .setAllowQuotedNewlines(csvOptions.allowQuotedNewLines()) .setEncoding(csvOptions.encoding()) .setQuote(csvOptions.quote()); if (csvOptions.skipLeadingRows() != null) {
.setAllowJaggedRows(csvOptions.allowJaggedRows()) .setAllowQuotedNewlines(csvOptions.allowQuotedNewLines()) .setEncoding(csvOptions.encoding()) .setQuote(csvOptions.quote()) .setSkipLeadingRows(csvOptions.skipLeadingRows());
com.google.api.services.bigquery.model.JobConfiguration toPb() { JobConfigurationLoad loadConfigurationPb = new JobConfigurationLoad(); loadConfigurationPb.setDestinationTable(destinationTable.toPb()); if (createDisposition != null) { loadConfigurationPb.setCreateDisposition(createDisposition.toString()); } if (writeDisposition != null) { loadConfigurationPb.setWriteDisposition(writeDisposition.toString()); } if (csvOptions() != null) { CsvOptions csvOptions = csvOptions(); loadConfigurationPb.setFieldDelimiter(csvOptions.fieldDelimiter()) .setAllowJaggedRows(csvOptions.allowJaggedRows()) .setAllowQuotedNewlines(csvOptions.allowQuotedNewLines()) .setEncoding(csvOptions.encoding()) .setQuote(csvOptions.quote()) .setSkipLeadingRows(csvOptions.skipLeadingRows()); } if (schema != null) { loadConfigurationPb.setSchema(schema.toPb()); } if (formatOptions != null) { loadConfigurationPb.setSourceFormat(formatOptions.type()); } loadConfigurationPb.setMaxBadRecords(maxBadRecords); loadConfigurationPb.setIgnoreUnknownValues(ignoreUnknownValues); loadConfigurationPb.setProjectionFields(projectionFields); return new com.google.api.services.bigquery.model.JobConfiguration() .setLoad(loadConfigurationPb); }