Package org.apache.tajo.catalog

Examples of org.apache.tajo.catalog.CatalogService


    if(query != null) {
      LOG.warn("Query already started");
      return;
    }

    CatalogService catalog = getQueryTaskContext().getQueryMasterContext().getWorkerContext().getCatalog();
    LogicalPlanner planner = new LogicalPlanner(catalog);
    LogicalOptimizer optimizer = new LogicalOptimizer();
    Expr expr;
    if (queryContext.isHiveQueryMode()) {
      HiveConverter hiveConverter = new HiveConverter();
View Full Code Here


            DataChannel finalChannel = masterPlan.getChannel(castEvent.getExecutionBlockId(), nextBlock.getId());
            Path finalOutputDir = commitOutputData(query);
            TableDesc finalTableDesc = buildOrUpdateResultTableDesc(query, castEvent.getExecutionBlockId(), finalOutputDir);

            QueryContext queryContext = query.context.getQueryContext();
            CatalogService catalog = query.context.getQueryMasterContext().getWorkerContext().getCatalog();

            if (queryContext.hasOutputTable()) { // TRUE only if a query command is 'CREATE TABLE' OR 'INSERT INTO'
              if (queryContext.isOutputOverwrite()) { // TRUE only if a query is 'INSERT OVERWRITE INTO'
                catalog.deleteTable(finalOutputDir.getName());
              }
              catalog.addTable(finalTableDesc);
            }
            query.setResultDesc(finalTableDesc);
            query.finished(QueryState.QUERY_SUCCEEDED);
            query.eventHandler.handle(new QueryFinishEvent(query.getId()));
          }
View Full Code Here

      TableDesc finalTableDesc = outputTableDesc;

      // If a query has a target table, a TableDesc is updated.
      if (queryContext.hasOutputTable()) { // CREATE TABLE or INSERT STATEMENT
        if (queryContext.isOutputOverwrite()) {
          CatalogService catalog = query.context.getQueryMasterContext().getWorkerContext().getCatalog();
          Preconditions.checkNotNull(catalog, "CatalogService is NULL");
          TableDesc updatingTable = catalog.getTableDesc(outputTableDesc.getName());
          updatingTable.getMeta().setStat(meta.getStat());
          finalTableDesc = updatingTable;
        }
      }
      return finalTableDesc;
View Full Code Here

  public final void testInsertOverwrite() throws Exception {
    String tableName ="InsertOverwrite";
    ResultSet res = tpch.execute("create table " + tableName +" (col1 int8, col2 int4, col3 float4)");
    res.close();
    TajoTestingCluster cluster = tpch.getTestingCluster();
    CatalogService catalog = cluster.getMaster().getCatalog();
    assertTrue(catalog.existsTable(tableName));

    res = tpch.execute("insert overwrite into " + tableName
        + " select l_orderkey, l_partkey, l_quantity from lineitem");
    res.close();

    TableDesc desc = catalog.getTableDesc(tableName);
    assertEquals(5, desc.getMeta().getStat().getNumRows().intValue());
  }
View Full Code Here

  public final void testInsertOverwriteSmallerColumns() throws Exception {
    String tableName = "insertoverwritesmallercolumns";
    ResultSet res = tpch.execute("create table " + tableName + " (col1 int8, col2 int4, col3 float4)");
    res.close();
    TajoTestingCluster cluster = tpch.getTestingCluster();
    CatalogService catalog = cluster.getMaster().getCatalog();
    assertTrue(catalog.existsTable(tableName));
    TableDesc originalDesc = catalog.getTableDesc(tableName);

    res = tpch.execute("insert overwrite into " + tableName + " select l_orderkey from lineitem");
    res.close();
    TableDesc desc = catalog.getTableDesc(tableName);
    assertEquals(5, desc.getMeta().getStat().getNumRows().intValue());
    assertEquals(originalDesc.getMeta().getSchema(), desc.getMeta().getSchema());
  }
View Full Code Here

  public final void testInsertOverwriteWithTargetColumns() throws Exception {
    String tableName = "InsertOverwriteWithTargetColumns";
    ResultSet res = tpch.execute("create table " + tableName + " (col1 int8, col2 int4, col3 float4)");
    res.close();
    TajoTestingCluster cluster = tpch.getTestingCluster();
    CatalogService catalog = cluster.getMaster().getCatalog();
    assertTrue(catalog.existsTable(tableName));
    TableDesc originalDesc = catalog.getTableDesc(tableName);

    res = tpch.execute("insert overwrite into " + tableName
        + " (col1, col3) select l_orderkey, l_quantity from lineitem");
    res.close();
    TableDesc desc = catalog.getTableDesc(tableName);
    assertEquals(5, desc.getMeta().getStat().getNumRows().intValue());

    res = tpch.execute("select * from " + tableName);
    assertTrue(res.next());
    assertEquals(1, res.getLong(1));
View Full Code Here

  public final void testInsertOverwriteWithAsterisk() throws Exception {
    String tableName = "testinsertoverwritewithasterisk";
    ResultSet res = tpch.execute("create table " + tableName + " as select * from lineitem");
    res.close();
    TajoTestingCluster cluster = tpch.getTestingCluster();
    CatalogService catalog = cluster.getMaster().getCatalog();
    assertTrue(catalog.existsTable(tableName));

    res = tpch.execute("insert overwrite into " + tableName + " select * from lineitem where l_orderkey = 3");
    res.close();
    TableDesc desc = catalog.getTableDesc(tableName);
    assertEquals(2, desc.getMeta().getStat().getNumRows().intValue());
  }
View Full Code Here

        "create table " + tableName + " as select l_orderkey from lineitem");
    assertFalse(res.next());
    res.close();

    TajoTestingCluster cluster = tpch.getTestingCluster();
    CatalogService catalog = cluster.getMaster().getCatalog();
    assertTrue(catalog.existsTable(tableName));
    TableDesc orderKeys = catalog.getTableDesc(tableName);
    assertEquals(5, orderKeys.getMeta().getStat().getNumRows().intValue());

    // this query will result in the two rows.
    res = tpch.execute(
        "insert overwrite into " + tableName + " select l_orderkey from lineitem where l_orderkey = 3");
    assertFalse(res.next());
    res.close();

    assertTrue(catalog.existsTable(tableName));
    orderKeys = catalog.getTableDesc(tableName);
    assertEquals(2, orderKeys.getMeta().getStat().getNumRows().intValue());
  }
View Full Code Here

  public final void testInsertOverwriteCapitalTableName() throws Exception {
    String tableName = "testInsertOverwriteCapitalTableName";
    ResultSet res = tpch.execute("create table " + tableName + " as select * from lineitem");
    res.close();
    TajoTestingCluster cluster = tpch.getTestingCluster();
    CatalogService catalog = cluster.getMaster().getCatalog();
    assertTrue(catalog.existsTable(tableName));

    res = tpch.execute("insert overwrite into " + tableName + " select * from lineitem where l_orderkey = 3");
    res.close();
    TableDesc desc = catalog.getTableDesc(tableName);
    assertEquals(2, desc.getMeta().getStat().getNumRows().intValue());
  }
View Full Code Here

  public final void testInsertOverwriteWithCompression() throws Exception {
    String tableName = "testInsertOverwriteWithCompression";
    ResultSet res = tpch.execute("create table " + tableName + " (col1 int8, col2 int4, col3 float4) USING csv WITH ('csvfile.delimiter'='|','compression.codec'='org.apache.hadoop.io.compress.DeflateCodec')");
    res.close();
    TajoTestingCluster cluster = tpch.getTestingCluster();
    CatalogService catalog = cluster.getMaster().getCatalog();
    assertTrue(catalog.existsTable(tableName));

    res = tpch.execute("insert overwrite into " + tableName + " select  l_orderkey, l_partkey, l_quantity from lineitem where l_orderkey = 3");
    res.close();
    TableDesc desc = catalog.getTableDesc(tableName);
    assertEquals(2, desc.getMeta().getStat().getNumRows().intValue());

    FileSystem fs = FileSystem.get(tpch.getTestingCluster().getConfiguration());
    assertTrue(fs.exists(desc.getPath()));
    CompressionCodecFactory factory = new CompressionCodecFactory(tpch.getTestingCluster().getConfiguration());
View Full Code Here

TOP

Related Classes of org.apache.tajo.catalog.CatalogService

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.