Skip to content
Snippets Groups Projects
Commit 97917277 authored by Karin Pettersen's avatar Karin Pettersen
Browse files

Finished sort class

parent f3be99fe
Branches
No related tags found
No related merge requests found
...@@ -42,18 +42,18 @@ public class Sort { ...@@ -42,18 +42,18 @@ public class Sort {
} }
//getFromExistingTable sorts out treespecies, ex, width and height
public static void getFromExistingTable() throws Exception { public static void getFromExistingTable() throws Exception {
// Step 2: Prepare query job // Step 2: Prepare query job
// A "QueryJob" is a type of job that executes SQL queries // A "QueryJob" is a type of job that executes SQL queries
// we create a new job configuration from our SQL query and // 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 " + final String GET_WORD_COUNT =
"INNER JOIN sf-drying-optimization.124.int_dk_valmaticsdryingbatches ON sf-drying-optimization.124.int_gs_ds_sipalpackages.InTidTork = " + "SELECT Name, CalculatedStart, CalculatedStop FROM `sf-drying-optimization.124.int_dk_valmaticsdryingbatches`" +
"sf-drying-optimization.124.int_dk_valmaticsdryingbatches.CalculatedStart"+ "WHERE Name Like \"%Gran%\" AND Name Like \"%3ex%\" AND NAME Like \"%47x150%\" AND DATE(CalculatedStart) " +
"WHERE Name Like '%Gran%' OR Name LIKE '%2ex%' OR Name LIKE '%47x175%" + "BETWEEN \"2018-08-17\" AND \"2022-08-30\" ORDER BY DATE(CalculatedStart)";
"AND BETWEEN \"2021-08-17\" AND \"2020-08-29\" ORDER BY InTidTork"+
"LIMIT 100";
QueryJobConfiguration queryConfig = QueryJobConfiguration queryConfig =
QueryJobConfiguration.newBuilder(GET_WORD_COUNT).build(); QueryJobConfiguration.newBuilder(GET_WORD_COUNT).build();
...@@ -77,15 +77,16 @@ public class Sort { ...@@ -77,15 +77,16 @@ public class Sort {
// Step 4: Display results // Step 4: Display results
// Print out a header line, and iterate through the // Print out a header line, and iterate through the
// query results to print each result in a new line // 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(); TableResult result = queryJob.getQueryResults();
for (FieldValueList row : result.iterateAll()) { for (FieldValueList row : result.iterateAll()) {
// We can use the `get` method along with the column // We can use the `get` method along with the column
// name to get the corresponding row entry // name to get the corresponding row entry
int variantValue = row.get("VariantValue").getNumericValue().intValue(); String name = row.get("Name").getStringValue();
String timeStamp = row.get("TimeStamp").getStringValue(); String calculatedStart = row.get("CalculatedStart").getStringValue();
System.out.printf("%s\t%d\n", timeStamp, variantValue); String calculatedStop = row.get("CalculatedStop").getStringValue();
System.out.printf("%s\t%s\t%s\n", name,calculatedStart, calculatedStop);
} }
......
No preview for this file type
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment