@@ -490,21 +510,32 @@ public class DSLQueriesTest extends BasicTestSetup {
@DataProvider(name="errorQueriesProvider")
privateObject[][]errorQueries(){
returnnewObject[][]{
{"`isa`"},
{"PIII"},
{"DBBB as d select d"},
{"`isa`"},// Tag doesn't exist in the test data
{"PIII"},// same as above
{"DBBB as d select d"},// same as above
{"hive_db has db"},// same as above
{"hive_table where (name = \"sales_fact\" and createTime >= \"2014-12-11\" ) select name as _col_0, createTime as _col_1 orderby name limit 0 offset 1"},
{"hive_table as t, sd, hive_column as c where t.name=\"sales_fact\" select c.name as colName, c.dataType as colType"}
{"hive_table as t, sd, hive_column as c where t.name=\"sales_fact\" select c.name as colName, c.dataType as colType"},
{"hive_table isa hive_db"},// isa should be a trait/classification
{"hive_table isa FooTag"},// FooTag doesn't exist
{"hive_table groupby(db.name)"},// GroupBy on referred attribute is not supported
{"hive_table orderby(db.name)"},// OrderBy on referred attribute is not supported
{"hive_table select db, columns"},// Can't select multiple referred attributes/entity
{"hive_table select min(db.name), columns"},// Can't do aggregation on referred attribute
{"hive_table select db.name, columns"},// Can't select more than one referred attribute
{"hive_table select owner, columns"},// Can't select a mix of immediate attribute and referred entity
{"hive_table select owner, db.name"},// Same as above
{"hive_order"},// From src should be an Entity or Classification
verify("hive_db as d owner = ['hdfs', 'anon']","g.V().has('__typeName', 'hive_db').as('d').has('hive_db.owner', within('hdfs','anon')).limit(25).toList()");
verify("DB where owner = ['hdfs', 'anon']","g.V().has('__typeName', 'DB').has('DB.owner', within('hdfs','anon')).limit(local, 25).limit(25).toList()");
verify("hive_db as d owner = ['hdfs', 'anon']","g.V().has('__typeName', 'hive_db').as('d').has('hive_db.owner', within('hdfs','anon')).limit(local, 25).limit(25).toList()");
}
@Test
publicvoidgroupByMin(){
verify("from DB groupby (owner) select min(name) orderby name limit 2",
verify("Table isa 'Dimension' and t.name = 'sales_fact'","g.V().has('__typeName', 'Table').has('__traitNames', within(''Dimension'')).limit(25).toList()");
verify("Table isa 'Dimension' and name = 'sales_fact'","g.V().has('__typeName', 'Table').and(__.has('__traitNames', within('Dimension')),__.has('Table.name', eq('sales_fact'))).limit(local, 25).limit(25).toList()");
verify("Table has name and name = 'sales_fact'","g.V().has('__typeName', 'Table').and(__.has('Table.name'),__.has('Table.name', eq('sales_fact'))).limit(local, 25).limit(25).toList()");
verify("Table is 'Dimension' and Table has owner and name = 'sales_fact'","g.V().has('__typeName', 'Table').and(__.has('__traitNames', within('Dimension')),__.has('Table.owner'),__.has('Table.name', eq('sales_fact'))).limit(local, 25).limit(25).toList()");
verify("Table has name and Table has owner and name = 'sales_fact'","g.V().has('__typeName', 'Table').and(__.has('Table.name'),__.has('Table.owner'),__.has('Table.name', eq('sales_fact'))).limit(local, 25).limit(25).toList()");
}
@Test
publicvoidsystemAttributes(){
verify("Table has __state","g.V().has('__typeName', 'Table').has('__state').limit(local, 25).limit(25).toList()");
verify("Table as t where t.__state = 'ACTIVE'","g.V().has('__typeName', 'Table').as('t').has('__state', eq('ACTIVE')).limit(local, 25).limit(25).toList()");