use of com.facebook.presto.common.type.DistinctType in project presto by prestodb.
the class TestDistinctType method testSerdeAndLazyLoading.
@Test
public void testSerdeAndLazyLoading() {
DistinctType int00 = getDistinctType("test.dt.int00");
DistinctType int10 = getDistinctType("test.dt.int10");
DistinctType int11 = getDistinctType("test.dt.int11");
DistinctType int20 = getDistinctType("test.dt.int20");
DistinctType int21 = getDistinctType("test.dt.int21");
DistinctType int30 = getDistinctType("test.dt.int30");
DistinctType intAlt = getDistinctType("test.dt.int_alt");
String int00Signature = "test.dt.int00:DistinctType(test.dt.int00{integer, true, null, []})";
String int20Signature = "test.dt.int20:DistinctType(test.dt.int20{integer, true, test.dt.int10, []})";
assertEquals(int00.getTypeSignature().toString(), "test.dt.int00:DistinctType(test.dt.int00{integer, true, null, []})");
assertEquals(int20.getTypeSignature().toString(), "test.dt.int20:DistinctType(test.dt.int20{integer, true, test.dt.int10, []})");
assertEquals(getDistinctType(parseTypeSignature(int00Signature)), int00);
assertEquals(getDistinctType(parseTypeSignature(int20Signature)), int20);
assertEquals(getLowestCommonSuperType(int20, int21).get(), int10);
assertEquals(int20.getTypeSignature().toString(), "test.dt.int20:DistinctType(test.dt.int20{integer, true, test.dt.int00, [test.dt.int10]})");
assertEquals(getLowestCommonSuperType(int30, int21).get(), int10);
assertEquals(int30.getTypeSignature().toString(), "test.dt.int30:DistinctType(test.dt.int30{integer, true, test.dt.int10, [test.dt.int20]})");
assertEquals(getLowestCommonSuperType(int30, int11).get(), int00);
assertEquals(int30.getTypeSignature().toString(), "test.dt.int30:DistinctType(test.dt.int30{integer, true, test.dt.int00, [test.dt.int20, test.dt.int10]})");
assertEquals(getLowestCommonSuperType(int30, intAlt), Optional.empty());
assertEquals(int30.getTypeSignature().toString(), "test.dt.int30:DistinctType(test.dt.int30{integer, true, null, [test.dt.int20, test.dt.int10, test.dt.int00]})");
}
use of com.facebook.presto.common.type.DistinctType in project presto by prestodb.
the class TestDistinctType method testLowestCommonSuperType.
@Test
public void testLowestCommonSuperType() {
DistinctType int00 = getDistinctType("test.dt.int00");
DistinctType int10 = getDistinctType("test.dt.int10");
DistinctType int11 = getDistinctType("test.dt.int11");
DistinctType int20 = getDistinctType("test.dt.int20");
DistinctType int21 = getDistinctType("test.dt.int21");
DistinctType int30 = getDistinctType("test.dt.int30");
DistinctType intAlt = getDistinctType("test.dt.int_alt");
DistinctType varcharAlt = getDistinctType("test.dt.varchar_alt");
assertEquals(getLowestCommonSuperType(int00, int00).get(), int00);
assertEquals(getLowestCommonSuperType(int20, int21).get(), int10);
assertEquals(getLowestCommonSuperType(int21, int20).get(), int10);
assertEquals(getLowestCommonSuperType(int11, int20).get(), int00);
assertEquals(getLowestCommonSuperType(int00, int20).get(), int00);
assertEquals(getLowestCommonSuperType(int20, int30).get(), int20);
assertEquals(getLowestCommonSuperType(int30, int20).get(), int20);
assertEquals(getLowestCommonSuperType(int21, int30).get(), int10);
assertEquals(getLowestCommonSuperType(int00, intAlt), Optional.empty());
assertEquals(getLowestCommonSuperType(int00, varcharAlt), Optional.empty());
}
use of com.facebook.presto.common.type.DistinctType in project presto by prestodb.
the class TestDistinctType method testAncestorRelationship.
@Test
public void testAncestorRelationship() {
DistinctType int00 = getDistinctType("test.dt.int00");
DistinctType int10 = getDistinctType("test.dt.int10");
DistinctType int11 = getDistinctType("test.dt.int11");
DistinctType int20 = getDistinctType("test.dt.int20");
DistinctType int21 = getDistinctType("test.dt.int21");
DistinctType int30 = getDistinctType("test.dt.int30");
DistinctType intAlt = getDistinctType("test.dt.int_alt");
DistinctType varcharAlt = getDistinctType("test.dt.varchar_alt");
assertTrue(hasAncestorRelationship(int00, int00));
assertTrue(hasAncestorRelationship(int00, int20));
assertTrue(hasAncestorRelationship(int20, int00));
assertTrue(hasAncestorRelationship(int10, int20));
assertTrue(hasAncestorRelationship(int21, int10));
assertTrue(hasAncestorRelationship(int20, int00));
assertTrue(hasAncestorRelationship(int20, int30));
assertFalse(hasAncestorRelationship(int20, int21));
assertFalse(hasAncestorRelationship(int11, int20));
assertFalse(hasAncestorRelationship(int30, int21));
assertFalse(hasAncestorRelationship(int00, intAlt));
assertFalse(hasAncestorRelationship(int00, varcharAlt));
}
Aggregations