Skip to content

Commit

Permalink
Change the type of UNSUPPORTED_TABLE_TYPE to EXTERNAL
Browse files Browse the repository at this point in the history
`UNSUPPORTED_TABLE_TYPE` error code was initially introduced to
provide a more generic approach than
`HiveErrorCode.HIVE_UNSUPPORTED_FORMAT` to dealing with
the situation of selecting a table of an unsupported type
from a shared metastore (e.g. : Hive, Glue).

The internal logic from `HiveMetadata.streamTableColumns` however
made use of the error type of `HiveErrorCode.HIVE_UNSUPPORTED_FORMAT`
which is `EXTERNAL`. Due to this reason, the error type of
`UNSUPPORTED_TABLE_TYPE` will be changed as well to `EXTERNAL`.
  • Loading branch information
findinpath authored and findepi committed Mar 31, 2022
1 parent 3051f7d commit b395286
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
*/
package io.trino.spi;

import static io.trino.spi.ErrorType.EXTERNAL;
import static io.trino.spi.ErrorType.INSUFFICIENT_RESOURCES;
import static io.trino.spi.ErrorType.INTERNAL_ERROR;
import static io.trino.spi.ErrorType.USER_ERROR;
Expand Down Expand Up @@ -129,7 +130,6 @@ public enum StandardErrorCode
MISSING_ROW_PATTERN(106, USER_ERROR),
INVALID_WINDOW_MEASURE(107, USER_ERROR),
STACK_OVERFLOW(108, USER_ERROR),
UNSUPPORTED_TABLE_TYPE(109, USER_ERROR),

GENERIC_INTERNAL_ERROR(65536, INTERNAL_ERROR),
TOO_MANY_REQUESTS_FAILED(65537, INTERNAL_ERROR),
Expand Down Expand Up @@ -173,6 +173,7 @@ public enum StandardErrorCode
EXCEEDED_SCAN_LIMIT(131081, INSUFFICIENT_RESOURCES),
EXCEEDED_TASK_DESCRIPTOR_STORAGE_CAPACITY(131082, INSUFFICIENT_RESOURCES),

UNSUPPORTED_TABLE_TYPE(133001, EXTERNAL),
/**/;

// Connectors can use error codes starting at the range 0x0100_0000
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import static io.airlift.testing.Assertions.assertLessThan;
import static io.trino.spi.StandardErrorCode.GENERIC_INSUFFICIENT_RESOURCES;
import static io.trino.spi.StandardErrorCode.GENERIC_INTERNAL_ERROR;
import static io.trino.spi.StandardErrorCode.UNSUPPORTED_TABLE_TYPE;
import static java.util.Arrays.asList;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertTrue;
Expand Down Expand Up @@ -61,7 +62,7 @@ public void testOrdering()
StandardErrorCode code = iterator.next();
int current = code(code);
assertGreaterThan(current, previous, "Code is out of order: " + code);
if ((code != GENERIC_INTERNAL_ERROR) && (code != GENERIC_INSUFFICIENT_RESOURCES)) {
if (code != GENERIC_INTERNAL_ERROR && code != GENERIC_INSUFFICIENT_RESOURCES && code != UNSUPPORTED_TABLE_TYPE) {
assertEquals(current, previous + 1, "Code is not sequential: " + code);
}
previous = current;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@
import io.trino.tempto.ProductTest;
import org.testng.annotations.Test;

import static io.trino.tempto.assertions.QueryAssert.Row.row;
import static io.trino.tempto.assertions.QueryAssert.assertQueryFailure;
import static io.trino.tempto.assertions.QueryAssert.assertThat;
import static io.trino.tests.product.TestGroups.HMS_ONLY;
import static io.trino.tests.product.TestGroups.ICEBERG;
import static io.trino.tests.product.TestGroups.STORAGE_FORMATS;
Expand Down Expand Up @@ -89,4 +91,25 @@ public void testHiveCannotCreateTableNamesakeToIcebergTable()

onTrino().executeQuery("DROP TABLE iceberg.default." + tableName);
}

@Test(groups = {ICEBERG, STORAGE_FORMATS, HMS_ONLY})
public void testHiveSelectTableColumns()
{
String hiveTableName = "test_hive_table_columns_table_" + randomTableSuffix();
onTrino().executeQuery("CREATE TABLE hive.default." + hiveTableName + "(a bigint)");

String icebergTableName = "test_iceberg_table_columns_table_" + randomTableSuffix();
onTrino().executeQuery("CREATE TABLE iceberg.default." + icebergTableName + "(a bigint)");

assertThat(onTrino().executeQuery(
format("SELECT table_cat, table_schem, table_name, column_name FROM system.jdbc.columns WHERE table_cat = 'hive' AND table_schem = 'default' AND table_name = '%s'", hiveTableName)))
.containsOnly(row("hive", "default", hiveTableName, "a"));
// Hive does not show any information about tables with unsupported format
assertThat(onTrino().executeQuery(
format("SELECT table_cat, table_schem, table_name, column_name FROM system.jdbc.columns WHERE table_cat = 'hive' AND table_schem = 'default' AND table_name = '%s'", icebergTableName)))
.hasNoRows();

onTrino().executeQuery("DROP TABLE hive.default." + hiveTableName);
onTrino().executeQuery("DROP TABLE iceberg.default." + icebergTableName);
}
}

0 comments on commit b395286

Please sign in to comment.