hiveService/src/main/java/com/ge/research/semtk/edc/services/hive/HiveServiceRestController.java
@CrossOrigin
	@RequestMapping(value="/stat", method= RequestMethod.POST)
	public JSONObject stat(@RequestBody HiveServiceStatRequestBody requestBody){

		String query = "";
		for (ColumnOperation co : requestBody.columnOperations) {
			String operation = null;
			String op = co.operation;
			if (op == null)
				op = "";
			op = op.toLowerCase ();
			switch (op) {
				case "min":	operation = "min";
						break;
				case "max":	operation = "max";
						break;
				case "avg":	operation = "avg";
						break;
				case "sum":	operation = "sum";
						break;
				case "variance": operation = "variance";
						break;
				case "stddev":	operation = "stddev_pop";
						break;
				default:	TableResultSet tableResultSet = new TableResultSet();
						tableResultSet.setSuccess(false);
						tableResultSet.addRationaleMessage("Unknown operation: " + co.operation + ".\n  Valid options are: min, max, avg, sum, variance, and stddev.");
						return tableResultSet.toJson();
			}
			if (!query.equals (""))
				query += ", ";
			query += operation + "(cast(" + co.column + " as DOUBLE)) as " + co.operation + "_" + co.column;
		}

		query = "select " + query + " from " + requestBody.table;
		return runQuery (requestBody, query);
	}
/**
	 * Execute stats query on one or more columns in Hive
	 */
Execute stats query on one or more columns in Hive
Execute stats query on one or more columns in Hive
@CrossOrigin
	@RequestMapping(value="/stat", method= RequestMethod.POST)
	public JSONObject stat(@RequestBody HiveServiceStatRequestBody requestBody){
		String query = "";
		for (ColumnOperation co : requestBody.columnOperations) {
			String operation = null;
			String op = co.operation;
			if (op == null)
				op = "";
			op = op.toLowerCase ();
			switch (op) {
				case "min":	operation = "min";
						break;
				case "max":	operation = "max";
						break;
				case "avg":	operation = "avg";
						break;
				case "sum":	operation = "sum";
						break;
				case "variance": operation = "variance";
						break;
				case "stddev":	operation = "stddev_pop";
						break;
				default:	TableResultSet tableResultSet = new TableResultSet();
						tableResultSet.setSuccess(false);
						tableResultSet.addRationaleMessage("Unknown operation: " + co.operation + ".\n  Valid options are: min, max, avg, sum, variance, and stddev.");
						return tableResultSet.toJson();
			}
			if (!query.equals (""))
				query += ", ";
			query += operation + "(cast(" + co.column + " as DOUBLE)) as " + co.operation + "_" + co.column;
		}
		query = "select " + query + " from " + requestBody.table;
		return runQuery (requestBody, query);
	}
@ CrossOrigin @ RequestMapping ( value = "/stat" , method = RequestMethod . POST ) public JSONObject stat ( @ RequestBody HiveServiceStatRequestBody requestBody ) { String query = "" ; for ( ColumnOperation co : requestBody . columnOperations ) { String operation = null ; String op = co . operation ; if ( op == null ) op = "" ; op = op . toLowerCase ( ) ; switch ( op ) { case "min" : operation = "min" ; break ; case "max" : operation = "max" ; break ; case "avg" : operation = "avg" ; break ; case "sum" : operation = "sum" ; break ; case "variance" : operation = "variance" ; break ; case "stddev" : operation = "stddev_pop" ; break ; default : TableResultSet tableResultSet = new TableResultSet ( ) ; tableResultSet . setSuccess ( false ) ; tableResultSet . addRationaleMessage ( "Unknown operation: " + co . operation + ".\n  Valid options are: min, max, avg, sum, variance, and stddev." ) ; return tableResultSet . toJson ( ) ; } if ( ! query . equals ( "" ) ) query += ", " ; query += operation + "(cast(" + co . column + " as DOUBLE)) as " + co . operation + "_" + co . column ; } query = "select " + query + " from " + requestBody . table ; return runQuery ( requestBody , query ) ; }
Execute stats query on one or more columns in Hive
Execute stats query on one or more columns in Hive