[
https://issues.apache.org/jira/browse/PHOENIX-5601?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17228829#comment-17228829
]
ASF GitHub Bot commented on PHOENIX-5601:
-----------------------------------------
ChinmaySKulkarni commented on a change in pull request #955:
URL: https://github.com/apache/phoenix/pull/955#discussion_r520143718
##########
File path:
phoenix-core/src/test/java/org/apache/phoenix/query/PhoenixTestBuilder.java
##########
@@ -294,27 +423,104 @@ public void upsertRow(int rowIndex) throws SQLException {
buf.append("?,");
}
buf.setCharAt(buf.length() - 1, ')');
-
- LOGGER.info(buf.toString());
+ LOGGER.debug(buf.toString());
Connection connection = getConnection();
try (PreparedStatement stmt =
connection.prepareStatement(buf.toString())) {
for (int i = 0; i < upsertValues.size(); i++) {
+ //TODO : handle null values
stmt.setObject(i + 1, upsertValues.get(i));
}
stmt.execute();
connection.commit();
}
+ return upsertValues;
+ }
+
+ // Upsert batch of rows.
+ public void upsertRows(int startRowIndex, int numRows) throws
SQLException {
+ dataTable.clear();
+ List<String> upsertColumns = Lists.newArrayList();
+ List<Integer> rowKeyPositions = Lists.newArrayList();
+
+ // Figure out the upsert columns based on whether this is a full
or partial row update.
+ boolean isFullRowUpdate = getColumnPositionsToUpdate().isEmpty();
+ if (isFullRowUpdate) {
+ upsertColumns.addAll(getUpsertColumns());
+ } else {
+ List<String> tmpColumns = getUpsertColumns();
+ for (int i : getColumnPositionsToUpdate()) {
+ upsertColumns.add(tmpColumns.get(i));
+ }
+ }
+
+ Set<String> rowKeys = getRowKeyColumns() == null ||
getRowKeyColumns().isEmpty() ?
+ Sets.<String>newHashSet(getUpsertColumns()) :
+ Sets.newHashSet(getRowKeyColumns());
+
+ StringBuilder buf = new StringBuilder("UPSERT INTO ");
+ buf.append(getTargetEntity());
+ buf.append("
(").append(Joiner.on(",").join(upsertColumns)).append(") VALUES(");
+ for (int i = 0; i < upsertColumns.size(); i++) {
+ buf.append("?,");
+ if (rowKeys.contains(upsertColumns.get(i))) {
+ rowKeyPositions.add(i);
+ }
+ }
+ buf.setCharAt(buf.length() - 1, ')');
+ LOGGER.debug (buf.toString());
+
+ Connection connection = getConnection();
+ try (PreparedStatement stmt =
connection.prepareStatement(buf.toString())) {
+
+ for (int r = startRowIndex; r < startRowIndex + numRows; r++) {
+ List<Object> upsertValues = Lists.newArrayList();
+ List<Object> rowValues = null;
+ try {
+ rowValues = getTestDataSupplier().getValues(r);
+ } catch (Exception e) {
+ throw new SQLException(e);
Review comment:
Why do we catch and wrap into a SQLException? I saw that in a couple
places in this class and didn't understand the reason for it.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
> Add a new Coprocessor - ViewTTLAware Coprocessor
> ------------------------------------------------
>
> Key: PHOENIX-5601
> URL: https://issues.apache.org/jira/browse/PHOENIX-5601
> Project: Phoenix
> Issue Type: Sub-task
> Affects Versions: 4.15.0, 5.1.0
> Reporter: Jacob Isaac
> Assignee: Jacob Isaac
> Priority: Major
> Attachments: PHOENIX-5601.4.x-HBase-1.3.008.patch,
> PHOENIX-5601.master.008.patch
>
>
> * Add a New coprocessor - ViewTTLAware Coprocessor that will intercept
> scan/get requests to inject a new ViewTTLAware scanner.
> The scanner will -
> * Use the row timestamp of the empty column to determine whether row TTL
> has expired and mask the rows from underlying query results.
> * Use the row timestamp to delete expired rows when DELETE_VIEW_TTL_EXPIRED
> flag is present.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)