use of io.trino.metadata.QualifiedObjectName in project trino by trinodb.
the class BaseHiveConnectorTest method getTableMetadata.
private TableMetadata getTableMetadata(String catalog, String schema, String tableName) {
Session session = getSession();
Metadata metadata = getDistributedQueryRunner().getCoordinator().getMetadata();
return transaction(getQueryRunner().getTransactionManager(), getQueryRunner().getAccessControl()).readOnly().execute(session, transactionSession -> {
Optional<TableHandle> tableHandle = metadata.getTableHandle(transactionSession, new QualifiedObjectName(catalog, schema, tableName));
assertTrue(tableHandle.isPresent());
return metadata.getTableMetadata(transactionSession, tableHandle.get());
});
}
use of io.trino.metadata.QualifiedObjectName in project trino by trinodb.
the class TestSetPropertiesTask method testSetMaterializedViewProperties.
@Test
public void testSetMaterializedViewProperties() {
QualifiedObjectName materializedViewName = qualifiedObjectName("test_materialized_view");
metadata.createMaterializedView(testSession, materializedViewName, someMaterializedView(), false, false);
// set all properties to non-DEFAULT values and check the results
executeSetProperties(new SetProperties(MATERIALIZED_VIEW, asQualifiedName(materializedViewName), ImmutableList.of(new Property(new Identifier(MATERIALIZED_VIEW_PROPERTY_1_NAME), new LongLiteral("111")), new Property(new Identifier(MATERIALIZED_VIEW_PROPERTY_2_NAME), new StringLiteral("abc")))));
assertThat(metadata.getMaterializedView(testSession, materializedViewName).get().getProperties()).isEqualTo(ImmutableMap.of(MATERIALIZED_VIEW_PROPERTY_1_NAME, 111L, MATERIALIZED_VIEW_PROPERTY_2_NAME, "abc"));
// set all properties to DEFAULT and check the results
executeSetProperties(new SetProperties(MATERIALIZED_VIEW, asQualifiedName(materializedViewName), ImmutableList.of(new Property(new Identifier(MATERIALIZED_VIEW_PROPERTY_1_NAME)), new Property(new Identifier(MATERIALIZED_VIEW_PROPERTY_2_NAME)))));
// since the default value of property 1 is null, property 1 should not appear in the result, whereas property 2 should appear in
// the result with its (non-null) default value
assertThat(metadata.getMaterializedView(testSession, materializedViewName).get().getProperties()).isEqualTo(ImmutableMap.of(MATERIALIZED_VIEW_PROPERTY_2_NAME, MATERIALIZED_VIEW_PROPERTY_2_DEFAULT_VALUE));
}
use of io.trino.metadata.QualifiedObjectName in project trino by trinodb.
the class TestRenameMaterializedViewTask method testRenameMaterializedViewOnTableIfExists.
@Test
public void testRenameMaterializedViewOnTableIfExists() {
QualifiedObjectName tableName = qualifiedObjectName("existing_table");
metadata.createTable(testSession, CATALOG_NAME, someTable(tableName), false);
assertTrinoExceptionThrownBy(() -> getFutureValue(executeRenameMaterializedView(asQualifiedName(tableName), qualifiedName("existing_table_new"), true))).hasErrorCode(TABLE_NOT_FOUND).hasMessage("Materialized View '%s' does not exist, but a table with that name exists. Did you mean ALTER TABLE %s RENAME ...?", tableName, tableName);
}
use of io.trino.metadata.QualifiedObjectName in project trino by trinodb.
the class TestRenameMaterializedViewTask method testRenameMaterializedViewOnTable.
@Test
public void testRenameMaterializedViewOnTable() {
QualifiedObjectName tableName = qualifiedObjectName("existing_table");
metadata.createTable(testSession, CATALOG_NAME, someTable(tableName), false);
assertTrinoExceptionThrownBy(() -> getFutureValue(executeRenameMaterializedView(asQualifiedName(tableName), qualifiedName("existing_table_new")))).hasErrorCode(TABLE_NOT_FOUND).hasMessage("Materialized View '%s' does not exist, but a table with that name exists. Did you mean ALTER TABLE %s RENAME ...?", tableName, tableName);
}
use of io.trino.metadata.QualifiedObjectName in project trino by trinodb.
the class TestRenameMaterializedViewTask method testRenameExistingMaterializedView.
@Test
public void testRenameExistingMaterializedView() {
QualifiedObjectName materializedViewName = qualifiedObjectName("existing_materialized_view");
QualifiedObjectName newMaterializedViewName = qualifiedObjectName("existing_materialized_view_new");
metadata.createMaterializedView(testSession, materializedViewName, someMaterializedView(), false, false);
getFutureValue(executeRenameMaterializedView(asQualifiedName(materializedViewName), asQualifiedName(newMaterializedViewName)));
assertThat(metadata.isMaterializedView(testSession, materializedViewName)).isFalse();
assertThat(metadata.isMaterializedView(testSession, newMaterializedViewName)).isTrue();
}
Aggregations