public List<String> build() {
    checkState(!columns.isEmpty(), "Columns need to be specified");

    List<String> sql = new ArrayList<>();

    String select = columns.stream().map(this::toSelect).collect(Collectors.joining(", "));

    if (dialect.getId().equals(MsSql.ID)) {
      sql.add("SELECT " + select + " INTO " + tableName + " FROM " + fromTableName);
    } else {
      StringBuilder sb = new StringBuilder("CREATE TABLE " + tableName + " (");
      appendColumnNames(sb);
      sb.append(") AS (SELECT ").append(select).append(" FROM ").append(fromTableName).append(")");
      sql.add(sb.toString());
    }

    List<Column> notNullColumns = columns.stream().filter(c -> !c.definition().isNullable()).toList();
    for (Column c : notNullColumns) {
      sql.addAll(new AlterColumnsBuilder(dialect, tableName).updateColumn(c.definition()).build());
    }

    return sql;
  }
@Test
  public void fail_if_table_not_set() {
    assertThatThrownBy(() -> new CreateTableAsBuilder(new H2(), null, "issues")
      .build())
      .isInstanceOf(NullPointerException.class);
  }