Skip to content

HIVE-29059: SHOW CREATE TABLE ignores all strings after tab character for VIEWs#6563

Open
cyanzheng2926 wants to merge 4 commits into
apache:masterfrom
cyanzheng2926:HIVE-29059-show_create_table_truncates_after_tab
Open

HIVE-29059: SHOW CREATE TABLE ignores all strings after tab character for VIEWs#6563
cyanzheng2926 wants to merge 4 commits into
apache:masterfrom
cyanzheng2926:HIVE-29059-show_create_table_truncates_after_tab

Conversation

@cyanzheng2926

@cyanzheng2926 cyanzheng2926 commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

… for views

What changes were proposed in this pull request?

Addresses the issue for HIVE-29059 when a view is created with actual tabs, the SHOW CREATE TABLE output would truncate all strings after the tab.

Why are the changes needed?

SHOW CREATE TABLE of a view's create comment containing tab characters should have the same behaviour as COMMENTs when running SHOW CREATE TABLE on a normal table, which should display tab as \t instead of truncating all contents after it.

Does this PR introduce any user-facing change?

Yes.
When tab is present in the create view statement, running SHOW CREATE TABLE would truncate the output after the tab. e.g.:
CREATE TABLE t1 (val1 string, val2 string);
CREATE VIEW v1 AS SELECT * FROM t1 WHERE val1 = 'a'; -- There is a tab present at val1= 'a';
SHOW CREATE TABLE v1;
-- This would originally output below:
+----------------------------------------------------+
| createtab_stmt |
+----------------------------------------------------+
| CREATE VIEW v1 AS SELECT t1.val1, t1.val2 FROM default.t1 WHERE t1.val1 |
+----------------------------------------------------+

After the fix, the tab is replaced by explicit \t which is similar to the behaviour of how SHOW CREATE TABLE deals with tabs for COMMENT. e.g.:
+----------------------------------------------------+
| createtab_stmt |
+----------------------------------------------------+
| CREATE VIEW v1 AS SELECT t1.val1, t1.val2 FROM default.t1 WHERE t1.val1\t= 'a' |
+----------------------------------------------------+

How was this patch tested?

Created show_create_table_tab_view.q which contains testing tab for several cases
Tests run on TestMiniLlapCliDriver under minillap.query.files

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Fixes HIVE-29059 where SHOW CREATE TABLE for VIEWs can truncate output after literal tab characters by escaping tab characters in the rendered VIEW DDL, and adds a qtest covering several tab-containing VIEW definitions.

Changes:

  • Escape literal tab characters (\t) in SHOW CREATE TABLE output for VIEWs.
  • Add a new clientpositive qtest that creates/views with tabs in whitespace and string literals and verifies \t escaping.
  • Add the corresponding LLAP expected output file for the new qtest.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
ql/src/java/org/apache/hadoop/hive/ql/ddl/table/create/show/ShowCreateTableOperation.java Escapes tab characters in the generated CREATE VIEW statement before writing results.
ql/src/test/queries/clientpositive/show_create_table_tab_view.q New qtest query file exercising tab characters in VIEW definitions and literals.
ql/src/test/results/clientpositive/llap/show_create_table_tab_view.q.out New LLAP golden output validating \t escaping and non-view behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread ql/src/test/queries/clientpositive/show_create_table_tab_view.q Outdated

@ayushtkn ayushtkn left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

minor comments, rest looks good

Comment thread ql/src/test/queries/clientpositive/show_create_table_tab_view.q Outdated
Comment thread ql/src/test/queries/clientpositive/show_create_table_tab_view.q Outdated
Comment thread ql/src/test/queries/clientpositive/show_create_table_tab_view.q Outdated
@cyanzheng2926

Copy link
Copy Markdown
Contributor Author

Hi @ayushtkn thanks again for the review :) I've addressed all the suggested changes.

@ayushtkn ayushtkn left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Minor comment, rest LGTM

script_pipe.q,\
scriptfile1.q,\
select_transform_hint.q,\
show_create_table_tab_view.q,\

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I don't think this is required, you can add a normal test, adding to these files is required for specific cases when u want LLAP or Tez, else by default it goes to normal CLI driver, drop this and move the q.out

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Understood, thanks!

@sonarqubecloud

Copy link
Copy Markdown

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants