Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions contrib/starrocks-python-client/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,9 @@ class MyTable(Base):
__table_args__ = {
'comment': 'table comment',

'starrocks_PRIMARY_KEY': 'id',
'starrocks_DISTRIBUTED_BY': 'HASH(id) BUCKETS 10',
'starrocks_PROPERTIES': {'replication_num': '1'}
'starrocks_primary_key': 'id',
'starrocks_distributed_by': 'HASH(id) BUCKETS 10',
'starrocks_properties': {'replication_num': '1'}
}

# Create the table in the database
Expand All @@ -106,7 +106,7 @@ Base.metadata.create_all(engine)
Alternatively, you can use SQLAlchemy Core to define tables programmatically.

```python
from sqlalchemy import Table, MetaData, Column
from sqlalchemy import Column, MetaData, Table
from starrocks import INTEGER, VARCHAR

metadata = MetaData()
Expand All @@ -118,9 +118,9 @@ my_core_table = Table(
Column('name', VARCHAR(50)),

# StarRocks-specific arguments
starrocks_PRIMARY_KEY='id',
starrocks_DISTRIBUTED_BY='HASH(id) BUCKETS 10',
starrocks_PROPERTIES={"replication_num": "1"}
starrocks_primary_key='id',
starrocks_distributed_by='HASH(id) BUCKETS 10',
starrocks_properties={"replication_num": "1"}
)

# Create the table in the database
Expand Down
24 changes: 12 additions & 12 deletions contrib/starrocks-python-client/docs/usage_guide/alembic.md
Original file line number Diff line number Diff line change
Expand Up @@ -292,20 +292,20 @@ class MyTable(Base):
__table_args__ = {
'comment': 'table comment',

'starrocks_PRIMARY_KEY': 'id',
'starrocks_ENGINE': 'OLAP',
'starrocks_PARTITION_BY': """RANGE (id) (
'starrocks_primary_key': 'id',
'starrocks_engine': 'OLAP',
'starrocks_partition_by': """RANGE (id) (
PARTITION p1 VALUES LESS THAN ('100')
)""",
'starrocks_DISTRIBUTED_BY': 'HASH(id) BUCKETS 10',
'starrocks_PROPERTIES': {
'starrocks_distributed_by': 'HASH(id) BUCKETS 10',
'starrocks_properties': {
'storage_medium': 'SSD',
'replication_num': '1'
}
}
```

**Note**: All columns that appear in a StarRocks key (`starrocks_PRIMARY_KEY`, `starrocks_UNIQUE_KEY`, `starrocks_DUPLICATE_KEY`, or `starrocks_AGGREGATE_KEY`) must also be marked with `primary_key=True` in their `Column(...)` declarations.
**Note**: All columns that appear in a StarRocks key (`starrocks_primary_key`, `starrocks_unique_key`, `starrocks_duplicate_key`, or `starrocks_aggregate_key`) must also be marked with `primary_key=True` in their `Column(...)` declarations.

> In the above example, it the `id` column.

Expand Down Expand Up @@ -386,7 +386,7 @@ Follow the standard Alembic workflow:

If there is some problems of the generated script (e.g., `versions/<revision_id>_...py`), or some problems of the `models.py`, you should delete the generated script file, and re-run the `--autogenerate` commond above, to re-generate a migration script.

### View Autogenerate Details and Limitations (Invalid for the moment)
### View Autogenerate Details and Limitations

When you define `View` or `MaterializedView` objects in your model files (e.g., `models_view.py`), Alembic's autogenerate process will detect them and create the appropriate migration operations, which are similar with Tables.

Expand Down Expand Up @@ -438,13 +438,13 @@ class MyTable(Base):
__table_args__ = {
'comment': 'A modified table comment', # Modified comment

'starrocks_PRIMARY_KEY': 'id',
'starrocks_ENGINE': 'OLAP',
'starrocks_PARTITION_BY': """RANGE (id) (
'starrocks_primary_key': 'id',
'starrocks_engine': 'OLAP',
'starrocks_partition_by': """RANGE (id) (
PARTITION p1 VALUES LESS THAN ('100')
)""",
'starrocks_DISTRIBUTED_BY': 'HASH(id) BUCKETS 10',
'starrocks_PROPERTIES': {
'starrocks_distributed_by': 'HASH(id) BUCKETS 10',
'starrocks_properties': {
'storage_medium': 'SSD',
'replication_num': '1'
}
Expand Down
4 changes: 2 additions & 2 deletions contrib/starrocks-python-client/docs/usage_guide/tables.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ my_table = Table(

Note: Usage mirrors standard SQLAlchemy patterns (e.g., MySQL dialect), but you should use types from `starrocks` and keep them uppercase.

**Important**: If you specify a StarRocks table key via `starrocks_PRIMARY_KEY`, `starrocks_UNIQUE_KEY`, `starrocks_DUPLICATE_KEY`, or `starrocks_AGGREGATE_KEY`, all columns listed in that key **MUST** also be declared with `primary_key=True` on their `Column(...)` definitions. This ensures SQLAlchemy metadata and Alembic autogenerate behave correctly.
**Important**: If you specify a StarRocks table key via `starrocks_primary_key`, `starrocks_unique_key`, `starrocks_duplicate_key`, or `starrocks_aggregate_key`, all columns listed in that key **MUST** also be declared with `primary_key=True` on their `Column(...)` definitions. This ensures SQLAlchemy metadata and Alembic autogenerate behave correctly.

## Defining Table Attributes

Expand All @@ -48,7 +48,7 @@ StarRocks-specific physical attributes for a table are configured by passing spe

Here is a comprehensive list of the supported `starrocks_` prefixed arguments. The order of attributes in the documentation follows the recommended order in the `CREATE TABLE` DDL statement.

The prefix `starrocks_` should be **lower case**, the other part can be either lower case or upper case for clearity.
The prefix `starrocks_` should be **lower case**. The suffix is case-insensitive, but it is recommended to use lowercase in your code for consistency (all examples in this guide use lowercase).

##### 1. `starrocks_engine`

Expand Down
4 changes: 4 additions & 0 deletions docs/docusaurus/sidebars.json
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,10 @@
{
"type": "doc",
"id": "integrations/dbt"
},
{
"type": "doc",
"id": "integrations/smt/starrocks_sqlalchemy"
}
]
},
Expand Down
Loading
Loading