Example #1
0
 @Test
 public void testTimeZoneTest2() throws Exception {
   String tableName = "test1";
   tajoCli.executeMetaCommand("\\set TIMEZONE GMT+1");
   tajoCli.executeScript("create table " + tableName + " (col1 TIMESTAMP)");
   tajoCli.executeScript("insert into " + tableName + " select to_timestamp(0)");
   tajoCli.executeScript("select * from " + tableName);
   String consoleResult = new String(out.toByteArray());
   tajoCli.executeScript("DROP TABLE " + tableName + " PURGE");
   assertTrue(consoleResult.contains("1970-01-01 01:00:00"));
 }
Example #2
0
 @Test
 public void testTimeZoneSessionVars2() throws Exception {
   tajoCli.executeScript("SET TIME ZONE 'GMT+2'");
   tajoCli.executeMetaCommand("\\set");
   String output = new String(out.toByteArray());
   assertTrue(output.contains("'TIMEZONE'='GMT+2'"));
 }
  public void assertScriptFailure(String cmd) throws Exception {
    Path resultFile = getResultFile(getMethodName() + ".result");
    String expected = FileUtil.readTextFile(new File(resultFile.toUri()));

    tajoCli.executeScript(cmd);
    String consoleResult = new String(err.toByteArray());
    assertEquals(expected, consoleResult);
  }
Example #4
0
  @Test
  public void testLocalQueryWithoutFrom() throws Exception {
    String sql = "select 'abc', '123'; select substr('123456', 1,3);";
    setVar(tajoCli, SessionVars.CLI_FORMATTER_CLASS, TajoCliOutputTestFormatter.class.getName());
    tajoCli.executeScript(sql);
    String consoleResult = new String(out.toByteArray());

    assertOutputResult(consoleResult);
  }
Example #5
0
  private void verifyStopWhenError() throws Exception {
    setVar(tajoCli, SessionVars.CLI_FORMATTER_CLASS, TajoCliOutputTestFormatter.class.getName());

    assertSessionVar(tajoCli, SessionVars.ON_ERROR_STOP.keyname(), "true");

    tajoCli.executeScript(
        "select count(*) from lineitem; "
            + "select count(*) from lineitem2; "
            + "select count(*) from orders");

    String consoleResult = new String(out.toByteArray());
    assertOutputResult(consoleResult);
  }
Example #6
0
  @Test
  public void testSelectResultWithNullFalse() throws Exception {
    String sql =
        "select\n"
            + "  c_custkey,\n"
            + "  orders.o_orderkey,\n"
            + "  orders.o_orderstatus \n"
            + "from\n"
            + "  orders full outer join customer on c_custkey = o_orderkey\n"
            + "order by\n"
            + "  c_custkey,\n"
            + "  orders.o_orderkey;\n";

    setVar(tajoCli, SessionVars.CLI_FORMATTER_CLASS, TajoCliOutputTestFormatter.class.getName());
    tajoCli.executeScript(sql);

    String consoleResult = new String(out.toByteArray());
    assertOutputResult(consoleResult);
  }
Example #7
0
  private void verifyDescTable(String sql, String tableName, String resultFileName)
      throws Exception {
    setVar(tajoCli, SessionVars.CLI_FORMATTER_CLASS, TajoCliOutputTestFormatter.class.getName());
    tajoCli.executeScript(sql);

    tajoCli.executeMetaCommand("\\d " + tableName);
    tajoCli.executeMetaCommand("\\d \"" + tableName + "\"");

    String consoleResult = new String(out.toByteArray());

    if (!cluster.isHiveCatalogStoreRunning()) {
      assertOutputResult(
          resultFileName,
          consoleResult,
          new String[] {"${table.path}"},
          new String[] {
            TablespaceManager.getDefault().getTableUri("default", tableName).toString()
          });
    }
  }
Example #8
0
  @Test
  public void testAlterTableAddDropPartition() throws Exception {
    String tableName = CatalogUtil.normalizeIdentifier("testAlterTableAddPartition");

    tajoCli.executeScript(
        "create table " + tableName + " (col1 int4, col2 int4) partition by column(key float8)");
    tajoCli.executeScript("alter table " + tableName + " add partition (key2 = 0.1)");
    tajoCli.executeScript("alter table " + tableName + " add partition (key = 0.1)");
    tajoCli.executeScript("alter table " + tableName + " drop partition (key = 0.1)");
    tajoCli.executeScript("alter table " + tableName + " drop partition (key = 0.1)");

    tajoCli.executeScript("drop table " + tableName);
    tajoCli.executeScript(
        "create table "
            + tableName
            + " (col1 int4, col2 int4) partition by column(col3 float8, col4 int4)");

    TajoClient client = testBase.getTestingCluster().newTajoClient();
    TableDesc tableDesc = client.getTableDesc(tableName);

    String partitionLocation = tableDesc.getUri().toString() + "/col5=0.1/col6=10";
    tajoCli.executeScript(
        "alter table "
            + tableName
            + " add partition (col3 = 0.1, col4 = 10)"
            + " location '"
            + partitionLocation
            + "'");

    Path partitionPath = new Path(partitionLocation);
    FileSystem fs = testBase.getTestingCluster().getDefaultFileSystem();
    assertTrue(fs.exists(partitionPath));

    tajoCli.executeScript("alter table " + tableName + " drop partition (col3 = 0.1, col4 = 10)");

    String consoleResult = new String(out.toByteArray());
    assertOutputResult(consoleResult);
  }
Example #9
0
  @Test
  public void testConnectDatabase() throws Exception {
    String databaseName;

    if (cluster.isHiveCatalogStoreRunning()) {
      databaseName = "TEST_CONNECTION_DATABASE".toLowerCase();
    } else {
      databaseName = "TEST_CONNECTION_DATABASE";
    }
    String sql = "create database \"" + databaseName + "\";";

    tajoCli.executeScript(sql);

    tajoCli.executeMetaCommand("\\c " + databaseName);
    assertEquals(databaseName, tajoCli.getContext().getCurrentDatabase());

    tajoCli.executeMetaCommand("\\c default");
    assertEquals("default", tajoCli.getContext().getCurrentDatabase());

    tajoCli.executeMetaCommand("\\c \"" + databaseName + "\"");
    assertEquals(databaseName, tajoCli.getContext().getCurrentDatabase());
  }
Example #10
0
  @Test(timeout = 3000)
  public void testNonForwardQueryPause() throws Exception {
    final String sql = "select * from default.lineitem";
    TajoCli cli = null;
    try {
      TableDesc tableDesc = cluster.getMaster().getCatalog().getTableDesc("default", "lineitem");
      assertNotNull(tableDesc);
      assertEquals(0L, tableDesc.getStats().getNumRows().longValue());

      InputStream testInput =
          new ByteArrayInputStream(new byte[] {(byte) DefaultTajoCliOutputFormatter.QUIT_COMMAND});
      cli = new TajoCli(cluster.getConfiguration(), new String[] {}, testInput, out);
      setVar(cli, SessionVars.CLI_PAGE_ROWS, "2");
      setVar(cli, SessionVars.CLI_FORMATTER_CLASS, TajoCliOutputTestFormatter.class.getName());

      cli.executeScript(sql);

      String consoleResult;
      consoleResult = new String(out.toByteArray());
      assertOutputResult(consoleResult);
    } finally {
      cli.close();
    }
  }
Example #11
0
 public void assertScriptFailure(String cmd, String expectedMsg) throws Exception {
   tajoCli.executeScript(cmd);
   String consoleResult = new String(err.toByteArray());
   assertEquals(expectedMsg, consoleResult);
 }