diff --git a/src/main/java/com/application/DB/Sort.java b/src/main/java/com/application/DB/Sort.java index 6766dde189d15807c3e0dfaf66ce2c581ee9aaa8..0164d9cac0f1d6b9a2ba42c983191939795f3ff7 100644 --- a/src/main/java/com/application/DB/Sort.java +++ b/src/main/java/com/application/DB/Sort.java @@ -42,18 +42,18 @@ public class Sort { } + //getFromExistingTable sorts out treespecies, ex, width and height + public static void getFromExistingTable() throws Exception { // Step 2: Prepare query job // A "QueryJob" is a type of job that executes SQL queries // we create a new job configuration from our SQL query and - final String GET_WORD_COUNT = "SELECT InTidTork, UtTidTork FROM sf-drying-optimization.124.int_gs_ds_sipalpackages " + - "INNER JOIN sf-drying-optimization.124.int_dk_valmaticsdryingbatches ON sf-drying-optimization.124.int_gs_ds_sipalpackages.InTidTork = " + - "sf-drying-optimization.124.int_dk_valmaticsdryingbatches.CalculatedStart"+ - "WHERE Name Like '%Gran%' OR Name LIKE '%2ex%' OR Name LIKE '%47x175%" + - "AND BETWEEN \"2021-08-17\" AND \"2020-08-29\" ORDER BY InTidTork"+ - "LIMIT 100"; + final String GET_WORD_COUNT = + "SELECT Name, CalculatedStart, CalculatedStop FROM `sf-drying-optimization.124.int_dk_valmaticsdryingbatches`" + + "WHERE Name Like \"%Gran%\" AND Name Like \"%3ex%\" AND NAME Like \"%47x150%\" AND DATE(CalculatedStart) " + + "BETWEEN \"2018-08-17\" AND \"2022-08-30\" ORDER BY DATE(CalculatedStart)"; QueryJobConfiguration queryConfig = QueryJobConfiguration.newBuilder(GET_WORD_COUNT).build(); @@ -77,15 +77,16 @@ public class Sort { // Step 4: Display results // Print out a header line, and iterate through the // query results to print each result in a new line - System.out.println("Timestamp\tVarient value"); + System.out.println("Name\tCalculatedStarted\tCalculatedStop"); TableResult result = queryJob.getQueryResults(); for (FieldValueList row : result.iterateAll()) { // We can use the `get` method along with the column // name to get the corresponding row entry - int variantValue = row.get("VariantValue").getNumericValue().intValue(); - String timeStamp = row.get("TimeStamp").getStringValue(); - System.out.printf("%s\t%d\n", timeStamp, variantValue); + String name = row.get("Name").getStringValue(); + String calculatedStart = row.get("CalculatedStart").getStringValue(); + String calculatedStop = row.get("CalculatedStop").getStringValue(); + System.out.printf("%s\t%s\t%s\n", name,calculatedStart, calculatedStop); } diff --git a/target/classes/com/application/DB/Sort.class b/target/classes/com/application/DB/Sort.class index b51d8ea87339df4aa62db8bd9a4c2a8a6826ef89..1a594c06b3520ce5e5d358f21b0ff1cf017bc63b 100644 Binary files a/target/classes/com/application/DB/Sort.class and b/target/classes/com/application/DB/Sort.class differ