Search in sources :

Example 6 with TablePropertyManager

use of io.trino.metadata.TablePropertyManager in project trino by trinodb.

the class TestCreateTableTask method testCreateLikeWithProperties.

@Test
public void testCreateLikeWithProperties() {
    CreateTable statement = getCreatleLikeStatement(true);
    CreateTableTask createTableTask = new CreateTableTask(plannerContext, new AllowAllAccessControl(), columnPropertyManager, tablePropertyManager);
    getFutureValue(createTableTask.internalExecute(statement, testSession, List.of(), output -> {
    }));
    assertEquals(metadata.getCreateTableCallCount(), 1);
    assertThat(metadata.getReceivedTableMetadata().get(0).getColumns()).isEqualTo(PARENT_TABLE.getColumns());
    assertThat(metadata.getReceivedTableMetadata().get(0).getProperties()).isEqualTo(PARENT_TABLE.getProperties());
}
Also used : TransactionManager(io.trino.transaction.TransactionManager) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Test(org.testng.annotations.Test) TestingTableHandle(io.trino.testing.TestingMetadata.TestingTableHandle) AfterMethod(org.testng.annotations.AfterMethod) SHOW_CREATE_TABLE(io.trino.testing.TestingAccessControlManager.TestingPrivilegeType.SHOW_CREATE_TABLE) TrinoExceptionAssert.assertTrinoExceptionThrownBy(io.trino.testing.assertions.TrinoExceptionAssert.assertTrinoExceptionThrownBy) TestingConnectorTransactionHandle(io.trino.sql.planner.TestingConnectorTransactionHandle) NOT_SUPPORTED(io.trino.spi.StandardErrorCode.NOT_SUPPORTED) CatalogName(io.trino.connector.CatalogName) MockConnectorFactory(io.trino.connector.MockConnectorFactory) Map(java.util.Map) TEST_SESSION(io.trino.SessionTestUtils.TEST_SESSION) ALREADY_EXISTS(io.trino.spi.StandardErrorCode.ALREADY_EXISTS) TestingAccessControlManager(io.trino.testing.TestingAccessControlManager) Property(io.trino.sql.tree.Property) ENGLISH(java.util.Locale.ENGLISH) Assert.assertFalse(org.testng.Assert.assertFalse) Identifier(io.trino.sql.tree.Identifier) SMALLINT(io.trino.spi.type.SmallintType.SMALLINT) TableElement(io.trino.sql.tree.TableElement) ImmutableMap(com.google.common.collect.ImmutableMap) INCLUDING(io.trino.sql.tree.LikeClause.PropertiesOption.INCLUDING) Collections.emptyList(java.util.Collections.emptyList) TypeSignatureTranslator.toSqlType(io.trino.sql.analyzer.TypeSignatureTranslator.toSqlType) BeforeMethod(org.testng.annotations.BeforeMethod) Set(java.util.Set) TrinoException(io.trino.spi.TrinoException) SchemaTableName(io.trino.spi.connector.SchemaTableName) TableMetadata(io.trino.metadata.TableMetadata) List(java.util.List) TestingSession.testSessionBuilder(io.trino.testing.TestingSession.testSessionBuilder) CreateTable(io.trino.sql.tree.CreateTable) BIGINT(io.trino.spi.type.BigintType.BIGINT) Optional(java.util.Optional) ColumnPropertyManager(io.trino.metadata.ColumnPropertyManager) DATE(io.trino.spi.type.DateType.DATE) Session(io.trino.Session) PlannerContext(io.trino.sql.PlannerContext) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) AccessDeniedException(io.trino.spi.security.AccessDeniedException) SELECT_COLUMN(io.trino.testing.TestingAccessControlManager.TestingPrivilegeType.SELECT_COLUMN) AllowAllAccessControl(io.trino.security.AllowAllAccessControl) ColumnMetadata(io.trino.spi.connector.ColumnMetadata) Assert.assertEquals(org.testng.Assert.assertEquals) ConnectorTableMetadata(io.trino.spi.connector.ConnectorTableMetadata) VARCHAR(io.trino.spi.type.VarcharType.VARCHAR) ImmutableList(com.google.common.collect.ImmutableList) Assertions.assertThatThrownBy(org.assertj.core.api.Assertions.assertThatThrownBy) TestingPlannerContext.plannerContextBuilder(io.trino.sql.planner.TestingPlannerContext.plannerContextBuilder) LocalQueryRunner(io.trino.testing.LocalQueryRunner) Objects.requireNonNull(java.util.Objects.requireNonNull) ColumnHandle(io.trino.spi.connector.ColumnHandle) INVALID_TABLE_PROPERTY(io.trino.spi.StandardErrorCode.INVALID_TABLE_PROPERTY) VARBINARY(io.trino.spi.type.VarbinaryType.VARBINARY) EventListenerConfig(io.trino.eventlistener.EventListenerConfig) PropertyMetadata.stringProperty(io.trino.spi.session.PropertyMetadata.stringProperty) QueryUtil.identifier(io.trino.sql.QueryUtil.identifier) Sets.immutableEnumSet(com.google.common.collect.Sets.immutableEnumSet) NOT_NULL_COLUMN_CONSTRAINT(io.trino.spi.connector.ConnectorCapabilities.NOT_NULL_COLUMN_CONSTRAINT) StringLiteral(io.trino.sql.tree.StringLiteral) Collections.emptySet(java.util.Collections.emptySet) ConnectorCapabilities(io.trino.spi.connector.ConnectorCapabilities) MoreFutures.getFutureValue(io.airlift.concurrent.MoreFutures.getFutureValue) QualifiedName(io.trino.sql.tree.QualifiedName) LikeClause(io.trino.sql.tree.LikeClause) AbstractMockMetadata(io.trino.metadata.AbstractMockMetadata) TableHandle(io.trino.metadata.TableHandle) TestingAccessControlManager.privilege(io.trino.testing.TestingAccessControlManager.privilege) QualifiedObjectName(io.trino.metadata.QualifiedObjectName) EventListenerManager(io.trino.eventlistener.EventListenerManager) TablePropertyManager(io.trino.metadata.TablePropertyManager) Assert.assertTrue(org.testng.Assert.assertTrue) ColumnDefinition(io.trino.sql.tree.ColumnDefinition) AllowAllAccessControl(io.trino.security.AllowAllAccessControl) CreateTable(io.trino.sql.tree.CreateTable) Test(org.testng.annotations.Test)

Example 7 with TablePropertyManager

use of io.trino.metadata.TablePropertyManager in project trino by trinodb.

the class TestCreateTableTask method testCreateTableNotExistsTrue.

@Test
public void testCreateTableNotExistsTrue() {
    CreateTable statement = new CreateTable(QualifiedName.of("test_table"), ImmutableList.of(new ColumnDefinition(identifier("a"), toSqlType(BIGINT), true, emptyList(), Optional.empty())), true, ImmutableList.of(), Optional.empty());
    CreateTableTask createTableTask = new CreateTableTask(plannerContext, new AllowAllAccessControl(), columnPropertyManager, tablePropertyManager);
    getFutureValue(createTableTask.internalExecute(statement, testSession, emptyList(), output -> {
    }));
    assertEquals(metadata.getCreateTableCallCount(), 1);
}
Also used : TransactionManager(io.trino.transaction.TransactionManager) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Test(org.testng.annotations.Test) TestingTableHandle(io.trino.testing.TestingMetadata.TestingTableHandle) AfterMethod(org.testng.annotations.AfterMethod) SHOW_CREATE_TABLE(io.trino.testing.TestingAccessControlManager.TestingPrivilegeType.SHOW_CREATE_TABLE) TrinoExceptionAssert.assertTrinoExceptionThrownBy(io.trino.testing.assertions.TrinoExceptionAssert.assertTrinoExceptionThrownBy) TestingConnectorTransactionHandle(io.trino.sql.planner.TestingConnectorTransactionHandle) NOT_SUPPORTED(io.trino.spi.StandardErrorCode.NOT_SUPPORTED) CatalogName(io.trino.connector.CatalogName) MockConnectorFactory(io.trino.connector.MockConnectorFactory) Map(java.util.Map) TEST_SESSION(io.trino.SessionTestUtils.TEST_SESSION) ALREADY_EXISTS(io.trino.spi.StandardErrorCode.ALREADY_EXISTS) TestingAccessControlManager(io.trino.testing.TestingAccessControlManager) Property(io.trino.sql.tree.Property) ENGLISH(java.util.Locale.ENGLISH) Assert.assertFalse(org.testng.Assert.assertFalse) Identifier(io.trino.sql.tree.Identifier) SMALLINT(io.trino.spi.type.SmallintType.SMALLINT) TableElement(io.trino.sql.tree.TableElement) ImmutableMap(com.google.common.collect.ImmutableMap) INCLUDING(io.trino.sql.tree.LikeClause.PropertiesOption.INCLUDING) Collections.emptyList(java.util.Collections.emptyList) TypeSignatureTranslator.toSqlType(io.trino.sql.analyzer.TypeSignatureTranslator.toSqlType) BeforeMethod(org.testng.annotations.BeforeMethod) Set(java.util.Set) TrinoException(io.trino.spi.TrinoException) SchemaTableName(io.trino.spi.connector.SchemaTableName) TableMetadata(io.trino.metadata.TableMetadata) List(java.util.List) TestingSession.testSessionBuilder(io.trino.testing.TestingSession.testSessionBuilder) CreateTable(io.trino.sql.tree.CreateTable) BIGINT(io.trino.spi.type.BigintType.BIGINT) Optional(java.util.Optional) ColumnPropertyManager(io.trino.metadata.ColumnPropertyManager) DATE(io.trino.spi.type.DateType.DATE) Session(io.trino.Session) PlannerContext(io.trino.sql.PlannerContext) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) AccessDeniedException(io.trino.spi.security.AccessDeniedException) SELECT_COLUMN(io.trino.testing.TestingAccessControlManager.TestingPrivilegeType.SELECT_COLUMN) AllowAllAccessControl(io.trino.security.AllowAllAccessControl) ColumnMetadata(io.trino.spi.connector.ColumnMetadata) Assert.assertEquals(org.testng.Assert.assertEquals) ConnectorTableMetadata(io.trino.spi.connector.ConnectorTableMetadata) VARCHAR(io.trino.spi.type.VarcharType.VARCHAR) ImmutableList(com.google.common.collect.ImmutableList) Assertions.assertThatThrownBy(org.assertj.core.api.Assertions.assertThatThrownBy) TestingPlannerContext.plannerContextBuilder(io.trino.sql.planner.TestingPlannerContext.plannerContextBuilder) LocalQueryRunner(io.trino.testing.LocalQueryRunner) Objects.requireNonNull(java.util.Objects.requireNonNull) ColumnHandle(io.trino.spi.connector.ColumnHandle) INVALID_TABLE_PROPERTY(io.trino.spi.StandardErrorCode.INVALID_TABLE_PROPERTY) VARBINARY(io.trino.spi.type.VarbinaryType.VARBINARY) EventListenerConfig(io.trino.eventlistener.EventListenerConfig) PropertyMetadata.stringProperty(io.trino.spi.session.PropertyMetadata.stringProperty) QueryUtil.identifier(io.trino.sql.QueryUtil.identifier) Sets.immutableEnumSet(com.google.common.collect.Sets.immutableEnumSet) NOT_NULL_COLUMN_CONSTRAINT(io.trino.spi.connector.ConnectorCapabilities.NOT_NULL_COLUMN_CONSTRAINT) StringLiteral(io.trino.sql.tree.StringLiteral) Collections.emptySet(java.util.Collections.emptySet) ConnectorCapabilities(io.trino.spi.connector.ConnectorCapabilities) MoreFutures.getFutureValue(io.airlift.concurrent.MoreFutures.getFutureValue) QualifiedName(io.trino.sql.tree.QualifiedName) LikeClause(io.trino.sql.tree.LikeClause) AbstractMockMetadata(io.trino.metadata.AbstractMockMetadata) TableHandle(io.trino.metadata.TableHandle) TestingAccessControlManager.privilege(io.trino.testing.TestingAccessControlManager.privilege) QualifiedObjectName(io.trino.metadata.QualifiedObjectName) EventListenerManager(io.trino.eventlistener.EventListenerManager) TablePropertyManager(io.trino.metadata.TablePropertyManager) Assert.assertTrue(org.testng.Assert.assertTrue) ColumnDefinition(io.trino.sql.tree.ColumnDefinition) AllowAllAccessControl(io.trino.security.AllowAllAccessControl) CreateTable(io.trino.sql.tree.CreateTable) ColumnDefinition(io.trino.sql.tree.ColumnDefinition) Test(org.testng.annotations.Test)

Aggregations

TablePropertyManager (io.trino.metadata.TablePropertyManager)7 AllowAllAccessControl (io.trino.security.AllowAllAccessControl)6 BeforeMethod (org.testng.annotations.BeforeMethod)6 CatalogName (io.trino.connector.CatalogName)5 AbstractMockMetadata (io.trino.metadata.AbstractMockMetadata)5 QualifiedObjectName (io.trino.metadata.QualifiedObjectName)5 AccessDeniedException (io.trino.spi.security.AccessDeniedException)5 ImmutableList (com.google.common.collect.ImmutableList)4 ImmutableMap (com.google.common.collect.ImmutableMap)4 Sets.immutableEnumSet (com.google.common.collect.Sets.immutableEnumSet)4 MoreFutures.getFutureValue (io.airlift.concurrent.MoreFutures.getFutureValue)4 Session (io.trino.Session)4 TEST_SESSION (io.trino.SessionTestUtils.TEST_SESSION)4 MockConnectorFactory (io.trino.connector.MockConnectorFactory)4 EventListenerConfig (io.trino.eventlistener.EventListenerConfig)4 EventListenerManager (io.trino.eventlistener.EventListenerManager)4 ColumnPropertyManager (io.trino.metadata.ColumnPropertyManager)4 TableHandle (io.trino.metadata.TableHandle)4 TableMetadata (io.trino.metadata.TableMetadata)4 ALREADY_EXISTS (io.trino.spi.StandardErrorCode.ALREADY_EXISTS)4