public static void main(String[] args) throws RecordServiceException, IOException { String query = "select * from tpch.nation"; if (args.length == 2) query = args[1]; PlanRequestResult plan = new RecordServicePlannerClient.Builder() .planRequest(PLANNER_HOST, PLANNER_PORT, Request.createSqlRequest(query)); Schema avroSchema = SchemaUtils.convertSchema(plan.schema); System.out.println("Avro Schema:\n" + avroSchema); System.out.println("Records:"); for (int t = 0; t < plan.tasks.size(); ++t) { GenericRecords records = null; try { records = new GenericRecords(WorkerClientUtil.execTask(plan, t)); while (records.hasNext()) { GenericData.Record record = records.next(); System.out.println(record); } } finally { if (records != null) records.close(); } } } }