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

Finished sort class

parent f3be99fe
No related branches found
No related tags found
No related merge requests found
......@@ -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);
}
......
No preview for this file type
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment