예제 #1
0
  private boolean isClonedSchema(Schema origSchema, Schema newSchema) {
    // Check schema of tables
    boolean schemaEqual = (origSchema.size() == newSchema.size());
    if (schemaEqual == false) {
      fail("Number of columns in schema not equal");
      return false;
    }

    for (int col = 0; col < origSchema.size(); col++) {
      Column colA = origSchema.getColumn(col);
      Column colB = newSchema.getColumn(col);
      if (colA.getSimpleName().equals(colB.getSimpleName()) == false) {
        fail("Column names at index " + col + " do not match");
        return false;
      }
      if (colA.getDataType().equals(colB.getDataType()) == false) {
        fail("Column datatypes at index " + col + " do not match");
        return false;
      }
    }
    return true;
  }
예제 #2
0
  @Test
  public final void testGetSortKeysFromJoinQual() {
    Schema outerSchema = new Schema();
    outerSchema.addColumn("employee.id1", CatalogUtil.newSimpleDataType(Type.INT4));
    outerSchema.addColumn("employee.id2", CatalogUtil.newSimpleDataType(Type.INT4));
    Schema innerSchema = new Schema();
    innerSchema.addColumn("people.fid1", CatalogUtil.newSimpleDataType(Type.INT4));
    innerSchema.addColumn("people.fid2", CatalogUtil.newSimpleDataType(Type.INT4));

    FieldEval f1 = new FieldEval("employee.id1", CatalogUtil.newSimpleDataType(Type.INT4));
    FieldEval f2 = new FieldEval("people.fid1", CatalogUtil.newSimpleDataType(Type.INT4));
    FieldEval f3 = new FieldEval("employee.id2", CatalogUtil.newSimpleDataType(Type.INT4));
    FieldEval f4 = new FieldEval("people.fid2", CatalogUtil.newSimpleDataType(Type.INT4));

    EvalNode joinQual = new BinaryEval(EvalType.EQUAL, f1, f2);
    SortSpec[][] sortSpecs =
        PlannerUtil.getSortKeysFromJoinQual(joinQual, outerSchema, innerSchema);
    assertEquals(2, sortSpecs.length);
    assertEquals(1, sortSpecs[0].length);
    assertEquals(1, sortSpecs[1].length);
    assertEquals(outerSchema.getColumn("id1"), sortSpecs[0][0].getSortKey());
    assertEquals(innerSchema.getColumn("fid1"), sortSpecs[1][0].getSortKey());

    // tests for composited join key
    EvalNode joinQual2 = new BinaryEval(EvalType.EQUAL, f3, f4);
    EvalNode compositedJoinQual = new BinaryEval(EvalType.AND, joinQual, joinQual2);

    sortSpecs = PlannerUtil.getSortKeysFromJoinQual(compositedJoinQual, outerSchema, innerSchema);
    assertEquals(2, sortSpecs.length);
    assertEquals(2, sortSpecs[0].length);
    assertEquals(2, sortSpecs[1].length);
    assertEquals(outerSchema.getColumn("id1"), sortSpecs[0][0].getSortKey());
    assertEquals(outerSchema.getColumn("id2"), sortSpecs[0][1].getSortKey());
    assertEquals(innerSchema.getColumn("fid1"), sortSpecs[1][0].getSortKey());
    assertEquals(innerSchema.getColumn("fid2"), sortSpecs[1][1].getSortKey());
  }
예제 #3
0
 @Test
 public final void testCreateTableDef2() {
   CreateTableStmt stmt = (CreateTableStmt) analyzer.parse(createTableStmts[7]).getParseTree();
   assertEquals("table1", stmt.getTableName());
   Schema def = stmt.getTableDef();
   assertEquals("name", def.getColumn(0).getColumnName());
   assertEquals(DataType.STRING, def.getColumn(0).getDataType());
   assertEquals("age", def.getColumn(1).getColumnName());
   assertEquals(DataType.INT, def.getColumn(1).getDataType());
   assertEquals("earn", def.getColumn(2).getColumnName());
   assertEquals(DataType.LONG, def.getColumn(2).getDataType());
   assertEquals("score", def.getColumn(3).getColumnName());
   assertEquals(DataType.FLOAT, def.getColumn(3).getDataType());
   assertEquals(StoreType.CSV, stmt.getStoreType());
   assertEquals("/tmp/data", stmt.getPath().toString());
   assertTrue(stmt.hasOptions());
   assertEquals("|", stmt.getOptions().get("csv.delimiter"));
 }
예제 #4
0
 @Test
 public final void testCreateTableDef1() {
   CreateTableStmt stmt = (CreateTableStmt) analyzer.parse(createTableStmts[6]).getParseTree();
   assertEquals("table1", stmt.getTableName());
   Schema def = stmt.getTableDef();
   assertEquals("name", def.getColumn(0).getColumnName());
   assertEquals(DataType.STRING, def.getColumn(0).getDataType());
   assertEquals("age", def.getColumn(1).getColumnName());
   assertEquals(DataType.INT, def.getColumn(1).getDataType());
   assertEquals("earn", def.getColumn(2).getColumnName());
   assertEquals(DataType.LONG, def.getColumn(2).getDataType());
   assertEquals("score", def.getColumn(3).getColumnName());
   assertEquals(DataType.FLOAT, def.getColumn(3).getDataType());
   assertEquals(StoreType.RCFILE, stmt.getStoreType());
   assertFalse(stmt.hasPath());
   assertTrue(stmt.hasOptions());
   assertEquals("4096", stmt.getOptions().get("rcfile.buffer"));
 }