Skip to content

Commit

Permalink
[修复]trino
Browse files Browse the repository at this point in the history
  • Loading branch information
longfengpili committed Nov 14, 2023
1 parent 37ae7ce commit e5b8f80
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 25 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: 2023-11-03 10:59:55
# @Last Modified time: 2023-11-14 16:16:00
# @github: https://github.com/longfengpili


Expand Down Expand Up @@ -42,8 +42,8 @@ def create(self, columns, partition=None):
partition_sql = None
if partition:
partition_key = columns.get_column_by_name(partition)
columns = columns.remove(partition)
columns = columns.append(partition_key)
columns.remove(partition)
columns.append(partition_key)
partition_sql = self.create_partition(partition_key)

sql = self.create_nonindex(columns)
Expand Down
4 changes: 2 additions & 2 deletions pydbapi/col/colmodel.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: 2023-10-31 11:30:48
# @Last Modified time: 2023-11-14 16:18:21
# @github: https://github.com/longfengpili

from typing import Iterable, List, Any
Expand Down Expand Up @@ -95,7 +95,7 @@ def remove(self, remove_column: str):
for column in columns:
if column.newname != remove_column:
new_columns.append(column)
return ColumnsModel(*new_columns)
self.columns = new_columns

@property
def func_cols(self):
Expand Down
2 changes: 1 addition & 1 deletion pydbapi/db/base.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: 2023-11-13 12:08:35
# @Last Modified time: 2023-11-14 16:35:27
# @github: https://github.com/longfengpili


Expand Down
2 changes: 1 addition & 1 deletion pydbapi/sql/compile.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: 2023-07-27 15:35:21
# @Last Modified time: 2023-11-14 16:14:56
# @github: https://github.com/longfengpili


Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
# @Author: longfengpili
# @Date: 2023-06-02 15:27:41
# @Last Modified by: longfengpili
# @Last Modified time: 2023-11-03 14:09:37
# @Last Modified time: 2023-11-14 16:36:24
# @github: https://github.com/longfengpili


import setuptools

VERSION = '0.0.114'
VERSION = '0.0.115'
PROJECT_NAME = 'pydbapi'

with open('README.md', 'r', encoding='utf-8') as f:
Expand Down
32 changes: 16 additions & 16 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: 2023-10-25 11:11:51
# @Last Modified time: 2023-11-14 16:36:12
# @github: https://github.com/longfengpili


Expand All @@ -24,7 +24,7 @@ class TestTrino:

def setup_method(self, method):
self.trinodb = TrinoDB(TRINO_HOST, TRINO_USER, TRINO_PASSWORD, TRINO_DATABASE, safe_rule=False)
self.tablename = 'dow_jp_w.test_friuts_xu'
self.tablename = 'dow_jp_w.test_friut_xu'
self.id = ColumnModel('id', 'integer')
self.name = ColumnModel('name', 'varchar(1024)')
self.address = ColumnModel('address', 'varchar(1024)')
Expand Down Expand Up @@ -73,8 +73,8 @@ def test_insert(self):
print(f"【rows】: {rows}, 【action】: {action}, 【result】: {result}")

def test_create_by_sql1(self):
sql = '''
create table if not exists dow_jp_w.test_xu1
sql = f'''
create table if not exists {self.tablename}_bysql
(time varchar,
adid varchar,
dt varchar)
Expand All @@ -84,11 +84,11 @@ def test_create_by_sql1(self):
print(f"【rows】: {rows}, 【action】: {action}, 【result】: {result}")

def test_create_by_sql2(self):
sql = '''
create table if not exists dow_jp_w.test_xu2 as
sql = f'''
create table if not exists {self.tablename}_bysql2 as
with test as
(select *
from dow_jp_w.test_friuts_xu
from {self.tablename}
limit 10),
test1 as
Expand All @@ -103,11 +103,11 @@ def test_create_by_sql2(self):
print(f"【rows】: {rows}, 【action】: {action}, 【result】: {result}")

def test_insert_by_sql(self):
sql = '''
delete from dow_jp_w.test_xu2;
sql = f'''
delete from {self.tablename}_bysql2;
with test as
(select *
from dow_jp_w.test_friuts_xu
from {self.tablename}
limit 10),
test1 as
Expand All @@ -117,10 +117,10 @@ def test_insert_by_sql(self):
select * from test1
;
insert into dow_jp_w.test_xu2
insert into {self.tablename}_bysql2
with test as
(select *
from dow_jp_w.test_friuts_xu
from {self.tablename}
limit 10),
test1 as
Expand All @@ -135,17 +135,17 @@ def test_insert_by_sql(self):
print(f"【rows】: {rows}, 【action】: {action}, 【result】: {result}")

def test_drop_by_sql(self):
sql = '''
drop table dow_jp_w.test_xu
sql = f'''
drop table {self.tablename}_bysql
'''
rows, action, result = self.trinodb.execute(sql)
print(f"【rows】: {rows}, 【action】: {action}, 【result】: {result}")

def test_select_by_sql(self):
sql = '''
sql = f'''
with test as
(select *
from dow_jp_w.test_friuts_xu
from {self.tablename}
limit 10),
test1 as
Expand Down

0 comments on commit e5b8f80

Please sign in to comment.