jayvynl / django-clickhouse-backend

Django clickhouse database backend.
MIT License
130 stars 21 forks source link

[BUG] AttributeError: 'ReplicatedReplacingMergeTree' object has no attribute 'expressions' #76

Closed magichuang77 closed 9 months ago

magichuang77 commented 9 months ago

Describe the bug Using models.ReplicatedReplacingMergeTree engine reported an error:

AttributeError: 'ReplicatedReplacingMergeTree' object has no attribute 'expressions'

To Reproduce

class Student(models.ClickhouseModel):
    name = models.StringField()
    address = models.StringField()
    score = models.Int8Field()

    class Meta:
        engine = models.ReplicatedReplacingMergeTree(
            "/clickhouse/tables/{uuid}/{shard}",
            "{replica}",
            order_by="id"
        )
        cluster = "cluster"

Expected behavior Same as using models.ReplicatedMergeTree logic

Versions

magichuang77 commented 9 months ago

pr: https://github.com/jayvynl/django-clickhouse-backend/pull/77

jayvynl commented 9 months ago

I find new issue when debugging this issue, ReplicatedReplacingMergeTree and ReplacingMergeTree are not working when the optional parameter ver exists.

I need more time to solve this.

magichuang77 commented 9 months ago

Another new issue has been discovered, if configured in the config.xml of Clickhouse

    <default_replica_path>/clickhouse/tables/{shard}/{database}/{table}</default_replica_path>
    <default_replica_name>{replica}</default_replica_name>

When the parameter is not passed in the ReplicatedReplacingMergeTree() of django, an error will also be reported

# clickhouse_backend/models/engines.py", line 208
TypeError: 'ReplicatedReplacingMergeTree' takes at least 2 arguments (0 given)
jayvynl commented 9 months ago

@magichuang77 All the bugs mentioned in this post have been fixed. Please install from master branch and verify. If ok, I will release a new version.

magichuang77 commented 9 months ago

@jayvynl I used the master branch code, which met my expectations and did not encounter the above issues. Thank you

jayvynl commented 9 months ago

@jayvynl I used the master branch code, which met my expectations and did not encounter the above issues. Thank you

Glad to hear that. Latest version v1.1.7.