public SelectItem getSelectItem(Column column) { if (column != null) { for (SelectItem item : getItems()) { if (column.equals(item.getColumn())) { return item; } } } return null; }
private static List<SelectItem> getSelectItems(List<Query> splitQueries) { if (splitQueries.isEmpty()) { return new ArrayList<SelectItem>(0); } return splitQueries.get(0).getSelectClause().getItems(); }
public SelectItem getSelectItem(Column column) { if (column != null) { for (SelectItem item : getItems()) { if (column.equals(item.getColumn())) { return item; } } } return null; }
private static List<SelectItem> getSelectItems(List<Query> splitQueries) { if (splitQueries.isEmpty()) { return new ArrayList<SelectItem>(0); } return splitQueries.get(0).getSelectClause().getItems(); }
@Override public String toSql(boolean includeSchemaInColumnPaths) { if (getItems().size() == 0) { return ""; } final String sql = super.toSql(includeSchemaInColumnPaths); StringBuilder sb = new StringBuilder(sql); if (_distinct) { sb.insert(AbstractQueryClause.PREFIX_SELECT.length(), "DISTINCT "); } return sb.toString(); }
@Override public String toSql(boolean includeSchemaInColumnPaths) { if (getItems().size() == 0) { return ""; } final String sql = super.toSql(includeSchemaInColumnPaths); StringBuilder sb = new StringBuilder(sql); if (_distinct) { sb.insert(AbstractQueryClause.PREFIX_SELECT.length(), "DISTINCT "); } return sb.toString(); }
protected List<SelectItem> getSelectItems() { return _query.getSelectClause().getItems(); }
protected List<SelectItem> getSelectItems() { return _query.getSelectClause().getItems(); }
/** * Constructor used for regular query execution. * * @param query * @param jdbcDataContext * @param connection * @param statement * @param resultSet * @param closeConnectionOnCloseDataSet */ public JdbcDataSet(Query query, JdbcDataContext jdbcDataContext, Connection connection, Statement statement, ResultSet resultSet, boolean closeConnectionOnCloseDataSet) { super(query.getSelectClause().getItems()); if (query == null || statement == null || resultSet == null) { throw new IllegalArgumentException("Arguments cannot be null"); } _jdbcDataContext = jdbcDataContext; _connection = connection; _closeConnectionOnCloseDataSet = closeConnectionOnCloseDataSet; _statement = statement; _resultSet = resultSet; _closed = false; _compiledQuery = null; _lease = null; }
/** * Gets the size of a row (in bytes). * * @param query * the query that will yield the rows * @return an integer representing the size of a row from the given query * (in bytes). */ protected int getRowSize(Query query) { List<SelectItem> items = query.getSelectClause().getItems(); int bytesPerRow = 0; for (SelectItem selectItem : items) { bytesPerRow += getValueSize(selectItem); } return bytesPerRow; }
/** * Gets the size of a row (in bytes). * * @param query * the query that will yield the rows * @return an integer representing the size of a row from the given query * (in bytes). */ protected int getRowSize(Query query) { List<SelectItem> items = query.getSelectClause().getItems(); int bytesPerRow = 0; for (SelectItem selectItem : items) { bytesPerRow += getValueSize(selectItem); } return bytesPerRow; }
/** * This method returns the select item of the given alias name. * * @param query * @return */ public static SelectItem getSelectItemByAlias(Query query, String alias) { List<SelectItem> selectItems = query.getSelectClause().getItems(); for (SelectItem selectItem : selectItems) { if (selectItem.getAlias() != null && selectItem.getAlias().equals(alias)) { return selectItem; } } return null; }
/** * This method returns the select item of the given alias name. * * @param query * @return */ public static SelectItem getSelectItemByAlias(Query query, String alias) { List<SelectItem> selectItems = query.getSelectClause().getItems(); for (SelectItem selectItem : selectItems) { if (selectItem.getAlias() != null && selectItem.getAlias().equals(alias)) { return selectItem; } } return null; }
/** * Determines if all the select items are 'simple' meaning that they just represent scans of values in columns. * * @param clause * @return */ private boolean isSimpleSelect(SelectClause clause) { if (clause.isDistinct()) { return false; } for (SelectItem item : clause.getItems()) { if (item.getAggregateFunction() != null || item.getExpression() != null) { return false; } } return true; }
/** * Determines if all the select items are 'simple' meaning that they just represent scans of values in columns. * * @param clause * @return */ private boolean isSimpleSelect(SelectClause clause) { if (clause.isDistinct()) { return false; } for (SelectItem item : clause.getItems()) { if (item.getAggregateFunction() != null || item.getExpression() != null) { return false; } } return true; }
/** * Gets whether a query is guaranteed to only yield a single row. Such * queries are queries that only consist of aggregation functions and no * group by clause. * * @param query * @return */ private boolean isSingleRowQuery(Query query) { if (!query.getGroupByClause().isEmpty()) { return false; } List<SelectItem> items = query.getSelectClause().getItems(); for (SelectItem item : items) { if (item.getAggregateFunction() == null) { return false; } } return true; }
/** * Gets whether a query is guaranteed to only yield a single row. Such * queries are queries that only consist of aggregation functions and no * group by clause. * * @param query * @return */ private boolean isSingleRowQuery(Query query) { if (!query.getGroupByClause().isEmpty()) { return false; } List<SelectItem> items = query.getSelectClause().getItems(); for (SelectItem item : items) { if (item.getAggregateFunction() == null) { return false; } } return true; }
public void initialize() { final Table table = _outputDataStreamJob.getOutputDataStream().getTable(); final Query query = new Query(); query.from(table).selectAll(); final List<SelectItem> selectItems = query.getSelectClause().getItems(); final ConsumeRowHandler consumeRowHandler = _publisher.createConsumeRowHandler(); _outputRowCollector = new OutputDataStreamRowCollector(_publisher, selectItems, consumeRowHandler); final OutputDataStream outputDataStream = _outputDataStreamJob.getOutputDataStream(); _component.initializeOutputDataStream(outputDataStream, query, _outputRowCollector); _publisher.getAnalysisListener() .rowProcessingBegin(_publisher.getAnalysisJob(), _publisher.getRowProcessingMetrics()); }
public Query selectAll(final FromItem fromItem) { if (fromItem.getTable() != null) { final List<Column> columns = fromItem.getTable().getColumns(); for (final Column column : columns) { select(column, fromItem); } } else if (fromItem.getJoin() != null) { selectAll(fromItem.getLeftSide()); selectAll(fromItem.getRightSide()); } else if (fromItem.getSubQuery() != null) { final List<SelectItem> items = fromItem.getSubQuery().getSelectClause().getItems(); for (final SelectItem subQuerySelectItem : items) { select(new SelectItem(subQuerySelectItem, fromItem)); } } else { throw new MetaModelException("All select items ('*') not determinable with from item: " + fromItem); } return this; }
public Query selectAll(final FromItem fromItem) { if (fromItem.getTable() != null) { final List<Column> columns = fromItem.getTable().getColumns(); for (final Column column : columns) { select(column, fromItem); } } else if (fromItem.getJoin() != null) { selectAll(fromItem.getLeftSide()); selectAll(fromItem.getRightSide()); } else if (fromItem.getSubQuery() != null) { final List<SelectItem> items = fromItem.getSubQuery().getSelectClause().getItems(); for (final SelectItem subQuerySelectItem : items) { select(new SelectItem(subQuerySelectItem, fromItem)); } } else { throw new MetaModelException("All select items ('*') not determinable with from item: " + fromItem); } return this; }