Skip to content

Commit

Permalink
fixed view uuid type parsing
Browse files Browse the repository at this point in the history
added view with UUID

compare the UUID returned in the result

compare with constant uuid

imported static constant
  • Loading branch information
adkharat committed Feb 14, 2025
1 parent b835409 commit 6d063ad
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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");
}
}

0 comments on commit 6d063ad

Please sign in to comment.