Skip to content

Commit 2ec7613

Browse files
adkharatnmahadevuni
authored andcommitted
fixed view uuid type parsing
added view with UUID compare the UUID returned in the result compare with constant uuid imported static constant
1 parent 704bcc9 commit 2ec7613

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

presto-hive-metastore/src/main/java/com/facebook/presto/hive/HiveType.java

+3
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,9 @@ public static boolean isSupportedType(TypeInfo typeInfo)
227227
public static HiveType valueOf(String hiveTypeName)
228228
{
229229
requireNonNull(hiveTypeName, "hiveTypeName is null");
230+
if (hiveTypeName.equals(HIVE_UUID.getTypeInfo().getTypeName())) {
231+
return HIVE_UUID;
232+
}
230233
return toHiveType(getTypeInfoFromTypeString(hiveTypeName));
231234
}
232235

presto-tests/src/main/java/com/facebook/presto/tests/AbstractTestDistributedQueries.java

+23
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
import static com.facebook.presto.SystemSessionProperties.REMOVE_REDUNDANT_CAST_TO_VARCHAR_IN_JOIN;
5252
import static com.facebook.presto.SystemSessionProperties.SHARDED_JOINS_STRATEGY;
5353
import static com.facebook.presto.SystemSessionProperties.VERBOSE_OPTIMIZER_INFO_ENABLED;
54+
import static com.facebook.presto.common.type.UuidType.UUID;
5455
import static com.facebook.presto.common.type.VarcharType.VARCHAR;
5556
import static com.facebook.presto.connector.informationSchema.InformationSchemaMetadata.INFORMATION_SCHEMA;
5657
import static com.facebook.presto.sql.tree.CreateView.Security.INVOKER;
@@ -1569,4 +1570,26 @@ private String sanitizePlan(String explain)
15691570
.replaceAll("\\[PlanNodeId (\\d+(?:,\\d+)*)\\]", "")
15701571
.replaceAll("Values => .*\n", "\n");
15711572
}
1573+
1574+
@Test
1575+
public void testViewWithUUID()
1576+
{
1577+
skipTestUnless(supportsViews());
1578+
1579+
@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)";
1580+
1581+
// Create View with UUID type in Hive
1582+
assertQuerySucceeds("CREATE VIEW test_hive_view AS " + query);
1583+
1584+
// Select UUID from the view
1585+
MaterializedResult result = computeActual("SELECT c1 FROM test_hive_view WHERE rum = 1");
1586+
1587+
// Verify the result set is not empty
1588+
assertTrue(result.getMaterializedRows().size() > 0, "Result set is empty");
1589+
assertEquals(result.getTypes(), ImmutableList.of(UUID));
1590+
assertEquals(result.getOnlyValue(), "12151fd2-7586-11e9-8f9e-2a86e4085a59");
1591+
1592+
// Drop the view after the test
1593+
assertQuerySucceeds("DROP VIEW test_hive_view");
1594+
}
15721595
}

0 commit comments

Comments
 (0)