Skip to content
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

fixed hive view uuid type parsing #24538

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

adkharat
Copy link
Contributor

@adkharat adkharat commented Feb 12, 2025

Description

Currently, creation of VIEW with UUID on hive catalog throws exception

create or replace view "hive"."dbcert_hive".vuuid as 
SELECT * FROM ( 
 VALUES 
 (cast(0 as integer), null), 
 (cast(1 as integer), UUID '12151fd2-7586-11e9-8f9e-2a86e4085a59') 
) AS t (rum, c1);

This PR fixes UUID type parsing while VIEW creation, selection on Hive

Motivation and Context

Presto is failing to recognize UUID as a valid Hive type, leading to a type resolution failure.

cannot construct instance of com.facebook.presto.hive.HiveType, problem: Error: type expected at the position 0 of uuid'but uuid is found.

Test Plan

Added a test for hive and iceberg where we create the view with uuid column and select from that view.

Release Notes

Please follow release notes guidelines and fill in the release notes below.

== RELEASE NOTES ==

General Changes
* Fix Hive ``UUID`` type parsing

@adkharat adkharat requested a review from a team as a code owner February 12, 2025 14:43
@adkharat adkharat requested a review from presto-oss February 12, 2025 14:43
@prestodb-ci prestodb-ci added the from:IBM PR from IBM label Feb 12, 2025
@prestodb-ci prestodb-ci requested review from a team, auden-woolfson and imsayari404 and removed request for a team February 12, 2025 14:43
@steveburnett
Copy link
Contributor

Thanks for the release note! Nits of formatting suggested.

== RELEASE NOTES ==

General Changes
* Fix Hive ``UUID`` type parsing. 

@adkharat adkharat force-pushed the fix_hive_uuid_type_parsing branch from 74e49fa to d5f9256 Compare February 12, 2025 15:47
@nmahadevuni
Copy link
Member

@adkharat Please add tests for both hive and iceberg.

@adkharat adkharat changed the title fixed hive uuid type parsing fixed hive view uuid type parsing Feb 13, 2025
@adkharat adkharat force-pushed the fix_hive_uuid_type_parsing branch 2 times, most recently from c9fab35 to f26adef Compare February 13, 2025 11:24
@nmahadevuni
Copy link
Member

Don't add tests in new files. You can add tests to existing test file like AbstractTestDistributedQueries.java. Existing hive and iceberg tests derive from this file. So, it will be run for both.

@adkharat adkharat force-pushed the fix_hive_uuid_type_parsing branch from f26adef to 2f396cc Compare February 14, 2025 05:03
@adkharat adkharat marked this pull request as draft February 14, 2025 06:43
@adkharat adkharat force-pushed the fix_hive_uuid_type_parsing branch 4 times, most recently from ff3bb49 to bfc7065 Compare February 14, 2025 10:42
@adkharat
Copy link
Contributor Author

adkharat commented Feb 14, 2025

Don't add tests in new files. You can add tests to existing test file like AbstractTestDistributedQueries.java. Existing hive and iceberg tests derive from this file. So, it will be run for both.

@nmahadevuni Added test case in AbstractTestDistributedQueries.java

MaterializedResult result = computeActual("SELECT c1 FROM test_hive_view WHERE rum = 1");

// Verify the result set is not empty
assertTrue(result.getMaterializedRows().size() > 0, "Result set is empty");
Copy link
Member

Choose a reason for hiding this comment

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

Can't we compare the UUID value?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, we cannot directly compare the UUID returned in the result unless casted to string.

Copy link
Member

Choose a reason for hiding this comment

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

As I see, the data maintained in materialized row for uuid is already plain string, so seems we can validate the result as follows:

assertEquals(result.getTypes(), ImmutableList.of(UUID));
assertEquals(result.getOnlyValue(), "12151fd2-7586-11e9-8f9e-2a86e4085a59");

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, it worked.
Changes pushed to compare type and UUID returned in the result.

@adkharat adkharat marked this pull request as ready for review February 14, 2025 13:14
@adkharat adkharat force-pushed the fix_hive_uuid_type_parsing branch from 52be48e to f87af61 Compare February 14, 2025 14:50
@@ -227,6 +227,9 @@ public static boolean isSupportedType(TypeInfo typeInfo)
public static HiveType valueOf(String hiveTypeName)
{
requireNonNull(hiveTypeName, "hiveTypeName is null");
if (hiveTypeName.equals("uuid")) {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
if (hiveTypeName.equals("uuid")) {
if (hiveTypeName.equals(HIVE_UUID.getTypeInfo().getTypeName())) {

Better to use HIVE_UUID.getTypeInfo().getTypeName(), since it is where the value uuid from.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks,

Done. Pushed.

@adkharat adkharat force-pushed the fix_hive_uuid_type_parsing branch from 7258103 to 9017291 Compare February 14, 2025 15:34
hantangwangd
hantangwangd previously approved these changes Feb 14, 2025
Copy link
Member

@hantangwangd hantangwangd left a comment

Choose a reason for hiding this comment

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

Thanks for the fix.

jaystarshot
jaystarshot previously approved these changes Feb 14, 2025
auden-woolfson
auden-woolfson previously approved these changes Feb 14, 2025
Copy link
Contributor

@auden-woolfson auden-woolfson left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -16,6 +16,7 @@
import com.facebook.airlift.testing.Assertions;
import com.facebook.presto.Session;
import com.facebook.presto.SystemSessionProperties;
import com.facebook.presto.common.type.UuidType;
Copy link
Member

Choose a reason for hiding this comment

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

import static com.facebook.presto.common.type.UuidType.UUID;

and use UUID in the assert function

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks,

Changes pushed.

added view with UUID

compare the UUID returned in the result

compare with constant uuid

imported static constant
@adkharat adkharat force-pushed the fix_hive_uuid_type_parsing branch from 9017291 to 6d063ad Compare February 14, 2025 22:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
from:IBM PR from IBM
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants