fix: use schemaName as fallback for databaseName in Hive DDL/columns/view queries#1818
Open
octo-patch wants to merge 1 commit intoCodePhiliaX:mainfrom
Open
fix: use schemaName as fallback for databaseName in Hive DDL/columns/view queries#1818octo-patch wants to merge 1 commit intoCodePhiliaX:mainfrom
octo-patch wants to merge 1 commit intoCodePhiliaX:mainfrom
Conversation
…view queries (fixes CodePhiliaX#1745) In Hive, schema and database represent the same concept. When a client passes schemaName without databaseName (e.g. from the DDL export endpoint), the SQL was generated as `SHOW CREATE TABLE null.table_name`, causing a SemanticException. Apply the same schemaName fallback in tableDDL(), columns(), and view() so all three operations work correctly regardless of which field the caller populates.
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 free
to 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.
Fixes #1745
Problem
When viewing a Hive table's DDL structure, the query fails with:
Root cause: In Hive, schema and database represent the same concept. The
HiveMetaData.schemas()method already reflects this by returningSchema(name=databaseName). However, when a client calls the DDL export endpoint passing onlyschemaName(withoutdatabaseName), thetableDDL(),columns(), andview()methods all useddatabaseNamedirectly in their SQL queries — producingnull.table_namewhendatabaseNamewas absent.Solution
Apply a
schemaNamefallback in the three affected methods so the effective database name is resolved correctly:This is applied to:
tableDDL()—SHOW CREATE TABLEcolumns()—DESCRIBE FORMATTEDview()—SHOW CREATE TABLEfor viewsTesting
The fix resolves the
Table not found null.table_nameerror reported in the issue. No existing behavior is changed whendatabaseNameis already populated.