use of com.yahoo.elide.datastores.aggregation.query.Query in project elide by yahoo.
the class JoinJoinTable method testArgumentsInJoinExprCase5a.
// Both dim4a and dim5a passes same value for join expression's argument 'exprArg'
// dim4a and dim5a passes different value for join table's column argument 'joinArg'
// 1 Join expressions is generated as fixed value of joinArg is used while calling join table's column.
@Test
void testArgumentsInJoinExprCase5a() {
Map<String, Argument> dim4Arg = new HashMap<>();
dim4Arg.put("exprArg", Argument.builder().name("exprArg").value("same").build());
dim4Arg.put("joinArg", Argument.builder().name("joinArg").value("foo4").build());
SQLDimensionProjection dim4a = (SQLDimensionProjection) table.getDimensionProjection("dim4a", "dim4a", dim4Arg);
Map<String, Argument> dim5Arg = new HashMap<>();
dim5Arg.put("exprArg", Argument.builder().name("exprArg").value("same").build());
dim5Arg.put("joinArg", Argument.builder().name("joinArg").value("foo5").build());
SQLDimensionProjection dim5a = (SQLDimensionProjection) table.getDimensionProjection("dim5a", "dim5a", dim5Arg);
Query query = Query.builder().source(table).dimensionProjection(dim4a).dimensionProjection(dim5a).arguments(emptyMap()).build();
String generatedSql = engine.explain(query).get(0);
String expectedSQL = "SELECT " + NL + " DISTINCT `MainTable_join2a_157775546`.`dim1` AS `dim4a`," + NL + " `MainTable_join2a_157775546`.`dim1` AS `dim5a` " + NL + "FROM " + NL + " `main_table` AS `MainTable` " + NL + "LEFT OUTER JOIN " + NL + " `join_table` AS `MainTable_join2a_157775546` " + NL + "ON " + NL + " value = 'same' AND `MainTable`.`dim6` - 'bar' = `MainTable_join2a_157775546`.`dim4` - 'fixedFoo' ";
assertEquals(formatExpected(expectedSQL), formatGenerated(generatedSql));
}
use of com.yahoo.elide.datastores.aggregation.query.Query in project elide by yahoo.
the class JoinJoinTable method testArgumentsInJoinExprCase1.
// Both dim4 and dim5 passes same value for join expression's argument 'exprArg'
// Single Join expression is generated.
@Test
void testArgumentsInJoinExprCase1() {
Map<String, Argument> dim4Arg = new HashMap<>();
dim4Arg.put("exprArg", Argument.builder().name("exprArg").value("same").build());
SQLDimensionProjection dim4 = (SQLDimensionProjection) table.getDimensionProjection("dim4", "dim4", dim4Arg);
Map<String, Argument> dim5Arg = new HashMap<>();
dim5Arg.put("exprArg", Argument.builder().name("exprArg").value("same").build());
SQLDimensionProjection dim5 = (SQLDimensionProjection) table.getDimensionProjection("dim5", "dim5", dim5Arg);
Query query = Query.builder().source(table).dimensionProjection(dim4).dimensionProjection(dim5).arguments(emptyMap()).build();
String generatedSql = engine.explain(query).get(0);
String expectedSQL = "SELECT " + NL + " DISTINCT `MainTable_join2_201179280`.`dim1` AS `dim4`," + NL + " `MainTable_join2_201179280`.`dim1` AS `dim5` " + NL + "FROM " + NL + " `main_table` AS `MainTable` " + NL + "LEFT OUTER JOIN " + NL + " `join_table` AS `MainTable_join2_201179280` " + NL + "ON " + NL + " value = 'same' AND `MainTable`.`dim6` - 'bar' = `MainTable_join2_201179280`.`dim4` - 'foo' ";
assertEquals(formatExpected(expectedSQL), formatGenerated(generatedSql));
}
use of com.yahoo.elide.datastores.aggregation.query.Query in project elide by yahoo.
the class JoinJoinTable method testArgumentsInJoinExprCase4.
// Both dim4 and dim5 passes same value for join expression's argument 'exprArg'
// dim4 and dim5 passes different value for column argument 'arg6'
// 2 Join expressions are generated.
@Test
void testArgumentsInJoinExprCase4() {
Map<String, Argument> dim4Arg = new HashMap<>();
dim4Arg.put("exprArg", Argument.builder().name("exprArg").value("same").build());
dim4Arg.put("arg6", Argument.builder().name("arg6").value("bar4").build());
SQLDimensionProjection dim4 = (SQLDimensionProjection) table.getDimensionProjection("dim4", "dim4", dim4Arg);
Map<String, Argument> dim5Arg = new HashMap<>();
dim5Arg.put("exprArg", Argument.builder().name("exprArg").value("same").build());
dim5Arg.put("arg6", Argument.builder().name("arg6").value("bar5").build());
SQLDimensionProjection dim5 = (SQLDimensionProjection) table.getDimensionProjection("dim5", "dim5", dim5Arg);
Query query = Query.builder().source(table).dimensionProjection(dim4).dimensionProjection(dim5).arguments(emptyMap()).build();
String generatedSql = engine.explain(query).get(0);
String expectedSQL = "SELECT " + NL + " DISTINCT `MainTable_join2_148518185`.`dim1` AS `dim4`," + NL + " `MainTable_join2_209848490`.`dim1` AS `dim5` " + NL + "FROM " + NL + " `main_table` AS `MainTable` " + NL + "LEFT OUTER JOIN " + NL + " `join_table` AS `MainTable_join2_148518185` " + NL + "ON " + NL + " value = 'same' AND `MainTable`.`dim6` - 'bar4' = `MainTable_join2_148518185`.`dim4` - 'foo' " + "LEFT OUTER JOIN " + NL + " `join_table` AS `MainTable_join2_209848490` " + NL + "ON " + NL + " value = 'same' AND `MainTable`.`dim6` - 'bar5' = `MainTable_join2_209848490`.`dim4` - 'foo' ";
assertEquals(formatExpected(expectedSQL), formatGenerated(generatedSql));
}
use of com.yahoo.elide.datastores.aggregation.query.Query in project elide by yahoo.
the class JoinJoinTable method testArgumentsInJoinExprCase3.
// Both dim4 and dim5 passes same value for join expression's argument 'exprArg'
// dim4 and dim5 passes different value for join table's column argument 'joinArg'
// 2 Join expressions are generated.
@Test
void testArgumentsInJoinExprCase3() {
Map<String, Argument> dim4Arg = new HashMap<>();
dim4Arg.put("exprArg", Argument.builder().name("exprArg").value("same").build());
dim4Arg.put("joinArg", Argument.builder().name("joinArg").value("foo4").build());
SQLDimensionProjection dim4 = (SQLDimensionProjection) table.getDimensionProjection("dim4", "dim4", dim4Arg);
Map<String, Argument> dim5Arg = new HashMap<>();
dim5Arg.put("exprArg", Argument.builder().name("exprArg").value("same").build());
dim5Arg.put("joinArg", Argument.builder().name("joinArg").value("foo5").build());
SQLDimensionProjection dim5 = (SQLDimensionProjection) table.getDimensionProjection("dim5", "dim5", dim5Arg);
Query query = Query.builder().source(table).dimensionProjection(dim4).dimensionProjection(dim5).arguments(emptyMap()).build();
String generatedSql = engine.explain(query).get(0);
String expectedSQL = "SELECT " + NL + " DISTINCT `MainTable_join2_201179732`.`dim1` AS `dim4`," + NL + " `MainTable_join2_201179856`.`dim1` AS `dim5` " + NL + "FROM " + NL + " `main_table` AS `MainTable` " + NL + "LEFT OUTER JOIN " + NL + " `join_table` AS `MainTable_join2_201179732` " + NL + "ON " + NL + " value = 'same' AND `MainTable`.`dim6` - 'bar' = `MainTable_join2_201179732`.`dim4` - 'foo4' " + "LEFT OUTER JOIN " + NL + " `join_table` AS `MainTable_join2_201179856` " + NL + "ON " + NL + " value = 'same' AND `MainTable`.`dim6` - 'bar' = `MainTable_join2_201179856`.`dim4` - 'foo5' ";
assertEquals(formatExpected(expectedSQL), formatGenerated(generatedSql));
}
use of com.yahoo.elide.datastores.aggregation.query.Query in project elide by yahoo.
the class JoinJoinTable method testArgumentsInJoinExprCase2b.
// dim4x and dim5x passes different value for join expression's argument 'exprArg'
// 1 Join expression is generated as they invoke dim4 and dim5 using sql helper with same value
@Test
void testArgumentsInJoinExprCase2b() {
Map<String, Argument> dim4Arg = new HashMap<>();
dim4Arg.put("exprArg", Argument.builder().name("exprArg").value("value4").build());
SQLDimensionProjection dim4x = (SQLDimensionProjection) table.getDimensionProjection("dim4x", "dim4x", dim4Arg);
Map<String, Argument> dim5Arg = new HashMap<>();
dim5Arg.put("exprArg", Argument.builder().name("exprArg").value("value5").build());
SQLDimensionProjection dim5x = (SQLDimensionProjection) table.getDimensionProjection("dim5x", "dim5x", dim5Arg);
Query query = Query.builder().source(table).dimensionProjection(dim4x).dimensionProjection(dim5x).arguments(emptyMap()).build();
String generatedSql = engine.explain(query).get(0);
String expectedSQL = "SELECT " + NL + " DISTINCT `MainTable_join2_156385021`.`dim1` - 'value4' AS `dim4x`," + NL + " `MainTable_join2_156385021`.`dim1` - 'value5' AS `dim5x` " + NL + "FROM " + NL + " `main_table` AS `MainTable` " + NL + "LEFT OUTER JOIN " + NL + " `join_table` AS `MainTable_join2_156385021` " + NL + "ON " + NL + " value = 'fixedExpr' AND `MainTable`.`dim6` - 'bar' = `MainTable_join2_156385021`.`dim4` - 'fixedArg' ";
assertEquals(formatExpected(expectedSQL), formatGenerated(generatedSql));
}
Aggregations