From 6d063ad5c11f259cdd5e0b44a579f93849207649 Mon Sep 17 00:00:00 2001 From: ajay-kharat Date: Wed, 12 Feb 2025 20:05:12 +0530 Subject: [PATCH] fixed view uuid type parsing added view with UUID compare the UUID returned in the result compare with constant uuid imported static constant --- .../com/facebook/presto/hive/HiveType.java | 3 +++ .../tests/AbstractTestDistributedQueries.java | 23 +++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/presto-hive-metastore/src/main/java/com/facebook/presto/hive/HiveType.java b/presto-hive-metastore/src/main/java/com/facebook/presto/hive/HiveType.java index d6d641362bc93..b1a8bbb47d13a 100644 --- a/presto-hive-metastore/src/main/java/com/facebook/presto/hive/HiveType.java +++ b/presto-hive-metastore/src/main/java/com/facebook/presto/hive/HiveType.java @@ -227,6 +227,9 @@ public static boolean isSupportedType(TypeInfo typeInfo) public static HiveType valueOf(String hiveTypeName) { requireNonNull(hiveTypeName, "hiveTypeName is null"); + if (hiveTypeName.equals(HIVE_UUID.getTypeInfo().getTypeName())) { + return HIVE_UUID; + } return toHiveType(getTypeInfoFromTypeString(hiveTypeName)); } diff --git a/presto-tests/src/main/java/com/facebook/presto/tests/AbstractTestDistributedQueries.java b/presto-tests/src/main/java/com/facebook/presto/tests/AbstractTestDistributedQueries.java index af59766dd458e..6ebab94288f00 100644 --- a/presto-tests/src/main/java/com/facebook/presto/tests/AbstractTestDistributedQueries.java +++ b/presto-tests/src/main/java/com/facebook/presto/tests/AbstractTestDistributedQueries.java @@ -51,6 +51,7 @@ import static com.facebook.presto.SystemSessionProperties.REMOVE_REDUNDANT_CAST_TO_VARCHAR_IN_JOIN; import static com.facebook.presto.SystemSessionProperties.SHARDED_JOINS_STRATEGY; import static com.facebook.presto.SystemSessionProperties.VERBOSE_OPTIMIZER_INFO_ENABLED; +import static com.facebook.presto.common.type.UuidType.UUID; import static com.facebook.presto.common.type.VarcharType.VARCHAR; import static com.facebook.presto.connector.informationSchema.InformationSchemaMetadata.INFORMATION_SCHEMA; import static com.facebook.presto.sql.tree.CreateView.Security.INVOKER; @@ -1569,4 +1570,26 @@ private String sanitizePlan(String explain) .replaceAll("\\[PlanNodeId (\\d+(?:,\\d+)*)\\]", "") .replaceAll("Values => .*\n", "\n"); } + + @Test + public void testViewWithUUID() + { + skipTestUnless(supportsViews()); + + @Language("SQL") String query = "SELECT * FROM (VALUES (CAST(0 AS INTEGER), NULL), (CAST(1 AS INTEGER), UUID '12151fd2-7586-11e9-8f9e-2a86e4085a59')) AS t (rum, c1)"; + + // Create View with UUID type in Hive + assertQuerySucceeds("CREATE VIEW test_hive_view AS " + query); + + // Select UUID from the view + 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"); + assertEquals(result.getTypes(), ImmutableList.of(UUID)); + assertEquals(result.getOnlyValue(), "12151fd2-7586-11e9-8f9e-2a86e4085a59"); + + // Drop the view after the test + assertQuerySucceeds("DROP VIEW test_hive_view"); + } }