Skip to content

Remove location from SHOW CREATE TABLE for translated table#28494

Open
Kundannitp wants to merge 3 commits intotrinodb:masterfrom
Kundannitp:fix-hive-managed-location
Open

Remove location from SHOW CREATE TABLE for translated table#28494
Kundannitp wants to merge 3 commits intotrinodb:masterfrom
Kundannitp:fix-hive-managed-location

Conversation

@Kundannitp
Copy link

Fixes #28483

Currently, the SHOW CREATE TABLE command for the Hive connector returns the managed table's path as external_location. This causes confusion as to whether the table is actually managed or external, violating the Principle of Least Surprise.

This change restricts the external_location property from being printed for managed tables that were silently translated to external tables by Hive.

Additional context and related issues
Previously, the if condition only checked if the table type was EXTERNAL_TABLE before appending the external_location property to the DDL.

However, in Hive 3.x+, Hive intercepts non-transactional managed table creations and silently converts them to external tables to bypass ACID requirements. When doing so, Hive marks the table parameter "TRANSLATED_TO_EXTERNAL" as "true".

To fix this, we now explicitly check this parameter. If the table is external but was translated by Hive, we treat it as a managed table for the purpose of SHOW CREATE TABLE and omit the external_location property.

Release notes
( ) This is not user-visible or is docs only, and no release notes are required.
( ) Release notes are required. Please propose a release note for me.
(x) Release notes are required, with the following suggested text:

Hive Connector

  • Fix SHOW CREATE TABLE exposing external_location for managed tables. ({issue}28483)

In the output of "SHOW CREATE TABLE" cmd 'external_location' is getting printed for managed table as well.
This change will restrict that for those managed table which got translated to external table by hive.
@cla-bot
Copy link

cla-bot bot commented Mar 1, 2026

Thank you for your pull request and welcome to the Trino community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. Continue to work with us on the review and improvements in this PR, and submit the signed CLA to cla@trino.io. Photos, scans, or digitally-signed PDF files are all suitable. Processing may take a few days. The CLA needs to be on file before we merge your changes. For more information, see https://github.com/trinodb/cla

@github-actions github-actions bot added the hive Hive connector label Mar 1, 2026
@ebyhr
Copy link
Member

ebyhr commented Mar 2, 2026

Could you please add a test?

@Kundannitp
Copy link
Author

@ebyhr Thanks for the review.
Actually tests are already present for this scenario but the error can only be observed if tests run on a actual hive and trino server. Please refer this #28483 (comment) for why its not captured in current tests.
So not sure if we can add a test which will run on a real setup.
If you can point out any scenario where such a test added I can use it as a reference.

@ebyhr
Copy link
Member

ebyhr commented Mar 2, 2026

@Kundannitp We already have test classes (e.g. BaseTestHiveOnDataLake) with dockerized Hive.

@Kundannitp
Copy link
Author

okay thanks
Let me check

@cla-bot
Copy link

cla-bot bot commented Mar 2, 2026

Thank you for your pull request and welcome to the Trino community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. Continue to work with us on the review and improvements in this PR, and submit the signed CLA to cla@trino.io. Photos, scans, or digitally-signed PDF files are all suitable. Processing may take a few days. The CLA needs to be on file before we merge your changes. For more information, see https://github.com/trinodb/cla

@cla-bot
Copy link

cla-bot bot commented Mar 2, 2026

Thank you for your pull request and welcome to the Trino community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. Continue to work with us on the review and improvements in this PR, and submit the signed CLA to cla@trino.io. Photos, scans, or digitally-signed PDF files are all suitable. Processing may take a few days. The CLA needs to be on file before we merge your changes. For more information, see https://github.com/trinodb/cla

@Kundannitp
Copy link
Author

@ebyhr
Thanks for pointing out the correct test file.
Added tests, pls check

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

hive Hive connector

Development

Successfully merging this pull request may close these issues.

SHOW CREATE TABLE return managed table path as external_location for hive connector

3 participants