Skip to content

Commit

Permalink
Remove deprecated method calling in Driver
Browse files Browse the repository at this point in the history
  • Loading branch information
ILuffZhe committed Dec 25, 2024
1 parent a88b1e8 commit 038f919
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 16 deletions.
7 changes: 3 additions & 4 deletions core/src/main/java/org/apache/calcite/jdbc/Driver.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public Driver() {

/** Creates a Driver with a factory for {@code CalcitePrepare} objects;
* if the factory is null, the driver will call
* {@link #createPrepareFactory()}. */
* {@link CalcitePrepare#DEFAULT_FACTORY}. */
protected Driver(@Nullable Supplier<CalcitePrepare> prepareFactory) {
this.prepareFactory = prepareFactory;
}
Expand Down Expand Up @@ -101,13 +101,12 @@ public CalcitePrepare createPrepare() {
if (prepareFactory != null) {
return prepareFactory.get();
}
return createPrepareFactory().apply();
return CalcitePrepare.DEFAULT_FACTORY.apply();
}

/** Returns a factory with which to create a {@link CalcitePrepare}.
*
* <p>Now deprecated; if you wish to use a custom prepare, overrides of this
* method will still work, but we prefer that you call
* <p>Now deprecated; if you wish to use a custom prepare, please call
* {@link #withPrepareFactory(Supplier)}
* or override {@link #createPrepare()}. */
@Deprecated // to be removed before 2.0
Expand Down
13 changes: 1 addition & 12 deletions core/src/test/java/org/apache/calcite/test/JdbcTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
import org.apache.calcite.linq4j.Ord;
import org.apache.calcite.linq4j.QueryProvider;
import org.apache.calcite.linq4j.Queryable;
import org.apache.calcite.linq4j.function.Function0;
import org.apache.calcite.plan.RelOptPlanner;
import org.apache.calcite.plan.RelOptUtil;
import org.apache.calcite.prepare.CalcitePrepareImpl;
Expand Down Expand Up @@ -902,17 +901,7 @@ private void checkTableFunctionInModel(Class<?> clazz) {
checkMockDdl(counter, true,
driver2.withPrepareFactory(() -> new CountingPrepare(counter)));

// MockDdlDriver2 implements commit if we override its createPrepareFactory
// method. The method is deprecated but override still needs to work.
checkMockDdl(counter, true,
new MockDdlDriver2(counter) {
@SuppressWarnings("deprecation")
@Override protected Function0<CalcitePrepare> createPrepareFactory() {
return () -> new CountingPrepare(counter);
}
});

// MockDdlDriver2 implements commit if we override its createPrepareFactory
// MockDdlDriver2 implements commit if we override its createPrepare
// method.
checkMockDdl(counter, true,
new MockDdlDriver2(counter) {
Expand Down

0 comments on commit 038f919

Please sign in to comment.