Skip to content

Commit

Permalink
Use unwrap in Oracle and Phoenix connectors
Browse files Browse the repository at this point in the history
  • Loading branch information
ebyhr committed Aug 21, 2023
1 parent cc4afb5 commit 20e3927
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -757,18 +757,18 @@ private static BooleanWriteFunction oracleBooleanWriteFunction()
public static LongWriteFunction oracleRealWriteFunction()
{
return LongWriteFunction.of(Types.REAL, (statement, index, value) ->
((OraclePreparedStatement) statement).setBinaryFloat(index, intBitsToFloat(toIntExact(value))));
statement.unwrap(OraclePreparedStatement.class).setBinaryFloat(index, intBitsToFloat(toIntExact(value))));
}

public static DoubleWriteFunction oracleDoubleWriteFunction()
{
return DoubleWriteFunction.of(Types.DOUBLE, (statement, index, value) ->
((OraclePreparedStatement) statement).setBinaryDouble(index, value));
statement.unwrap(OraclePreparedStatement.class).setBinaryDouble(index, value));
}

private SliceWriteFunction oracleCharWriteFunction()
{
return SliceWriteFunction.of(Types.NCHAR, (statement, index, value) -> ((OraclePreparedStatement) statement).setFixedCHAR(index, value.toStringUtf8()));
return SliceWriteFunction.of(Types.NCHAR, (statement, index, value) -> statement.unwrap(OraclePreparedStatement.class).setFixedCHAR(index, value.toStringUtf8()));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ public PreparedStatement buildSql(ConnectorSession session, Connection connectio
table,
columnHandles,
Optional.of(split));
QueryPlan queryPlan = getQueryPlan((PhoenixPreparedStatement) query);
QueryPlan queryPlan = getQueryPlan(query.unwrap(PhoenixPreparedStatement.class));
ResultSet resultSet = getResultSet(((PhoenixSplit) split).getPhoenixInputSplit(), queryPlan);
return new DelegatePreparedStatement(query)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,13 @@ public ConnectorSplitSource getSplits(
List<JdbcColumnHandle> columns = tableHandle.getColumns()
.map(columnSet -> columnSet.stream().map(JdbcColumnHandle.class::cast).collect(toList()))
.orElseGet(() -> phoenixClient.getColumns(session, tableHandle));
PhoenixPreparedStatement inputQuery = (PhoenixPreparedStatement) phoenixClient.prepareStatement(
PhoenixPreparedStatement inputQuery = phoenixClient.prepareStatement(
session,
connection,
tableHandle,
columns,
Optional.empty());
Optional.empty())
.unwrap(PhoenixPreparedStatement.class);

int maxScansPerSplit = session.getProperty(PhoenixSessionProperties.MAX_SCANS_PER_SPLIT, Integer.class);
List<ConnectorSplit> splits = getSplits(inputQuery, maxScansPerSplit).stream()
Expand Down

0 comments on commit 20e3927

Please sign in to comment.