Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CALCITE-6754] Remove deprecated method calling in Driver #4112

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't we override this method now?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, we can override createPrepare() to achieve the same goal.
Since createPrepareFactory() is deprecated, maybe we shouldn't call or override it any more.

* {@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
Loading