Java Code Examples for org.apache.kylin.rest.request.PrepareSqlRequest#setProject()
The following examples show how to use
org.apache.kylin.rest.request.PrepareSqlRequest#setProject() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: QueryControllerTest.java From kylin-on-parquet-v2 with Apache License 2.0 | 5 votes |
@Test(expected = Exception.class) public void testQueryException() throws Exception { PrepareSqlRequest sqlRequest = new PrepareSqlRequest(); sqlRequest.setSql("select * from not_exist_table"); sqlRequest.setProject("default"); SQLResponse response1 = queryController.query(sqlRequest); Assert.assertEquals(false, response1.getIsException()); SQLResponse response2 = queryController.query(sqlRequest); Assert.assertEquals(false, response2.getIsException()); }
Example 2
Source File: CubeService.java From kylin-on-parquet-v2 with Apache License 2.0 | 5 votes |
private List<List<String>> getPrepareQueryResult(String cubeName, String sql) { PrepareSqlRequest sqlRequest = new PrepareSqlRequest(); sqlRequest.setProject(MetricsManager.SYSTEM_PROJECT); PrepareSqlRequest.StateParam[] params = new PrepareSqlRequest.StateParam[1]; params[0] = new PrepareSqlRequest.StateParam(); params[0].setClassName("java.lang.String"); params[0].setValue(cubeName); sqlRequest.setParams(params); sqlRequest.setSql(sql); return queryService.doQueryWithCache(sqlRequest, false).getResults(); }
Example 3
Source File: QueryControllerTest.java From kylin with Apache License 2.0 | 5 votes |
@Test(expected = Exception.class) public void testQueryException() throws Exception { PrepareSqlRequest sqlRequest = new PrepareSqlRequest(); sqlRequest.setSql("select * from not_exist_table"); sqlRequest.setProject("default"); SQLResponse response1 = queryController.query(sqlRequest); Assert.assertEquals(false, response1.getIsException()); SQLResponse response2 = queryController.query(sqlRequest); Assert.assertEquals(false, response2.getIsException()); }
Example 4
Source File: CubeService.java From kylin with Apache License 2.0 | 5 votes |
private List<List<String>> getPrepareQueryResult(String cubeName, String sql) { PrepareSqlRequest sqlRequest = new PrepareSqlRequest(); sqlRequest.setProject(MetricsManager.SYSTEM_PROJECT); PrepareSqlRequest.StateParam[] params = new PrepareSqlRequest.StateParam[1]; params[0] = new PrepareSqlRequest.StateParam(); params[0].setClassName("java.lang.String"); params[0].setValue(cubeName); sqlRequest.setParams(params); sqlRequest.setSql(sql); return queryService.doQueryWithCache(sqlRequest, false).getResults(); }
Example 5
Source File: DashboardService.java From kylin-on-parquet-v2 with Apache License 2.0 | 4 votes |
private PrepareSqlRequest createPrepareSqlRequest(String[] dimensions, String[] metrics, String category, Map<String, String> filterMap) { PrepareSqlRequest sqlRequest = new PrepareSqlRequest(); sqlRequest.setProject(MetricsManager.SYSTEM_PROJECT); StringBuffer baseSQL = new StringBuffer("select "); StringBuffer groupBy = new StringBuffer(""); if (dimensions != null && dimensions.length > 0) { groupBy.append(" group by "); StringBuffer dimensionSQL = new StringBuffer(""); for (String dimension : dimensions) { dimensionSQL.append(","); dimensionSQL.append(dimension); } baseSQL.append(dimensionSQL.substring(1)); groupBy.append(dimensionSQL.substring(1)); } if (metrics != null && metrics.length > 0) { StringBuffer metricSQL = new StringBuffer(""); for (String metric : metrics) { metricSQL.append(","); metricSQL.append(metric); } if (groupBy.length() > 0) { baseSQL.append(metricSQL); } else { baseSQL.append(metricSQL.substring(1)); } } baseSQL.append(" from "); baseSQL.append(category); if (filterMap != null && filterMap.size() > 0) { PrepareSqlRequest.StateParam[] params = new PrepareSqlRequest.StateParam[filterMap.size()]; int i = 0; StringBuffer filterSQL = new StringBuffer(" where "); Iterator<String> it = filterMap.keySet().iterator(); String filter = it.next(); filterSQL.append(filter); params[i] = new PrepareSqlRequest.StateParam(); params[i].setClassName("java.lang.String"); params[i++].setValue(filterMap.get(filter)); while (it.hasNext()) { filter = it.next(); filterSQL.append(" and "); filterSQL.append(filter); params[i] = new PrepareSqlRequest.StateParam(); params[i].setClassName("java.lang.String"); params[i++].setValue(filterMap.get(filter)); } baseSQL.append(filterSQL.toString()); sqlRequest.setParams(params); } baseSQL.append(groupBy); sqlRequest.setSql(baseSQL.toString()); return sqlRequest; }
Example 6
Source File: DashboardService.java From kylin with Apache License 2.0 | 4 votes |
private PrepareSqlRequest createPrepareSqlRequest(String[] dimensions, String[] metrics, String category, Map<String, String> filterMap) { PrepareSqlRequest sqlRequest = new PrepareSqlRequest(); sqlRequest.setProject(MetricsManager.SYSTEM_PROJECT); StringBuffer baseSQL = new StringBuffer("select "); StringBuffer groupBy = new StringBuffer(""); if (dimensions != null && dimensions.length > 0) { groupBy.append(" group by "); StringBuffer dimensionSQL = new StringBuffer(""); for (String dimension : dimensions) { dimensionSQL.append(","); dimensionSQL.append(dimension); } baseSQL.append(dimensionSQL.substring(1)); groupBy.append(dimensionSQL.substring(1)); } if (metrics != null && metrics.length > 0) { StringBuffer metricSQL = new StringBuffer(""); for (String metric : metrics) { metricSQL.append(","); metricSQL.append(metric); } if (groupBy.length() > 0) { baseSQL.append(metricSQL); } else { baseSQL.append(metricSQL.substring(1)); } } baseSQL.append(" from "); baseSQL.append(category); if (filterMap != null && filterMap.size() > 0) { PrepareSqlRequest.StateParam[] params = new PrepareSqlRequest.StateParam[filterMap.size()]; int i = 0; StringBuffer filterSQL = new StringBuffer(" where "); Iterator<String> it = filterMap.keySet().iterator(); String filter = it.next(); filterSQL.append(filter); params[i] = new PrepareSqlRequest.StateParam(); params[i].setClassName("java.lang.String"); params[i++].setValue(filterMap.get(filter)); while (it.hasNext()) { filter = it.next(); filterSQL.append(" and "); filterSQL.append(filter); params[i] = new PrepareSqlRequest.StateParam(); params[i].setClassName("java.lang.String"); params[i++].setValue(filterMap.get(filter)); } baseSQL.append(filterSQL.toString()); sqlRequest.setParams(params); } baseSQL.append(groupBy); sqlRequest.setSql(baseSQL.toString()); return sqlRequest; }