@Test
  public void createTemporaryTableAsSelect() {
    Table table = new Table("A_SCHEMA", "A_TABLE_AS_SELECT");
    CreateTable ct = new CreateTable(table);
    ct.setTemporary(true);

    PlainSelect select = new PlainSelect();
    Table selectTable = new Table("A_SCHEMA", "Table", "Alias");
    select.setSelectItems(Arrays.asList(new ISelectItem[] {new AllTableColumns(selectTable)}));
    select.setTableReference(selectTable);
    ct.setSelect(select);

    String sql = sqlGenerator.generateSQL(ct);

    Assert.assertNotNull(sql);
    Assert.assertEquals(
        "CREATE GLOBAL TEMPORARY TABLE A_SCHEMA.A_TABLE_AS_SELECT ON COMMIT PRESERVE ROWS AS SELECT Alias.* FROM A_SCHEMA.Table AS Alias",
        sql);
  }
  @Test
  public void testCreateTemporaryComplexTableWithPrimaryKey() {
    CreateTable createTable = new CreateTable(new Table("A_SCHEMA", "COMPLEX_TABLE"));
    createTable.setTemporary(true);

    List<TableElement> columns = new ArrayList<TableElement>();
    columns.add(new ColumnDefinition("field1", new CharacterDataType(25), true));
    columns.add(new ColumnDefinition("field2", new CharacterDataType(25), true));
    columns.add(new ColumnDefinition("field3", new CharacterDataType(25)));
    columns.add(
        new UniqueConstraintDefinition(
            UniqueConstraintType.primaryKey, Arrays.asList(new String[] {"field1", "field2"})));
    createTable.setTableElements(columns);

    String sql = sqlGenerator.generateSQL(createTable);

    Assert.assertNotNull(sql);
    Assert.assertEquals(
        "CREATE GLOBAL TEMPORARY TABLE A_SCHEMA.COMPLEX_TABLE ( field1 VARCHAR(25) NOT NULL,\nfield2 VARCHAR(25) NOT NULL,\nfield3 VARCHAR(25),\nPRIMARY KEY (field1, field2) ) ON COMMIT PRESERVE ROWS",
        sql);
  }