Skip to content

Add config option to skip system schemas in JDBC connectors#24994

Merged
ZacBlanco merged 1 commit intoprestodb:masterfrom
infvg:system-schema-filter
May 27, 2025
Merged

Add config option to skip system schemas in JDBC connectors#24994
ZacBlanco merged 1 commit intoprestodb:masterfrom
infvg:system-schema-filter

Conversation

@infvg
Copy link
Contributor

@infvg infvg commented Apr 28, 2025

Description

Adds an option to skip schemas in JDBC connectors

Motivation and Context

Will allow users to skip system schemas in connectors

Impact

New config added

Test Plan

UTs

Contributor checklist

  • Please make sure your submission complies with our contributing guide, in particular code style and commit standards.
  • PR description addresses the issue accurately and concisely. If the change is non-trivial, a GitHub Issue is referenced.
  • Documented new properties (with its default value), SQL syntax, functions, or other functionality.
  • If release notes are required, they follow the release notes guidelines.
  • Adequate tests were added if applicable.
  • CI passed.

Release Notes

Please follow release notes guidelines and fill in the release notes below.

== RELEASE NOTES ==

JDBC Connector Changes
* Add skippable-schemas config option for jdbc connectors

@infvg infvg requested a review from a team as a code owner April 28, 2025 09:17
@infvg infvg requested a review from ZacBlanco April 28, 2025 09:17
@prestodb-ci prestodb-ci added the from:IBM PR from IBM label Apr 28, 2025
@prestodb-ci prestodb-ci requested review from a team, Dilli-Babu-Godari and ShahimSharafudeen and removed request for a team April 28, 2025 09:17
@infvg infvg force-pushed the system-schema-filter branch from 8605f5c to f2074f6 Compare April 29, 2025 08:32
@infvg infvg force-pushed the system-schema-filter branch from f2074f6 to bdeeece Compare May 1, 2025 12:47
@infvg infvg requested review from elharo and steveburnett as code owners May 1, 2025 12:47
steveburnett
steveburnett previously approved these changes May 1, 2025
Copy link
Contributor

@steveburnett steveburnett left a comment

Choose a reason for hiding this comment

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

LGTM! (docs)

Pull branch, local doc build, looks good. Thanks for the doc!

this.ignoredSystemSchemas = ImmutableSet.copyOf(Splitter.on(",").trimResults().omitEmptyStrings().split(ignoredSystemSchemas));
return this;
}
public BaseJdbcConfig setIgnoredSystemSchemas(Set<String> ignoredSystemSchemas)
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Add a newline above

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added

connectionProperties.setProperty("useUnicode", "true");
connectionProperties.setProperty("characterEncoding", "utf8");
connectionProperties.setProperty("tinyInt1isBit", "false");
config.setIgnoredSystemSchemas(concat(config.getIgnoredSystemSchemas().stream(), mySqlConfig.getAdditionalIgnoredSchemas().stream())
Copy link
Contributor

Choose a reason for hiding this comment

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

ImmutableSet.builder().addAll(set1).addAll(set2).build() is more succint

Copy link
Contributor Author

Choose a reason for hiding this comment

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

changed

return ignoredSystemSchemas;
}

@Config("ignored-system-schemas")
Copy link
Contributor

Choose a reason for hiding this comment

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

Lets call this config list-schemas-ignored-schemas or something similar to indicate how this set will be used

Copy link
Contributor Author

Choose a reason for hiding this comment

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

changed

@infvg infvg force-pushed the system-schema-filter branch from 72f87d6 to 3b252ea Compare May 5, 2025 15:12
@infvg infvg requested a review from ZacBlanco May 5, 2025 15:14
@infvg infvg force-pushed the system-schema-filter branch 2 times, most recently from 5b281f0 to d3d8750 Compare May 7, 2025 15:16
Copy link
Contributor

@ZacBlanco ZacBlanco left a comment

Choose a reason for hiding this comment

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

LGTM, but let's be a little more descriptive in the documentation

@infvg infvg force-pushed the system-schema-filter branch from d3d8750 to cff5f77 Compare May 15, 2025 09:29
@infvg infvg force-pushed the system-schema-filter branch 3 times, most recently from 3c2c51a to 9a88ea0 Compare May 20, 2025 13:42
ZacBlanco
ZacBlanco previously approved these changes May 21, 2025
Copy link
Member

@imjalpreet imjalpreet left a comment

Choose a reason for hiding this comment

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

Thanks for the PR, I had a couple of suggestions.

String schemaName = resultSet.getString("TABLE_SCHEM");
// skip internal schemas
if (!schemaName.equalsIgnoreCase("information_schema")) {
if (!listSchemasIgnoredSchemas.contains(schemaName)) {
Copy link
Member

Choose a reason for hiding this comment

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

In order to maintain the same behaviour as before, we should probably do a case-insensitive match here. Since the default value is lower case "information_schema", it won't match with non-lower case schema name like it would have earlier.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed it so that values added are automatically lowercase & changed the schemaName to lowercase

String schemaName = resultSet.getString("TABLE_CAT");
// skip internal schemas
if (!schemaName.equalsIgnoreCase("information_schema") && !schemaName.equalsIgnoreCase("mysql")) {
if (!listSchemasIgnoredSchemas.contains(schemaName)) {
Copy link
Member

Choose a reason for hiding this comment

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

Same here, we should try to maintain the same behaviour as before.

@infvg infvg force-pushed the system-schema-filter branch 2 times, most recently from c2d84f2 to 4f41443 Compare May 22, 2025 09:46
Co-authored-by: Susan Philip <70162360+SusanPhilip@users.noreply.github.com>
@infvg infvg force-pushed the system-schema-filter branch from 4f41443 to 2669785 Compare May 22, 2025 09:48
@github-actions
Copy link

github-actions bot commented May 22, 2025

Codenotify: Notifying subscribers in CODENOTIFY files for diff f9c336d...2669785.

No notifications.

Copy link
Member

@imjalpreet imjalpreet left a comment

Choose a reason for hiding this comment

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

LGTM.

We might have to modify the implementation a bit when mixed case support is added.

@ZacBlanco ZacBlanco merged commit dbe3d36 into prestodb:master May 27, 2025
98 checks passed
@ZacBlanco ZacBlanco mentioned this pull request May 29, 2025
21 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

from:IBM PR from IBM

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants