Search in sources :

Example 6 with ProjectSomeFieldsPredicate

use of edu.uci.ics.texera.textql.statements.predicates.ProjectSomeFieldsPredicate in project textdb by TextDB.

the class CreateViewStatementTest method testGettersAndGetters.

/**
 * Test the setter methods and the getter methods.
 * Call the setter of CreateViewStatement and test if the
 * returned value by the getter is the same.
 */
@Test
public void testGettersAndGetters() {
    Statement subStatement;
    ProjectPredicate projectPredicate;
    ExtractPredicate extractPredicate;
    CreateViewStatement createViewStatement = new CreateViewStatement(null, null);
    // Tests for the id attribute
    createViewStatement.setId(null);
    Assert.assertEquals(createViewStatement.getId(), null);
    createViewStatement.setId("statementId4");
    Assert.assertEquals(createViewStatement.getId(), "statementId4");
    createViewStatement.setId("_sid0");
    Assert.assertEquals(createViewStatement.getId(), "_sid0");
    // Tests for the subStatement attribute
    createViewStatement.setSubStatement(null);
    Assert.assertEquals(createViewStatement.getSubStatement(), null);
    projectPredicate = new ProjectAllFieldsPredicate();
    subStatement = new SelectStatement("substatementId0", projectPredicate, null, "from", null, null);
    createViewStatement = new CreateViewStatement("statementId", subStatement);
    Assert.assertEquals(createViewStatement.getSubStatement(), subStatement);
    projectPredicate = new ProjectAllFieldsPredicate();
    subStatement = new SelectStatement("substatementId1", projectPredicate, null, "table", null, null);
    createViewStatement = new CreateViewStatement("statementId", subStatement);
    Assert.assertEquals(createViewStatement.getSubStatement(), subStatement);
    projectPredicate = new ProjectSomeFieldsPredicate(Arrays.asList("c", "d"));
    extractPredicate = new KeywordExtractPredicate(Arrays.asList("f0", "f1"), "xxx", KeywordMatchingType.PHRASE_INDEXBASED.toString());
    subStatement = new SelectStatement("id", projectPredicate, extractPredicate, "source", null, null);
    createViewStatement.setSubStatement(subStatement);
    Assert.assertEquals(createViewStatement.getSubStatement(), subStatement);
}
Also used : SelectStatement(edu.uci.ics.texera.textql.statements.SelectStatement) ProjectPredicate(edu.uci.ics.texera.textql.statements.predicates.ProjectPredicate) CreateViewStatement(edu.uci.ics.texera.textql.statements.CreateViewStatement) ExtractPredicate(edu.uci.ics.texera.textql.statements.predicates.ExtractPredicate) KeywordExtractPredicate(edu.uci.ics.texera.textql.statements.predicates.KeywordExtractPredicate) CreateViewStatement(edu.uci.ics.texera.textql.statements.CreateViewStatement) SelectStatement(edu.uci.ics.texera.textql.statements.SelectStatement) Statement(edu.uci.ics.texera.textql.statements.Statement) ProjectAllFieldsPredicate(edu.uci.ics.texera.textql.statements.predicates.ProjectAllFieldsPredicate) ProjectSomeFieldsPredicate(edu.uci.ics.texera.textql.statements.predicates.ProjectSomeFieldsPredicate) KeywordExtractPredicate(edu.uci.ics.texera.textql.statements.predicates.KeywordExtractPredicate) Test(org.junit.Test)

Example 7 with ProjectSomeFieldsPredicate

use of edu.uci.ics.texera.textql.statements.predicates.ProjectSomeFieldsPredicate in project textdb by TextDB.

the class SelectStatementTest method testSelectStatementBeansBuilder02.

/**
 * Test the correctness of the generated beans by a SelectStatement with a
 * ProjectSomeFieldsPredicate.
 * Get a graph by calling getInternalPredicateBases() and getInternalLinkBeans()
 * methods and check if the generated path form the node getInputNodeID() to
 * the node getOutputNodeID() is correct. Also check whether getInputViews()
 * is returning the correct dependencies.
 */
@Test
public void testSelectStatementBeansBuilder02() {
    ProjectPredicate projectPredicate = new ProjectSomeFieldsPredicate(Arrays.asList("a", "b"));
    SelectStatement selectStatement = new SelectStatement("idX", projectPredicate, null, "from", null, null);
    List<PredicateBase> expectedGeneratedBeans = Arrays.asList(new ProjectionPredicate(Arrays.asList("a", "b")));
    List<String> dependencies = Arrays.asList("from");
    Assert.assertEquals(selectStatement.getInputViews(), dependencies);
    StatementTestUtils.assertGeneratedBeans(selectStatement, expectedGeneratedBeans);
}
Also used : SelectStatement(edu.uci.ics.texera.textql.statements.SelectStatement) ProjectPredicate(edu.uci.ics.texera.textql.statements.predicates.ProjectPredicate) PredicateBase(edu.uci.ics.texera.dataflow.common.PredicateBase) ProjectSomeFieldsPredicate(edu.uci.ics.texera.textql.statements.predicates.ProjectSomeFieldsPredicate) ProjectionPredicate(edu.uci.ics.texera.dataflow.projection.ProjectionPredicate) Test(org.junit.Test)

Example 8 with ProjectSomeFieldsPredicate

use of edu.uci.ics.texera.textql.statements.predicates.ProjectSomeFieldsPredicate in project textdb by TextDB.

the class CreateViewStatementTest method testCreateViewStatementBeansBuilder01.

/**
 * Test the correctness of the generated beans by a CreateViewStatement with
 * a SelectExtractStatement as sub-statement with a
 * SelectSomeFieldsPredicate and a KeywordExtractPredicate.
 * Get a graph by calling getInternalOperatorBeans() and getInternalLinkBeans()
 * methods and check if the generated path form the node getInputNodeID() to
 * the node getOutputNodeID() is correct. Also check whether getInputViews()
 * is returning the correct dependencies.
 */
@Test
public void testCreateViewStatementBeansBuilder01() {
    ProjectPredicate projectPredicate = new ProjectSomeFieldsPredicate(Arrays.asList("x", "y"));
    ExtractPredicate extractPredicate = new KeywordExtractPredicate(Arrays.asList("a", "b"), "zzz", KeywordMatchingType.SUBSTRING_SCANBASED.toString());
    Statement subStatement = new SelectStatement("id", projectPredicate, extractPredicate, "from", null, null);
    CreateViewStatement createViewStatement = new CreateViewStatement("idx", subStatement);
    List<PredicateBase> expectedGeneratedBeans = Collections.emptyList();
    List<String> dependencies = Arrays.asList(subStatement.getId());
    Assert.assertEquals(createViewStatement.getInputViews(), dependencies);
    StatementTestUtils.assertGeneratedBeans(createViewStatement, expectedGeneratedBeans);
}
Also used : SelectStatement(edu.uci.ics.texera.textql.statements.SelectStatement) ProjectPredicate(edu.uci.ics.texera.textql.statements.predicates.ProjectPredicate) CreateViewStatement(edu.uci.ics.texera.textql.statements.CreateViewStatement) PredicateBase(edu.uci.ics.texera.dataflow.common.PredicateBase) ExtractPredicate(edu.uci.ics.texera.textql.statements.predicates.ExtractPredicate) KeywordExtractPredicate(edu.uci.ics.texera.textql.statements.predicates.KeywordExtractPredicate) CreateViewStatement(edu.uci.ics.texera.textql.statements.CreateViewStatement) SelectStatement(edu.uci.ics.texera.textql.statements.SelectStatement) Statement(edu.uci.ics.texera.textql.statements.Statement) ProjectSomeFieldsPredicate(edu.uci.ics.texera.textql.statements.predicates.ProjectSomeFieldsPredicate) KeywordExtractPredicate(edu.uci.ics.texera.textql.statements.predicates.KeywordExtractPredicate) Test(org.junit.Test)

Example 9 with ProjectSomeFieldsPredicate

use of edu.uci.ics.texera.textql.statements.predicates.ProjectSomeFieldsPredicate in project textdb by TextDB.

the class SelectStatementTest method testConstructorAndGetters.

/**
 * Test the class constructor and the getter methods.
 * Call the constructor of SelectStatement and test if the
 * returned value by the getter is the same.
 */
@Test
public void testConstructorAndGetters() {
    ProjectPredicate projectPredicate;
    ExtractPredicate extractPredicate;
    SelectStatement selectExtractStatement;
    // Tests for the id attribute
    selectExtractStatement = new SelectStatement(null, null, null, null, null, null);
    Assert.assertEquals(selectExtractStatement.getId(), null);
    selectExtractStatement = new SelectStatement("idx", null, null, null, null, null);
    Assert.assertEquals(selectExtractStatement.getId(), "idx");
    selectExtractStatement = new SelectStatement("_sid08", null, null, null, null, null);
    Assert.assertEquals(selectExtractStatement.getId(), "_sid08");
    // Tests for the projectPredicate attribute
    selectExtractStatement = new SelectStatement("", null, null, null, null, null);
    Assert.assertEquals(selectExtractStatement.getProjectPredicate(), null);
    projectPredicate = new ProjectAllFieldsPredicate();
    selectExtractStatement = new SelectStatement(null, projectPredicate, null, null, null, null);
    Assert.assertEquals(selectExtractStatement.getProjectPredicate(), projectPredicate);
    projectPredicate = new ProjectSomeFieldsPredicate(Arrays.asList("a", "b", "c"));
    selectExtractStatement = new SelectStatement(null, projectPredicate, null, null, null, null);
    Assert.assertEquals(selectExtractStatement.getProjectPredicate(), projectPredicate);
    projectPredicate = new ProjectSomeFieldsPredicate(Arrays.asList("f0", "f1"));
    selectExtractStatement = new SelectStatement(null, projectPredicate, null, null, null, null);
    Assert.assertEquals(selectExtractStatement.getProjectPredicate(), projectPredicate);
    // Tests for the extractPredicate attribute
    selectExtractStatement = new SelectStatement(null, null, null, null, null, null);
    Assert.assertEquals(selectExtractStatement.getProjectPredicate(), null);
    extractPredicate = new KeywordExtractPredicate(Arrays.asList("x", "y"), "keyword", KeywordMatchingType.SUBSTRING_SCANBASED.toString());
    selectExtractStatement = new SelectStatement(null, null, extractPredicate, null, null, null);
    Assert.assertEquals(selectExtractStatement.getExtractPredicate(), extractPredicate);
    extractPredicate = new KeywordExtractPredicate(Arrays.asList("z6", "t4"), "xyz", KeywordMatchingType.PHRASE_INDEXBASED.toString());
    selectExtractStatement = new SelectStatement(null, null, extractPredicate, null, null, null);
    Assert.assertEquals(selectExtractStatement.getExtractPredicate(), extractPredicate);
    // Tests for the fromClause attribute
    selectExtractStatement = new SelectStatement(null, null, null, null, null, null);
    selectExtractStatement.setFromClause(null);
    selectExtractStatement = new SelectStatement(null, null, null, "tab", null, null);
    selectExtractStatement.setFromClause("tab");
    selectExtractStatement = new SelectStatement(null, null, null, "t1", null, null);
    selectExtractStatement.setFromClause("t1");
    // Tests for the limitClause attribute
    selectExtractStatement = new SelectStatement(null, null, null, null, null, null);
    Assert.assertEquals(selectExtractStatement.getLimitClause(), null);
    selectExtractStatement = new SelectStatement(null, null, null, null, 0, null);
    Assert.assertEquals(selectExtractStatement.getLimitClause(), Integer.valueOf(0));
    selectExtractStatement = new SelectStatement(null, null, null, null, 8, null);
    Assert.assertEquals(selectExtractStatement.getLimitClause(), Integer.valueOf(8));
    selectExtractStatement = new SelectStatement(null, null, null, null, -151, null);
    Assert.assertEquals(selectExtractStatement.getLimitClause(), Integer.valueOf(-151));
    // Tests for the offsetClause attribute
    selectExtractStatement = new SelectStatement(null, null, null, null, null, null);
    Assert.assertEquals(selectExtractStatement.getOffsetClause(), null);
    selectExtractStatement = new SelectStatement(null, null, null, null, null, 0);
    Assert.assertEquals(selectExtractStatement.getOffsetClause(), Integer.valueOf(0));
    selectExtractStatement = new SelectStatement(null, null, null, null, null, 562);
    Assert.assertEquals(selectExtractStatement.getOffsetClause(), Integer.valueOf(562));
    selectExtractStatement = new SelectStatement(null, null, null, null, null, -98);
    Assert.assertEquals(selectExtractStatement.getOffsetClause(), Integer.valueOf(-98));
}
Also used : SelectStatement(edu.uci.ics.texera.textql.statements.SelectStatement) ProjectPredicate(edu.uci.ics.texera.textql.statements.predicates.ProjectPredicate) ExtractPredicate(edu.uci.ics.texera.textql.statements.predicates.ExtractPredicate) KeywordExtractPredicate(edu.uci.ics.texera.textql.statements.predicates.KeywordExtractPredicate) ProjectAllFieldsPredicate(edu.uci.ics.texera.textql.statements.predicates.ProjectAllFieldsPredicate) ProjectSomeFieldsPredicate(edu.uci.ics.texera.textql.statements.predicates.ProjectSomeFieldsPredicate) KeywordExtractPredicate(edu.uci.ics.texera.textql.statements.predicates.KeywordExtractPredicate) Test(org.junit.Test)

Example 10 with ProjectSomeFieldsPredicate

use of edu.uci.ics.texera.textql.statements.predicates.ProjectSomeFieldsPredicate in project textdb by TextDB.

the class SelectStatementTest method testSelectStatementBeansBuilder05.

/**
 * Test the correctness of the generated beans by a SelectStatement with a
 * ProjectAllFieldsPredicate and a KeywordExtractPredicate.
 * Get a graph by calling getInternalPredicateBases() and getInternalLinkBeans()
 * methods and check if the generated path form the node getInputNodeID() to
 * the node getOutputNodeID() is correct. Also check whether getInputViews()
 * is returning the correct dependencies.
 */
@Test
public void testSelectStatementBeansBuilder05() {
    ProjectPredicate projectPredicate = new ProjectSomeFieldsPredicate(Arrays.asList("a", "b"));
    ExtractPredicate extractPredicate = new KeywordExtractPredicate(Arrays.asList("a", "b"), "x", KeywordMatchingType.SUBSTRING_SCANBASED.toString());
    SelectStatement selectStatement = new SelectStatement("_sid4", projectPredicate, extractPredicate, "from", null, null);
    List<PredicateBase> expectedGeneratedBeans = Arrays.asList(new KeywordPredicate("x", Arrays.asList("a", "b"), null, KeywordMatchingType.SUBSTRING_SCANBASED, "_sid4_e"), new ProjectionPredicate(Arrays.asList("a", "b")));
    List<String> dependencies = Arrays.asList("from");
    Assert.assertEquals(selectStatement.getInputViews(), dependencies);
    StatementTestUtils.assertGeneratedBeans(selectStatement, expectedGeneratedBeans);
}
Also used : SelectStatement(edu.uci.ics.texera.textql.statements.SelectStatement) ProjectPredicate(edu.uci.ics.texera.textql.statements.predicates.ProjectPredicate) PredicateBase(edu.uci.ics.texera.dataflow.common.PredicateBase) ExtractPredicate(edu.uci.ics.texera.textql.statements.predicates.ExtractPredicate) KeywordExtractPredicate(edu.uci.ics.texera.textql.statements.predicates.KeywordExtractPredicate) ProjectSomeFieldsPredicate(edu.uci.ics.texera.textql.statements.predicates.ProjectSomeFieldsPredicate) KeywordExtractPredicate(edu.uci.ics.texera.textql.statements.predicates.KeywordExtractPredicate) ProjectionPredicate(edu.uci.ics.texera.dataflow.projection.ProjectionPredicate) KeywordPredicate(edu.uci.ics.texera.dataflow.keywordmatcher.KeywordPredicate) Test(org.junit.Test)

Aggregations

SelectStatement (edu.uci.ics.texera.textql.statements.SelectStatement)11 ProjectPredicate (edu.uci.ics.texera.textql.statements.predicates.ProjectPredicate)11 ProjectSomeFieldsPredicate (edu.uci.ics.texera.textql.statements.predicates.ProjectSomeFieldsPredicate)11 Test (org.junit.Test)11 ExtractPredicate (edu.uci.ics.texera.textql.statements.predicates.ExtractPredicate)10 KeywordExtractPredicate (edu.uci.ics.texera.textql.statements.predicates.KeywordExtractPredicate)10 ProjectAllFieldsPredicate (edu.uci.ics.texera.textql.statements.predicates.ProjectAllFieldsPredicate)8 CreateViewStatement (edu.uci.ics.texera.textql.statements.CreateViewStatement)7 Statement (edu.uci.ics.texera.textql.statements.Statement)7 TextQLParser (edu.uci.ics.texera.textql.languageparser.TextQLParser)4 PredicateBase (edu.uci.ics.texera.dataflow.common.PredicateBase)3 ProjectionPredicate (edu.uci.ics.texera.dataflow.projection.ProjectionPredicate)2 KeywordPredicate (edu.uci.ics.texera.dataflow.keywordmatcher.KeywordPredicate)1 ParseException (edu.uci.ics.texera.textql.languageparser.ParseException)1 TokenMgrError (edu.uci.ics.texera.textql.languageparser.TokenMgrError)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 PipedInputStream (java.io.PipedInputStream)1 PipedOutputStream (java.io.PipedOutputStream)1 PrintStream (java.io.PrintStream)1