Skip to content
This repository was archived by the owner on May 17, 2024. It is now read-only.

Commit 52d046a

Browse files
committed
presto: fix drop/insert/truncate/create
1 parent 75b8c5d commit 52d046a

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

data_diff/databases/presto.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,13 @@ def to_string(self, s: str):
5050

5151
def _query(self, sql_code: str) -> list:
5252
"Uses the standard SQL cursor interface"
53-
return _query_conn(self._conn, sql_code)
53+
c = self._conn.cursor()
54+
c.execute(sql_code)
55+
if sql_code.lower().startswith("select"):
56+
return c.fetchall()
57+
# Required for the query to actually run 🤯
58+
if re.match(r"(insert|create|truncate|drop)", sql_code, re.IGNORECASE):
59+
return c.fetchone()
5460

5561
def close(self):
5662
self._conn.close()

dev/presto-conf/standalone/catalog/postgresql.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ connector.name=postgresql
22
connection-url=jdbc:postgresql://postgres:5432/postgres
33
connection-user=postgres
44
connection-password=Password1
5+
allow-drop-table=true

0 commit comments

Comments
 (0)