No data is uploaded, but job status is DONE in bigquery load job using java -
i trying upload csv file, in right format. if try upload 3 rows of data, works, large file says socket-timeout exception our job done. dataset in other location.
bigquery bigquery = googleconnector.getbigquery(); tableschema schema = new tableschema(); list<tablefieldschema> tablefieldschema = gettablefieldschema("mostrecentobservation"); schema.setfields(tablefieldschema); table table = new table(); table.setschema(schema); tablereference tableref = new tablereference(); tableref.setdatasetid("metromallseu"); tableref.setprojectid(projectid); tableref.settableid("mostrecentobstest"); table.settablereference(tableref); filecontent content = new filecontent("application/octet-stream", new file(filenametoload)); job job = new job(); jobconfiguration config = new jobconfiguration(); jobconfigurationload configload = new jobconfigurationload(); configload.setschema(schema); configload.setdestinationtable(tableref); configload.setencoding("utf-8"); configload.setcreatedisposition("create_if_needed"); configload.setsourceformat("csv"); // configload.setskipleadingrows(1); config.setload(configload); job.setconfiguration(config); try { bigquery.jobs.insert insert = bigquery.jobs().insert(projectid, job, content); insert.setprojectid(projectid); jobreference jobref = insert.execute().getjobreference(); string jobid = jobref.getjobid(); string status; while (!bigquery.jobs(). get(projectid, jobid).execute().getstatus().getstate().equalsignorecase("done")) { status = bigquery.jobs(). get(projectid, jobid).execute().getstatus().getstate(); system.out.println("status: " + status); thread.sleep(1000); } }catch (exception e){ e.printstacktrace(); }
check documentation status
property of job -
status.state
tells of job completed or not if completed ('done') - still need check how completed - or without errors - can use status.errorresult
property this
Comments
Post a Comment