Example #1
0
  // test that if scan columns are specified the output schema of
  // a scan node consists of those columns
  public void testOutputSchemaSomeScanColumns() {
    AbstractScanPlanNode dut = new SeqScanPlanNode();
    dut.setTargetTableName(TABLE1);

    int[] scan_col_indexes = {1, 3};
    ArrayList<SchemaColumn> scanColumns = new ArrayList<SchemaColumn>();
    for (int index : scan_col_indexes) {
      TupleValueExpression tve = new TupleValueExpression();
      tve.setTableName(TABLE1);
      tve.setColumnName(COLS[index]);
      tve.setColumnAlias(COLS[index]);
      tve.setValueType(COLTYPES[index]);
      tve.setValueSize(COLTYPES[index].getLengthInBytesForFixedTypes());
      SchemaColumn col = new SchemaColumn(TABLE1, COLS[index], COLS[index], tve);
      scanColumns.add(col);
    }
    dut.setScanColumns(scanColumns);

    // Should be able to do this safely and repeatably multiple times
    for (int i = 0; i < 3; i++) {
      dut.generateOutputSchema(m_voltdb.getDatabase());
      NodeSchema dut_schema = dut.getOutputSchema();
      System.out.println(dut_schema.toString());
      assertEquals(scan_col_indexes.length, dut_schema.size());
      for (int index : scan_col_indexes) {
        SchemaColumn col = dut_schema.find(TABLE1, COLS[index], "");
        assertNotNull(col);
        assertEquals(col.getExpression().getExpressionType(), ExpressionType.VALUE_TUPLE);
        assertEquals(col.getExpression().getValueType(), COLTYPES[index]);
      }
    }
  }
Example #2
0
  // test that if no scan columns are specified, the output schema of
  // a scan node is the schema of the table
  public void testOutputSchemaNoScanColumns() {
    AbstractScanPlanNode dut = new SeqScanPlanNode();
    dut.setTargetTableName(TABLE1);

    dut.generateOutputSchema(m_voltdb.getDatabase());
    NodeSchema dut_schema = dut.getOutputSchema();
    System.out.println(dut_schema.toString());
    assertEquals(COLS.length, dut_schema.size());
    for (int i = 0; i < COLS.length; ++i) {
      SchemaColumn col = dut_schema.find(TABLE1, COLS[i], COLS[i]);
      assertNotNull(col);
      assertEquals(col.getExpression().getExpressionType(), ExpressionType.VALUE_TUPLE);
      assertEquals(col.getExpression().getValueType(), COLTYPES[i]);
    }
  }