Tiasnu
08/04/2025, 9:58 AMPARTITION BY or ORDER BY clause in table creation, in an ORM model. Could someone share an example with me. Or show me where the source code is? (currently the link on pypi https://pypi.org/project/starrocks/ directs to the source code of starrocks itself)Tiasnu
08/04/2025, 10:02 AMdef post_create_table(self, table):
"""Build table-level CREATE options like ENGINE and COLLATE."""
table_opts = []
opts = dict(
(k[len(self.dialect.name) + 1 :].upper(), v)
for k, v in table.kwargs.items()
if k.startswith("%s_" % self.dialect.name)
)
if table.comment is not None:
opts["COMMENT"] = table.comment
if 'ENGINE' in opts:
table_opts.append(f'ENGINE={opts["ENGINE"]}')
if 'PRIMARY_KEY' in opts:
table_opts.append(f'PRIMARY KEY({opts["PRIMARY_KEY"]})')
if 'DISTRIBUTED_BY' in opts:
table_opts.append(f'DISTRIBUTED BY HASH({opts["DISTRIBUTED_BY"]})')
if "COMMENT" in opts:
comment = self.sql_compiler.render_literal_value(
opts["COMMENT"], sqltypes.String()
)
table_opts.append(f"COMMENT {comment}")
# ToDo - Partition
# ToDo - Distribution
# ToDo - Order by
if "PROPERTIES" in opts:
props = ",\n".join([f'\t"{k}"="{v}"' for k, v in opts["PROPERTIES"]])
table_opts.append(f"PROPERTIES(\n{props}\n)")