'test to ensure that materialized view metadata is properly updated when a type in the base table
is updated.
test_create_view_metadata tests that materialized views metadata is properly updated when the type of base table
column is changed.
@since 3.0.0
@jira_ticket CASSANDRA-10424
@expected_result Materialized view metadata should be updated correctly
@test_category metadata'

@lessthancass30
def test_base_table_type_alter_mv(self):

    create_table = 'CREATE    TABLE    {0}.scores(\n                                                                                                user    TEXT,\n                                                                                                game    TEXT,\n                                                                                                year    INT,\n                                                                                                month    INT,\n                                                                                                day    INT,\n                                                                                                score    TEXT,\n                                                                                                PRIMARY    KEY    (user,    game,    year,    month,    day)\n                                                                                                )'.format(self.keyspace_name)
    self.session.execute(create_table)
    create_mv = 'CREATE    MATERIALIZED    VIEW    {0}.monthlyhigh    AS\n                                                                                                SELECT    game,    year,    month,    score,    user,    day    FROM    {0}.scores\n                                                                                                WHERE    game    IS    NOT    NULL    AND    year    IS    NOT    NULL    AND    month    IS    NOT    NULL    AND    score    IS    NOT    NULL    AND    user    IS    NOT    NULL    AND    day    IS    NOT    NULL\n                                                                                                PRIMARY    KEY    ((game,    year,    month),    score,    user,    day)\n                                                                                                WITH    CLUSTERING    ORDER    BY    (score    DESC,    user    ASC,    day    ASC)'.format(self.keyspace_name)
    self.session.execute(create_mv)
    self.assertEqual(len(self.cluster.metadata.keyspaces[self.keyspace_name].views), 1)
    alter_scores = 'ALTER    TABLE    {0}.scores    ALTER    score    TYPE    blob'.format(self.keyspace_name)
    self.session.execute(alter_scores)
    self.assertEqual(len(self.cluster.metadata.keyspaces[self.keyspace_name].views), 1)
    score_column = self.cluster.metadata.keyspaces[self.keyspace_name].tables['scores'].columns['score']
    self.assertEqual(score_column.cql_type, 'blob')
    for i in range(10):
        score_mv_column = self.cluster.metadata.keyspaces[self.keyspace_name].views['monthlyhigh'].columns['score']
        if ('blob' == score_mv_column.cql_type):
            break
        time.sleep(0.2)
    self.assertEqual(score_mv_column.cql_type, 'blob')
