Uh oh!
There was an error while loading. Please reload this page.
fix(plugin-postgresql): list Redshift external schemas and their tables - #2028
Merged
Conversation
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Workflows to automatically generate PRs for you. |
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Signed-off-by: Ngô Quốc Đạt <datlechin@gmail.com>
Uh oh!
There was an error while loading. Please reload this page.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for freeto join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Redshift external schemas showed up in the sidebar but always expanded to nothing.
Root cause
Two separate facts:
CREATE EXTERNAL SCHEMAdoes create apg_namespacerow (AWS buildsSVV_EXTERNAL_SCHEMASby joiningPG_EXTERNAL_SCHEMAtopg_namespace), so the schema list was never the problem.RedshiftPluginDriver.fetchTablesread onlyinformation_schema.tables, where external tables are never rows. They exist only inSVV_EXTERNAL_TABLES.fetchColumnshad the same gap viainformation_schema.columns.So the schema node rendered and expanded empty. This covers Redshift Spectrum over S3/Glue, federated query to Aurora, RDS and MySQL, cross-database references, and datashare consumers.
The reporter's own query returned 26 rows the sidebar could not show:
What changed
Listing. A probe reads
svv_external_schemasonce per connection to classify which schemas are external. Only for those schemas does table listing additionally readsvv_external_tables, and column listing readsvv_external_columns. Local objects keep their existinginformation_schemapath untouched, so a cluster with no external catalog pays one cheap query and nothing else.Routing local browsing through an SVV view was deliberately avoided: that is what broke DBeaver 25.3.1, where every non-superuser got
permission denied for relation svv_table_infojust expanding a schema.Read-only. Redshift rejects
UPDATEandDELETEon external tables, and they have no primary key and noctidto target a row with. A newTableInfo.TableType.externalTablecarries anallowsRowEditingproperty that now feeds the grid's editability flag, from both the sidebar and the Quick Switcher. Truncate and Import are hidden. Every read path stays: browse, filter, sort, export.Tree shape. External schemas stay in the normal schema list with an "External" marker, and their tables sit in the existing Tables group with their own icon. This matches DBeaver, AWS Redshift Query Editor v2, Postico, and Beekeeper's accepted design; only Aqua Data Studio splits them into a separate hierarchy, and doing that here would mean removing schemas from where they already appear.
Redshift traps handled
has_schema_privilege,substr,current_schema, andversion()cannot appear in a query that touches ansvv_view, because that query is distributed to the compute nodes. A test asserts none of them ever appear in the generated SQL.SVV_EXTERNAL_TABLESandSVV_EXTERNAL_COLUMNScarry rows for every database on the cluster, so both are filtered byredshift_database_name. Without it, two databases each holding a schema namedspectrumwould list duplicate tables with colliding ids.tabletype. The column can be" "when the external catalog reports nothing. It is kept as a table rather than dropped.external_typereaches the UI unparsed, sostruct<given:varchar(20),family:varchar(20)>survives. Splitting it on,or<to find a length is how Postico ended up treating every external column as text.svv_table_info. Superuser-only and local-tables-only, so it is skipped for external schemas instead of being queried and returning nothing.$path,$size, and$spectrum_oidare never added to a generatedSELECT; reading them scans S3 and costs money.PluginKit ABI
Additive, no version bump. One new
PluginDatabaseDriverrequirement with a default implementation; no requirement removed, no existing public init or signature changed, no frozen type touched.scripts/check-pluginkit-abi.shagainst the merge base reports only added lines, so this needs theabi-additivelabel per its own instructions.Tests
RedshiftExternalObjectsTestscovers the generated SQL and the row classifiers, including the leader-node-only guard, the database scoping, the blanktabletype, and the three-stateis_nullable.ExternalSchemaTrackerTestscovers classification, per-database scoping, fetch dedup, failure degradation, and reset.TableInfoTests(allowsRowEditingper kind),PluginDriverAdapterTableTypeMappingTests,PluginKitABIResilienceTests,TableRowLogicTests,SidebarContextMenuLogicTests, andTableOperationSQLBuilderTests.swiftlint --strictis clean repo-wide. The SQL builders were additionally verified by compiling them standalone and running 40 assertions against the real functions.Not verified
No live Redshift cluster was available, so the queries are verified against AWS documentation and by unit tests over the generated SQL, not by execution. The Xcode build has not been run.