/*
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package io.prestosql.tests.iceberg;

import io.prestosql.tempto.ProductTest;
import io.prestosql.tempto.query.QueryExecutor;
import org.testng.annotations.Test;

import static io.prestosql.tempto.assertions.QueryAssert.Row.row;
import static io.prestosql.tempto.assertions.QueryAssert.assertThat;
import static io.prestosql.tests.TestGroups.ICEBERG;
import static io.prestosql.tests.TestGroups.STORAGE_FORMATS;
import static io.prestosql.tests.utils.QueryExecutors.onPresto;

public class TestIcebergCreateTable
        extends ProductTest
{
    @Test(groups = {ICEBERG, STORAGE_FORMATS})
    public void testCreateTable()
    {
        QueryExecutor queryExecutor = onPresto();
        queryExecutor.executeQuery("CREATE SCHEMA iceberg.iceberg");
        queryExecutor.executeQuery("use iceberg.iceberg");
        queryExecutor.executeQuery("CREATE TABLE test_create_table(a bigint, b varchar)");
        queryExecutor.executeQuery("INSERT INTO test_create_table(a, b) VALUES " +
                "(NULL, NULL), " +
                "(-42, 'abc'), " +
                "(9223372036854775807, 'abcdefghijklmnopqrstuvwxyz')");
        assertThat(queryExecutor.executeQuery("SELECT * FROM test_create_table"))
                .containsOnly(
                        row(null, null),
                        row(-42, "abc"),
                        row(9223372036854775807L, "abcdefghijklmnopqrstuvwxyz"));
        queryExecutor.executeQuery("DROP TABLE test_create_table");
        queryExecutor.executeQuery("DROP SCHEMA iceberg.iceberg");
    }

    @Test(groups = {ICEBERG, STORAGE_FORMATS})
    public void testCreateTableAsSelect()
    {
        QueryExecutor queryExecutor = onPresto();
        queryExecutor.executeQuery("CREATE SCHEMA iceberg.iceberg");
        queryExecutor.executeQuery("use iceberg.iceberg");
        queryExecutor.executeQuery("" +
                "CREATE TABLE test_create_table_as_select AS " +
                "SELECT * FROM (VALUES " +
                "  (NULL, NULL), " +
                "  (-42, 'abc'), " +
                "  (9223372036854775807, 'abcdefghijklmnopqrstuvwxyz')" +
                ") t(a, b)");
        assertThat(queryExecutor.executeQuery("SELECT * FROM test_create_table_as_select"))
                .containsOnly(
                        row(null, null),
                        row(-42, "abc"),
                        row(9223372036854775807L, "abcdefghijklmnopqrstuvwxyz"));
        queryExecutor.executeQuery("DROP TABLE test_create_table_as_select");
        queryExecutor.executeQuery("DROP SCHEMA iceberg.iceberg");
    }
}

@@ -680,16 +680,59 @@
 ecutor;%0A
+import io.prestosql.testng.services.Flaky;%0A
 import o
@@ -1179,32 +1179,143 @@
 ORAGE_FORMATS%7D)%0A
+    @Flaky(issue = %22https://github.com/prestosql/presto/issues/4864%22, match = %22Failed to read footer of file%22)%0A
     public void 
@@ -2294,24 +2294,135 @@
 E_FORMATS%7D)%0A
+    @Flaky(issue = %22https://github.com/prestosql/presto/issues/4864%22, match = %22Failed to read footer of file%22)%0A
     public v

Mark TestIcebergCreateTable as @Flaky