Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
3.4 kB
1
Indexable
Never
now after creating materialized you are given iam getting this error -->"response": "DataServiceError - ('Unable to complete the operation against any hosts', {<Host: 172.16.177.58:9042 datacenter1>: <Error from server: code=0000 [Server error] message=\"java.lang.RuntimeException: javax.management.InstanceAlreadyExistsException: org.apache.cassandra.db:type=Tables,keyspace=hobs_ods_staging,table=hos_cart_details_by_username\">}) . Line No - 97 "
}

the below one is my model class
from flask_cqlalchemy import CQLAlchemy
import uuid
from datetime import datetime

db = CQLAlchemy()


def serializetojson(self):
    results = {}
    for key in self.keys():
        if type(self[key]) in [str, int, bool, float, dict]:
            results[key] = self[key]
        elif type(self[key]) == type(None):
            results[key] = None
        elif type(self[key]) is list:
            lst = []
            for x in self[key]:
                lst.append(x)
                results[key] = lst
        elif type(self[key]) in [uuid.UUID, datetime]:
            results[key] = str(self[key])
        elif type(self[key] == bytes):
            results[key] = str(self[key].decode('utf-8'))
        else:
            results[key] = str(type(self[key]))
    return results


class hos_cart_details_by_username(db.Model):
    __keyspace__ = 'hobs_ods_staging'
    hoscd_username=db.columns.Text(primary_key=True)
    hoscd_event_date = db.columns.Date(primary_key=True)
    hoscd_businessid = db.columns.Text(primary_key=True)
    hoscd_key = db.columns.Text(primary_key=True)
    hoscd_buid = db.columns.Text()
    hoscd_createdtime = db.columns.DateTime()
    hoscd_opid = db.columns.Text()
    hoscd_status = db.columns.Text()
    hoscd_type = db.columns.Text()
    hoscd_updatedtime = db.columns.DateTime()
    hoscd_value = db.columns.Blob()
    hoscd_valuetype = db.columns.Text()

    def __json__(self):
        results = serializetojson(self)
        return results



db.sync_table(hos_cart_details_by_username)



the below one is my main table
CREATE TABLE hobs_ods_staging.hos_cart_details (
    hoscd_event_date date,
    hoscd_businessid text,
    hoscd_key text,
    hoscd_buid text,
    hoscd_createdtime timestamp,
    hoscd_opid text,
    hoscd_status text,
    hoscd_type text,
    hoscd_updatedtime timestamp,
    hoscd_username text,
    hoscd_value blob,
    hoscd_valuetype text,
    PRIMARY KEY (hoscd_event_date, hoscd_businessid, hoscd_key)
) WITH CLUSTERING ORDER BY (hoscd_businessid ASC, hoscd_key ASC)
    AND additional_write_policy = '99p'
    AND bloom_filter_fp_chance = 0.01
    AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'}
    AND cdc = false
    AND comment = ''
    AND compaction = {'class': 'org.apache.cassandra.db.compaction.DateTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'}
    AND compression = {'chunk_length_in_kb': '16', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'}
    AND memtable = 'default'
    AND crc_check_chance = 1.0
    AND default_time_to_live = 0
    AND extensions = {}
    AND gc_grace_seconds = 864000
    AND max_index_interval = 2048
    AND memtable_flush_period_in_ms = 0
    AND min_index_interval = 128
    AND read_repair = 'BLOCKING'
    AND speculative_retry = '99p';