Skip to content

Commit

Permalink
Fix/insert-into-connector-fix (#405)
Browse files Browse the repository at this point in the history
* fixing db connector for redshift bigquery

* PR comments resolve

---------

Co-authored-by: Hari John Kuriakose <[email protected]>
  • Loading branch information
kirtimanmishrazipstack and hari-kuriakose authored Jun 20, 2024
1 parent 660ee19 commit 49b9873
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 18 deletions.
6 changes: 0 additions & 6 deletions backend/workflow_manager/endpoint/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,3 @@ class BigQuery:
"""

TABLE_NAME_SIZE = 3
COLUMN_TYPES = [
"DATE",
"DATETIME",
"TIME",
"TIMESTAMP",
]
7 changes: 0 additions & 7 deletions backend/workflow_manager/endpoint/database_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,6 @@ def get_sql_values_for_query(
sql_values[column] = f"parse_json($${values[column]}$$)"
else:
sql_values[column] = f"{values[column]}"
elif cls_name == DBConnectionClass.BIGQUERY:
col = column.lower()
type_x = column_types[col]
if type_x in BigQuery.COLUMN_TYPES:
sql_values[column] = f"{type_x}({values[column]})"
else:
sql_values[column] = f"{values[column]}"
else:
# Default to Other SQL DBs
# TODO: Handle numeric types with no quotes
Expand Down
2 changes: 1 addition & 1 deletion backend/workflow_manager/endpoint/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
from backend.celery import app as celery_app
from backend.celery_service import app as celery_app # type: ignore

__all__ = ["celery_app"]
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,10 @@ def execute_query(
table_name = str(kwargs.get("table_name"))
try:
if sql_values:
engine.query(sql_query, job_config=sql_values)
query_job = engine.query(sql_query, job_config=sql_values)
else:
engine.query(sql_query)
query_job = engine.query(sql_query)
query_job.result()
except google.api_core.exceptions.Forbidden as e:
logger.error(f"Forbidden exception in creating/inserting data: {str(e)}")
raise BigQueryForbiddenException(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,12 @@ def sql_to_db_mapping(value: str) -> str:
"""
python_type = type(value)
mapping = {
str: "SUPER",
str: "VARCHAR(65535)",
int: "BIGINT",
float: "DOUBLE PRECISION",
datetime.datetime: "TIMESTAMP",
}
return mapping.get(python_type, "SUPER")
return mapping.get(python_type, "VARCHAR(65535)")

@staticmethod
def get_create_table_query(table: str) -> str:
Expand Down

0 comments on commit 49b9873

Please sign in to comment.