Esempio n. 1
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"));
 }
Esempio n. 2
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"));
 }
Esempio n. 3
0
 @Override
 public void eval(EvalContext ctx, Schema schema, Tuple tuple) {
   if (fieldId == null) {
     fieldId = schema.getColumnId(column.getQualifiedName());
     compile(this.pattern);
   }
   StringDatum str = tuple.getString(fieldId);
   if (not) {
     result.setValue(!compiled.matcher(str.asChars()).matches());
   } else {
     result.setValue(compiled.matcher(str.asChars()).matches());
   }
 }
Esempio n. 4
0
  @BeforeClass
  public static void setUp() throws Exception {
    util = new TajoTestingCluster();
    util.startCatalogCluster();
    cat = util.getMiniCatalogCluster().getCatalog();

    schema1 = new Schema();
    schema1.addColumn("id", DataType.INT);
    schema1.addColumn("name", DataType.STRING);
    schema1.addColumn("score", DataType.INT);
    schema1.addColumn("age", DataType.INT);

    Schema schema2 = new Schema();
    schema2.addColumn("id", DataType.INT);
    schema2.addColumn("people_id", DataType.INT);
    schema2.addColumn("dept", DataType.STRING);
    schema2.addColumn("year", DataType.INT);

    Schema schema3 = new Schema();
    schema3.addColumn("id", DataType.INT);
    schema3.addColumn("people_id", DataType.INT);
    schema3.addColumn("class", DataType.STRING);
    schema3.addColumn("branch_name", DataType.STRING);

    Schema schema4 = new Schema();
    schema4.addColumn("char_col", DataType.CHAR);
    schema4.addColumn("short_col", DataType.SHORT);
    schema4.addColumn("int_col", DataType.INT);
    schema4.addColumn("long_col", DataType.LONG);
    schema4.addColumn("float_col", DataType.FLOAT);
    schema4.addColumn("double_col", DataType.DOUBLE);
    schema4.addColumn("string_col", DataType.STRING);

    TableMeta meta = TCatUtil.newTableMeta(schema1, StoreType.CSV);
    TableDesc people = new TableDescImpl("people", meta, new Path("file:///"));
    cat.addTable(people);

    TableDesc student =
        TCatUtil.newTableDesc(
            "student", schema2, StoreType.CSV, new Options(), new Path("file:///"));
    cat.addTable(student);

    TableDesc branch =
        TCatUtil.newTableDesc(
            "branch", schema3, StoreType.CSV, new Options(), new Path("file:///"));
    cat.addTable(branch);

    TableDesc allType =
        TCatUtil.newTableDesc(
            "alltype", schema4, StoreType.CSV, new Options(), new Path("file:///"));
    cat.addTable(allType);

    TPCH tpch = new TPCH();
    tpch.loadSchemas();
    Schema lineitemSchema = tpch.getSchema("lineitem");
    Schema partSchema = tpch.getSchema("part");
    TableDesc lineitem =
        TCatUtil.newTableDesc(
            "lineitem", lineitemSchema, StoreType.CSV, new Options(), new Path("file:///"));
    TableDesc part =
        TCatUtil.newTableDesc(
            "part", partSchema, StoreType.CSV, new Options(), new Path("file:///"));
    cat.addTable(lineitem);
    cat.addTable(part);

    FunctionDesc funcMeta =
        new FunctionDesc(
            "sumtest",
            TestSum.class,
            FunctionType.GENERAL,
            new DataType[] {DataType.INT},
            new DataType[] {DataType.INT});

    cat.registerFunction(funcMeta);

    analyzer = new QueryAnalyzer(cat);
  }