Skip to content

feat: Filter out system views out of system namespaces #22221

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

Merged
merged 7 commits into from
Feb 6, 2023
Merged
Show file tree
Hide file tree
Changes from 5 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
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,11 @@ public Set<String> getExcludedInternalNameSpaces() {
return Collections.emptySet();
}

@Override
protected Set<String> getExcludedViews() {
return Collections.emptySet();
}

@Override
protected List<TableInfo<CommonField<StandardSQLTypeName>>> discoverInternal(final BigQueryDatabase database) throws Exception {
return discoverInternal(database, null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ public Set<String> getExcludedInternalNameSpaces() {
return Set.of("information_schema", "pg_catalog", "pg_internal", "catalog_history");
}

@Override
protected Set<String> getExcludedViews() {
return Set.of("pg_stat_statements", "pg_stat_statements_info");
}

public static void main(final String[] args) throws Exception {
final Source source = new JdbcSource();
LOGGER.info("starting source: {}", JdbcSource.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,11 @@ public Set<String> getExcludedInternalNameSpaces() {
return Collections.emptySet();
}

@Override
protected Set<String> getExcludedViews() {
return Collections.emptySet();
}

@Override
protected List<TableInfo<CommonField<BsonType>>> discoverInternal(final MongoDatabase database)
throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,11 @@ public Set<String> getExcludedInternalNameSpaces() {
return Set.of("information_schema", "pg_catalog", "pg_internal", "catalog_history");
}

@Override
protected Set<String> getExcludedViews() {
return Set.of("pg_stat_statements", "pg_stat_statements_info");
}

@Override
public AirbyteCatalog discover(final JsonNode config) throws Exception {
final AirbyteCatalog catalog = super.discover(config);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,11 @@ public Set<String> getExcludedInternalNameSpaces() {
return Set.of("information_schema", "pg_catalog", "pg_internal", "catalog_history");
}

@Override
protected Set<String> getExcludedViews() {
return Set.of("pg_stat_statements", "pg_stat_statements_info");
}

public static void main(final String[] args) throws Exception {
final Source source = new PostgresTestSource();
LOGGER.info("starting source: {}", PostgresTestSource.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,10 +271,11 @@ private List<TableInfo<CommonField<DataType>>> discoverWithoutSystemTables(
final Database database)
throws Exception {
final Set<String> systemNameSpaces = getExcludedInternalNameSpaces();
final Set<String> systemViews = getExcludedViews();
final List<TableInfo<CommonField<DataType>>> discoveredTables = discoverInternal(database);
return (systemNameSpaces == null || systemNameSpaces.isEmpty() ? discoveredTables
: discoveredTables.stream()
.filter(table -> !systemNameSpaces.contains(table.getNameSpace())).collect(
.filter(table -> !systemNameSpaces.contains(table.getNameSpace()) && !systemViews.contains(table.getName())).collect(
Collectors.toList()));
}

Expand Down Expand Up @@ -634,12 +635,19 @@ protected abstract List<CheckedConsumer<Database, Exception>> getCheckOperations
protected abstract JsonSchemaType getAirbyteType(DataType columnType);

/**
* Get list of system namespaces(schemas) in order to exclude them from the discover result list.
* Get list of system namespaces(schemas) in order to exclude them from the `discover` result list.
*
* @return set of system namespaces(schemas) to be excluded
*/
protected abstract Set<String> getExcludedInternalNameSpaces();

/**
* Get list of system views in order to exclude them from the `discover` result list.
*
* @return set of views to be excluded
*/
protected abstract Set<String> getExcludedViews();

/**
* Discover all available tables in the source database.
*
Expand Down