Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid loading lineitem unnecessarily #16587

Merged
merged 2 commits into from
Mar 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -472,10 +472,10 @@ public void testFileSortingWithLargerTable()
try (TestTable table = new TestTable(
getQueryRunner()::execute,
"test_sorted_lineitem_table",
"WITH (sorted_by = ARRAY['comment'], format = '" + format.name() + "') AS SELECT * FROM lineitem WITH NO DATA")) {
"WITH (sorted_by = ARRAY['comment'], format = '" + format.name() + "') AS TABLE tpch.tiny.lineitem WITH NO DATA")) {
assertUpdate(
withSmallRowGroups,
"INSERT INTO " + table.getName() + " SELECT * FROM lineitem",
"INSERT INTO " + table.getName() + " TABLE tpch.tiny.lineitem",
"VALUES 60175");
for (Object filePath : computeActual("SELECT file_path from \"" + table.getName() + "$files\"").getOnlyColumnAsSet()) {
assertTrue(isFileSorted((String) filePath, "comment"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
import io.trino.testing.QueryRunner;
import io.trino.testing.TestingConnectorBehavior;
import io.trino.testing.sql.TestTable;
import io.trino.tpch.TpchTable;
import org.apache.avro.Schema;
import org.apache.avro.file.DataFileReader;
import org.apache.avro.file.DataFileWriter;
Expand Down Expand Up @@ -117,7 +116,6 @@
import static io.trino.testing.TestingNames.randomNameSuffix;
import static io.trino.testing.TestingSession.testSessionBuilder;
import static io.trino.testing.assertions.Assert.assertEventually;
import static io.trino.tpch.TpchTable.LINE_ITEM;
import static io.trino.transaction.TransactionBuilder.transaction;
import static java.lang.String.format;
import static java.lang.String.join;
Expand Down Expand Up @@ -167,10 +165,7 @@ protected IcebergQueryRunner.Builder createQueryRunnerBuilder()
// Allows testing the sorting writer flushing to the file system with smaller tables
.put("iceberg.writer-sort-buffer-size", "1MB")
.buildOrThrow())
.setInitialTables(ImmutableList.<TpchTable<?>>builder()
.addAll(REQUIRED_TPCH_TABLES)
.add(LINE_ITEM)
.build());
.setInitialTables(REQUIRED_TPCH_TABLES);
}

@SuppressWarnings("DuplicateBranchesInSwitch")
Expand Down Expand Up @@ -1320,9 +1315,9 @@ public void testUpdateWithSortOrder()
try (TestTable table = new TestTable(
getQueryRunner()::execute,
"test_sorted_update",
"WITH (sorted_by = ARRAY['comment']) AS SELECT * FROM lineitem WITH NO DATA")) {
"WITH (sorted_by = ARRAY['comment']) AS TABLE tpch.tiny.lineitem WITH NO DATA")) {
assertUpdate(
"INSERT INTO " + table.getName() + " SELECT * FROM lineitem",
"INSERT INTO " + table.getName() + " TABLE tpch.tiny.lineitem",
"VALUES 60175");
assertUpdate(withSmallRowGroups, "UPDATE " + table.getName() + " SET comment = substring(comment, 2)", 60175);
assertQuery(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
*/
package io.trino.plugin.iceberg;

import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import io.minio.messages.Event;
Expand All @@ -34,7 +33,6 @@
import io.trino.plugin.hive.s3.TrinoS3ConfigurationInitializer;
import io.trino.testing.QueryRunner;
import io.trino.testing.minio.MinioClient;
import io.trino.tpch.TpchTable;
import org.apache.iceberg.FileFormat;
import org.intellij.lang.annotations.Language;
import org.testng.annotations.Test;
Expand All @@ -50,7 +48,6 @@
import static io.trino.testing.TestingNames.randomNameSuffix;
import static io.trino.testing.containers.Minio.MINIO_ACCESS_KEY;
import static io.trino.testing.containers.Minio.MINIO_SECRET_KEY;
import static io.trino.tpch.TpchTable.LINE_ITEM;
import static java.lang.String.format;
import static java.util.Locale.ENGLISH;
import static org.assertj.core.api.Assertions.assertThat;
Expand Down Expand Up @@ -104,10 +101,7 @@ protected QueryRunner createQueryRunner()
.setSchemaInitializer(
SchemaInitializer.builder()
.withSchemaName(schemaName)
.withClonedTpchTables(ImmutableList.<TpchTable<?>>builder()
.addAll(REQUIRED_TPCH_TABLES)
.add(LINE_ITEM)
.build())
.withClonedTpchTables(REQUIRED_TPCH_TABLES)
.withSchemaProperties(Map.of("location", "'s3://" + bucketName + "/" + schemaName + "'"))
.build())
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
*/
package io.trino.plugin.iceberg;

import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.google.common.io.Resources;
Expand All @@ -32,7 +31,6 @@
import io.trino.plugin.hive.metastore.HiveMetastore;
import io.trino.plugin.hive.metastore.thrift.BridgingHiveMetastore;
import io.trino.testing.QueryRunner;
import io.trino.tpch.TpchTable;
import org.testng.annotations.Parameters;
import org.testng.annotations.Test;

Expand All @@ -46,7 +44,6 @@
import static io.trino.plugin.hive.TestingThriftHiveMetastoreBuilder.testingThriftHiveMetastoreBuilder;
import static io.trino.plugin.iceberg.IcebergTestUtils.checkOrcFileSorting;
import static io.trino.testing.TestingNames.randomNameSuffix;
import static io.trino.tpch.TpchTable.LINE_ITEM;
import static java.lang.String.format;
import static java.nio.charset.StandardCharsets.UTF_8;
import static java.util.Locale.ENGLISH;
Expand Down Expand Up @@ -122,10 +119,7 @@ protected QueryRunner createQueryRunner()
.setSchemaInitializer(
SchemaInitializer.builder()
.withSchemaName(schemaName)
.withClonedTpchTables(ImmutableList.<TpchTable<?>>builder()
.addAll(REQUIRED_TPCH_TABLES)
.add(LINE_ITEM)
.build())
.withClonedTpchTables(REQUIRED_TPCH_TABLES)
.withSchemaProperties(Map.of("location", "'" + formatAbfsUrl(container, account, bucketName) + schemaName + "'"))
.build())
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,9 @@
*/
package io.trino.plugin.iceberg;

import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import io.trino.plugin.hive.metastore.HiveMetastore;
import io.trino.testing.QueryRunner;
import io.trino.tpch.TpchTable;
import org.testng.annotations.AfterClass;

import java.io.File;
Expand All @@ -30,7 +28,6 @@
import static com.google.common.io.RecursiveDeleteOption.ALLOW_INSECURE;
import static io.trino.plugin.hive.metastore.file.FileHiveMetastore.createTestingFileHiveMetastore;
import static io.trino.plugin.iceberg.IcebergTestUtils.checkOrcFileSorting;
import static io.trino.tpch.TpchTable.LINE_ITEM;
import static java.lang.String.format;
import static org.apache.iceberg.FileFormat.ORC;
import static org.assertj.core.api.Assertions.assertThat;
Expand All @@ -56,10 +53,7 @@ protected QueryRunner createQueryRunner()
this.metastoreDir.deleteOnExit();
this.metastore = createTestingFileHiveMetastore(metastoreDir);
return IcebergQueryRunner.builder()
.setInitialTables(ImmutableList.<TpchTable<?>>builder()
.addAll(REQUIRED_TPCH_TABLES)
.add(LINE_ITEM)
.build())
.setInitialTables(REQUIRED_TPCH_TABLES)
.setMetastoreDirectory(metastoreDir)
.setIcebergProperties(ImmutableMap.of(
"iceberg.register-table-procedure.enabled", "true",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
*/
package io.trino.plugin.iceberg;

import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.google.common.io.Resources;
Expand All @@ -35,7 +34,6 @@
import io.trino.plugin.hive.metastore.thrift.BridgingHiveMetastore;
import io.trino.testing.QueryRunner;
import io.trino.testing.TestingConnectorBehavior;
import io.trino.tpch.TpchTable;
import org.testng.annotations.AfterClass;
import org.testng.annotations.Parameters;
import org.testng.annotations.Test;
Expand All @@ -55,7 +53,6 @@
import static io.trino.plugin.iceberg.IcebergTestUtils.checkOrcFileSorting;
import static io.trino.testing.TestingConnectorSession.SESSION;
import static io.trino.testing.TestingNames.randomNameSuffix;
import static io.trino.tpch.TpchTable.LINE_ITEM;
import static java.lang.String.format;
import static java.nio.charset.StandardCharsets.UTF_8;
import static java.util.Objects.requireNonNull;
Expand Down Expand Up @@ -126,10 +123,7 @@ protected QueryRunner createQueryRunner()
.buildOrThrow())
.setSchemaInitializer(
SchemaInitializer.builder()
.withClonedTpchTables(ImmutableList.<TpchTable<?>>builder()
.addAll(REQUIRED_TPCH_TABLES)
.add(LINE_ITEM)
.build())
.withClonedTpchTables(REQUIRED_TPCH_TABLES)
.withSchemaName(schema)
.withSchemaProperties(ImmutableMap.of("location", "'" + schemaPath() + "'"))
.build())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@
import org.testng.annotations.Test;

import java.io.File;
import java.io.IOException;
import java.io.UncheckedIOException;
import java.nio.file.Files;
import java.util.Optional;

Expand All @@ -55,18 +53,14 @@ public class TestIcebergFileMetastoreTableOperationsInsertFailure

@Override
protected LocalQueryRunner createQueryRunner()
throws Exception
{
Session session = testSessionBuilder()
.setCatalog(ICEBERG_CATALOG)
.setSchema(SCHEMA_NAME)
.build();

try {
baseDir = Files.createTempDirectory(null).toFile();
}
catch (IOException e) {
throw new UncheckedIOException(e);
}
baseDir = Files.createTempDirectory(null).toFile();

HiveMetastore metastore = new FileHiveMetastore(
new NodeVersion("testversion"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import com.amazonaws.services.s3.model.ListObjectsV2Request;
import com.amazonaws.services.s3.model.ListObjectsV2Result;
import com.amazonaws.services.s3.model.S3ObjectSummary;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import io.trino.filesystem.TrinoFileSystem;
Expand All @@ -41,7 +40,6 @@
import io.trino.plugin.iceberg.SchemaInitializer;
import io.trino.testing.QueryRunner;
import io.trino.testing.sql.TestView;
import io.trino.tpch.TpchTable;
import org.apache.iceberg.FileFormat;
import org.testng.annotations.AfterClass;
import org.testng.annotations.Parameters;
Expand All @@ -54,7 +52,6 @@
import static io.trino.plugin.iceberg.IcebergTestUtils.checkParquetFileSorting;
import static io.trino.testing.TestingConnectorSession.SESSION;
import static io.trino.testing.TestingNames.randomNameSuffix;
import static io.trino.tpch.TpchTable.LINE_ITEM;
import static java.lang.String.format;
import static java.util.Objects.requireNonNull;
import static org.assertj.core.api.Assertions.assertThat;
Expand Down Expand Up @@ -99,10 +96,7 @@ protected QueryRunner createQueryRunner()
"iceberg.writer-sort-buffer-size", "1MB"))
.setSchemaInitializer(
SchemaInitializer.builder()
.withClonedTpchTables(ImmutableList.<TpchTable<?>>builder()
.addAll(REQUIRED_TPCH_TABLES)
.add(LINE_ITEM)
.build())
.withClonedTpchTables(REQUIRED_TPCH_TABLES)
.withSchemaName(schemaName)
.build())
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,13 @@
*/
package io.trino.plugin.iceberg.catalog.jdbc;

import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import io.trino.hadoop.ConfigurationInstantiator;
import io.trino.plugin.iceberg.BaseIcebergConnectorSmokeTest;
import io.trino.plugin.iceberg.IcebergConfig;
import io.trino.plugin.iceberg.IcebergQueryRunner;
import io.trino.testing.QueryRunner;
import io.trino.testing.TestingConnectorBehavior;
import io.trino.tpch.TpchTable;
import org.apache.iceberg.BaseTable;
import org.apache.iceberg.catalog.TableIdentifier;
import org.apache.iceberg.jdbc.JdbcCatalog;
Expand All @@ -38,7 +36,6 @@
import static io.trino.plugin.iceberg.IcebergTestUtils.checkOrcFileSorting;
import static io.trino.plugin.iceberg.catalog.jdbc.TestingIcebergJdbcServer.PASSWORD;
import static io.trino.plugin.iceberg.catalog.jdbc.TestingIcebergJdbcServer.USER;
import static io.trino.tpch.TpchTable.LINE_ITEM;
import static java.lang.String.format;
import static org.apache.iceberg.CatalogProperties.CATALOG_IMPL;
import static org.apache.iceberg.CatalogProperties.URI;
Expand Down Expand Up @@ -99,10 +96,7 @@ protected QueryRunner createQueryRunner()
.put("iceberg.writer-sort-buffer-size", "1MB")
.put("iceberg.jdbc-catalog.default-warehouse-dir", warehouseLocation.getAbsolutePath())
.buildOrThrow())
.setInitialTables(ImmutableList.<TpchTable<?>>builder()
.addAll(REQUIRED_TPCH_TABLES)
.add(LINE_ITEM)
.build())
.setInitialTables(REQUIRED_TPCH_TABLES)
.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,13 @@
*/
package io.trino.plugin.iceberg.catalog.rest;

import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import io.airlift.http.server.testing.TestingHttpServer;
import io.trino.plugin.iceberg.BaseIcebergConnectorSmokeTest;
import io.trino.plugin.iceberg.IcebergConfig;
import io.trino.plugin.iceberg.IcebergQueryRunner;
import io.trino.testing.QueryRunner;
import io.trino.testing.TestingConnectorBehavior;
import io.trino.tpch.TpchTable;
import org.apache.iceberg.catalog.Catalog;
import org.apache.iceberg.rest.DelegatingRestSessionCatalog;
import org.assertj.core.util.Files;
Expand All @@ -34,7 +32,6 @@
import static com.google.common.io.RecursiveDeleteOption.ALLOW_INSECURE;
import static io.trino.plugin.iceberg.IcebergTestUtils.checkOrcFileSorting;
import static io.trino.plugin.iceberg.catalog.rest.RestCatalogTestUtils.backendCatalog;
import static io.trino.tpch.TpchTable.LINE_ITEM;
import static java.lang.String.format;
import static org.assertj.core.api.Assertions.assertThatThrownBy;

Expand Down Expand Up @@ -87,10 +84,7 @@ protected QueryRunner createQueryRunner()
.put("iceberg.register-table-procedure.enabled", "true")
.put("iceberg.writer-sort-buffer-size", "1MB")
.buildOrThrow())
.setInitialTables(ImmutableList.<TpchTable<?>>builder()
.addAll(REQUIRED_TPCH_TABLES)
.add(LINE_ITEM)
.build())
.setInitialTables(REQUIRED_TPCH_TABLES)
.build();
}

Expand Down