Skip to content

Commit

Permalink
[新增]alter col增加sqlexpr
Browse files Browse the repository at this point in the history
  • Loading branch information
longfengpili committed Mar 4, 2024
1 parent 3d5c9c5 commit 2a628fc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
6 changes: 3 additions & 3 deletions pydbapi/api/trino.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# @Author: longfengpili
# @Date: 2023-06-02 15:27:41
# @Last Modified by: longfengpili
# @Last Modified time: 2024-03-04 18:15:24
# @Last Modified time: 2024-03-04 18:28:25
# @github: https://github.com/longfengpili


Expand Down Expand Up @@ -152,8 +152,8 @@ def insert(self, tablename, columns, inserttype='value', values=None, chunksize=
return rows, action, result

def alter_tablecol(self, tablename: str, colname: str, newname: str = None, newtype: str = None,
partition: str = 'part_date', conditions: list[str] = None, verbose: int = 0):
alter_columns = self.alter_column(tablename, colname, newname, newtype)
sqlexpr: str = None, partition: str = 'part_date', conditions: list[str] = None, verbose: int = 0):
alter_columns = self.alter_column(tablename, colname, newname, newtype, sqlexpr)

if alter_columns:
# create tmp table
Expand Down
8 changes: 6 additions & 2 deletions tests/trino/test_trino.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# @Author: longfengpili
# @Date: 2023-06-02 15:27:41
# @Last Modified by: longfengpili
# @Last Modified time: 2024-03-01 12:09:05
# @Last Modified time: 2024-03-04 18:47:44
# @github: https://github.com/longfengpili


Expand Down Expand Up @@ -201,5 +201,9 @@ def test_alter_col(self):
alter_cols = self.trinodb.alter_column(self.tablename, 'id', 'idx', 'int')
print(alter_cols)

def test_alter_table(self):
def test_alter_tablecol(self):
self.trinodb.alter_tablecol(self.tablename, colname='id', newname='idx', newtype='int', partition='birthday')

def test_alter_tablecol1(self):
self.trinodb.alter_tablecol(self.tablename, colname='idx', newname='idx',
newtype='int', sqlexpr='idx * 10', partition='birthday')

0 comments on commit 2a628fc

Please sign in to comment.