コード例 #1
0
  /**
   * @return
   * @throws ExecutionException
   * @throws UnsupportedException
   */
  private LogicalWorkflow selectLogicalWorkflowWithAlias()
      throws UnsupportedException, ExecutionException {
    List<LogicalStep> stepList = new LinkedList<>();
    // Input data
    Project projectRight =
        createProject(
            CASSANDRA_CLUSTERNAME_CONSTANT,
            KEYSPACE,
            MYTABLE2_CONSTANT,
            Arrays.asList(ARTIST_CONSTANT, AGE_CONSTANT));

    projectRight.setNextStep(
        createSelect(
            Arrays.asList(
                createColumn(KEYSPACE, MYTABLE2_CONSTANT, ARTIST_CONSTANT),
                createColumn(KEYSPACE, MYTABLE2_CONSTANT, AGE_CONSTANT)),
            Arrays.asList(ARTIST_ALIAS_CONSTANT, AGE_ALIAS_CONSTANT)));

    // One initial steps
    stepList.add(projectRight);

    LogicalWorkflow logicalWorkflow = new LogicalWorkflow(stepList);

    return logicalWorkflow;
  }
コード例 #2
0
  @Test
  public void testPartialResultJoinTest() throws ConnectorException {

    // Input data
    List<LogicalStep> stepList = new LinkedList<>();
    Project projectLeft =
        createProject(
            CASSANDRA_CLUSTERNAME_CONSTANT,
            KEYSPACE,
            MYTABLE1_CONSTANT,
            Arrays.asList(ARTIST_CONSTANT, DESCRIPTION_CONSTANT, TITLE_CONSTANT, YEAR_CONSTANT));

    ResultSet resultSet = deepQueryEngine.execute(selectLogicalWorkflow()).getResultSet();
    List<ColumnMetadata> columnMetadata = resultSet.getColumnMetadata();
    List<Row> rows = resultSet.getRows();

    Join join =
        createJoinPartialResults(
            "joinId",
            createColumn(KEYSPACE, MYTABLE1_CONSTANT, ARTIST_CONSTANT),
            createColumn(KEYSPACE, MYTABLE2_CONSTANT, ARTIST_CONSTANT),
            columnMetadata,
            rows);

    join.setNextStep(
        createSelect(
            Arrays.asList(
                createColumn(KEYSPACE, MYTABLE1_CONSTANT, ARTIST_CONSTANT),
                createColumn(KEYSPACE, MYTABLE2_CONSTANT, ARTIST_CONSTANT),
                createColumn(KEYSPACE, MYTABLE2_CONSTANT, AGE_CONSTANT),
                createColumn(KEYSPACE, MYTABLE1_CONSTANT, DESCRIPTION_CONSTANT)),
            Arrays.asList(
                ARTIST_ALIAS_CONSTANT,
                ARTIST_ALIAS2_CONSTANT,
                DESCRIPTION_ALIAS_CONSTANT,
                AGE_ALIAS_CONSTANT)));
    projectLeft.setNextStep(join);

    // One initial steps
    stepList.add(projectLeft);

    LogicalWorkflow logicalWorkflow = new LogicalWorkflow(stepList);

    // Execution
    QueryResult result = deepQueryEngine.execute(logicalWorkflow);

    // Assertions
    List<ColumnMetadata> columnsMetadata = result.getResultSet().getColumnMetadata();
    List<Row> rowsList = result.getResultSet().getRows();

    // Checking results number
    assertEquals("Wrong number of rows metadata", 4, columnsMetadata.size());
    assertEquals("Wrong number of rows", 72, rowsList.size());

    // Checking metadata
    assertEquals(
        "Author expected", ARTIST_ALIAS_CONSTANT, columnsMetadata.get(0).getName().getAlias());
    assertEquals(
        "Author expected", ARTIST_ALIAS2_CONSTANT, columnsMetadata.get(1).getName().getAlias());
    assertEquals(
        "Author expected", DESCRIPTION_ALIAS_CONSTANT, columnsMetadata.get(2).getName().getAlias());
    assertEquals(
        "Author expected", AGE_ALIAS_CONSTANT, columnsMetadata.get(3).getName().getAlias());
    assertEquals(
        "mytable1 expected",
        KEYSPACE + "." + MYTABLE1_CONSTANT,
        columnsMetadata.get(0).getName().getTableName().getQualifiedName());
    assertEquals(
        "mytable2 expected",
        KEYSPACE + "." + MYTABLE2_CONSTANT,
        columnsMetadata.get(1).getName().getTableName().getQualifiedName());
    assertEquals(
        "mytable2 expected",
        KEYSPACE + "." + MYTABLE2_CONSTANT,
        columnsMetadata.get(2).getName().getTableName().getQualifiedName());
    assertEquals(
        "mytable1 expected",
        KEYSPACE + "." + MYTABLE1_CONSTANT,
        columnsMetadata.get(3).getName().getTableName().getQualifiedName());

    // Checking rows
    for (Row row : rowsList) {
      assertEquals("Wrong number of columns in the row", 4, row.size());
      assertNotNull("Expecting author column in row", row.getCell(ARTIST_ALIAS_CONSTANT));
      assertNotNull("Expecting author column in row", row.getCell(ARTIST_ALIAS2_CONSTANT));
      assertNotNull("Expecting author column in row", row.getCell(DESCRIPTION_ALIAS_CONSTANT));
      assertNotNull("Expecting author column in row", row.getCell(AGE_ALIAS_CONSTANT));
    }
  }