use of com.yahoo.elide.datastores.aggregation.dynamic.TableType in project elide by yahoo.
the class QueryKeyExtractorTest method testDuplicateFullQuery.
@Test
public void testDuplicateFullQuery() throws Exception {
// Build 1st Table
NamespaceConfig testNamespace = NamespaceConfig.builder().name("namespace1").build();
NamespacePackage testNamespacePackage = new NamespacePackage(testNamespace);
Table testTable = Table.builder().cardinality("medium").description("A test table").friendlyName("foo").table("table1").name("Table").schema("db1").category("category1").readAccess("Admin").dbConnectionName("dbConn").isFact(true).filterTemplate("a==b").namespace("namespace1").dimension(Dimension.builder().name("dim1").definition("{{dim1}}").type(Type.BOOLEAN).values(Collections.EMPTY_SET).tags(Collections.EMPTY_SET).build()).build();
TableType testType = new TableType(testTable, testNamespacePackage);
dictionary.bindEntity(testType);
SQLTable testSqlTable = new SQLTable(new Namespace(testNamespacePackage), testType, dictionary);
// Build 2nd Table
NamespaceConfig anotherTestNamespace = NamespaceConfig.builder().name("namespace2").build();
NamespacePackage anotherTestNamespacePackage = new NamespacePackage(anotherTestNamespace);
Table anotherTestTable = // Exactly same as testTable but different namespace
Table.builder().cardinality("medium").description("A test table").friendlyName("foo").table("table1").name("Table").schema("db1").category("category1").readAccess("Admin").dbConnectionName("dbConn").isFact(true).filterTemplate("a==b").namespace("namespace2").dimension(Dimension.builder().name("dim1").definition("{{dim1}}").type(Type.BOOLEAN).values(Collections.EMPTY_SET).tags(Collections.EMPTY_SET).build()).build();
TableType anotherTestType = new TableType(anotherTestTable, anotherTestNamespacePackage);
dictionary.bindEntity(anotherTestType);
SQLTable anotherTestSqlTable = new SQLTable(new Namespace(anotherTestNamespacePackage), anotherTestType, dictionary);
// Build Query and Test
Query query = Query.builder().source(testSqlTable).dimensionProjection(testSqlTable.getDimensionProjection("dim1")).pagination(new ImmutablePagination(0, 2, false, true)).build();
assertEquals(// table name
"namespace1_Table;" + // metrics
"{}" + // Group by
"{dim1;{}}" + // time dimensions
"{}" + // where
";" + // having
";" + // sort
";" + // pagination
"{0;2;1;}", QueryKeyExtractor.extractKey(query));
Query anotherQuery = Query.builder().source(anotherTestSqlTable).dimensionProjection(anotherTestSqlTable.getDimensionProjection("dim1")).pagination(new ImmutablePagination(0, 2, false, true)).build();
assertEquals(// table name
"namespace2_Table;" + // metrics
"{}" + // Group by
"{dim1;{}}" + // time dimensions
"{}" + // where
";" + // having
";" + // sort
";" + // pagination
"{0;2;1;}", QueryKeyExtractor.extractKey(anotherQuery));
assertNotEquals(QueryKeyExtractor.extractKey(anotherQuery), QueryKeyExtractor.extractKey(query));
}
Aggregations