/** * Creates a request that is a SQL query. */ public static Request createSqlRequest(String query) { TPlanRequestParams request = new TPlanRequestParams(); request.request_type = TRequestType.Sql; request.sql_stmt = query; return new Request(request); }
/** * Creates a request to read an entire table. */ public static Request createTableScanRequest(String table) { TPlanRequestParams request = new TPlanRequestParams(); request.request_type = TRequestType.Sql; request.sql_stmt = "SELECT * FROM " + table; return new Request(request); }
/** * Creates a request to read a projection of a table. An empty or null * projection returns the number of rows in the table (as a BIGINT). */ public static Request createProjectionRequest(String table, List<String> cols) { TPlanRequestParams request = new TPlanRequestParams(); request.request_type = TRequestType.Sql; if (cols == null || cols.size() == 0) { request.sql_stmt = "SELECT count(*) FROM " + table; } else { StringBuilder sb = new StringBuilder("SELECT "); for (int i = 0; i < cols.size(); ++i) { if (i != 0) sb.append(", "); sb.append(cols.get(i)); } sb.append(" FROM ").append(table); request.sql_stmt = sb.toString(); } return new Request(request); }
/** * Creates a request that is a PATH query. This does a full scan of the * data files in 'uri'. */ public static Request createPathRequest(String uri) { TPlanRequestParams request = new TPlanRequestParams(); request.request_type = TRequestType.Path; request.path = new TPathRequest(uri); return new Request(request); }