QueryUtil { public static String constructSelectStatement(String fullTableName, List<ColumnInfo> columnInfos,final String conditions) { Preconditions.checkNotNull(fullTableName,"Table name cannot be null"); if(columnInfos == null || columnInfos.isEmpty()) { throw new IllegalArgumentException("At least one column must be provided"); } final String escapedFullTableName = SchemaUtil.getEscapedFullTableName(fullTableName); StringBuilder query = new StringBuilder(); query.append("SELECT "); for (ColumnInfo cinfo : columnInfos) { if (cinfo != null) { String fullColumnName = getEscapedFullColumnName(cinfo.getColumnName()); query.append(fullColumnName); query.append(","); } } query.setLength(query.length() - 1); query.append(" FROM "); query.append(escapedFullTableName); if(conditions != null && conditions.length() > 0) { query.append(" WHERE (").append(conditions).append(")"); } return query.toString(); } private  QueryUtil(); static String toSQL(CompareOp op); static String constructUpsertStatement(String tableName, List<ColumnInfo> columnInfos); static String constructGenericUpsertStatement(String tableName, int numColumns); static String constructSelectStatement(String fullTableName, List<ColumnInfo> columnInfos,final String conditions); static String getUrl(String server); static String getUrl(String server, long port); static String getExplainPlan(ResultSet rs); static String getExplainPlan(ResultIterator iterator); static Connection getConnection(Configuration conf); static Connection getConnection(Properties props, Configuration conf); static String getConnectionUrl(Properties props, Configuration conf); static String getViewStatement(String schemaName, String tableName, String where); static final int COLUMN_FAMILY_POSITION; static final int COLUMN_NAME_POSITION; static final int DATA_TYPE_POSITION; static final int DATA_TYPE_NAME_POSITION; }
@Test public void testConstructSelectStatement() { assertEquals( "SELECT \"ID\",\"NAME\" FROM \"MYTAB\"", QueryUtil.constructSelectStatement("MYTAB", ImmutableList.of(ID_COLUMN,NAME_COLUMN),null)); }