jnturton commented on a change in pull request #2422:
URL: https://github.com/apache/drill/pull/2422#discussion_r787682748
##########
File path:
contrib/storage-phoenix/src/main/java/org/apache/drill/exec/store/phoenix/PhoenixBatchReader.java
##########
@@ -67,42 +74,55 @@
public PhoenixBatchReader(PhoenixSubScan subScan) {
this.subScan = subScan;
+ this.impersonationEnabled =
subScan.getPlugin().getContext().getConfig().getBoolean(ExecConstants.IMPERSONATION_ENABLED);
}
@Override
public boolean open(SchemaNegotiator negotiator) {
+ return impersonationEnabled
+ ? ugi.doAs((PrivilegedAction<Boolean>) () -> processOpen(negotiator))
+ : processOpen(negotiator);
+ }
+
+ private boolean processOpen(SchemaNegotiator negotiator) {
try {
errorContext = negotiator.parentErrorContext();
- conn = subScan.getPlugin().getDataSource().getConnection();
- pstmt = conn.prepareStatement(subScan.getSql());
+ DataSource ds = subScan.getPlugin().getDataSource(negotiator.userName());
+ PreparedStatement pstmt =
ds.getConnection().prepareStatement(subScan.getSql());
results = pstmt.executeQuery();
meta = pstmt.getMetaData();
} catch (SQLException e) {
throw UserException
- .dataReadError(e)
- .message("Failed to execute the phoenix sql query. " +
e.getMessage())
- .addContext(errorContext)
- .build(logger);
+ .dataReadError(e)
+ .message("Failed to execute the phoenix sql query. " + e.getMessage())
+ .addContext(errorContext)
+ .build(logger);
}
Review comment:
```suggestion
} finally {
pstmt.close();
}
```
Something flagged by LGTM.
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]