Skip to content

Commit

Permalink
Don't use Jinja #1055
Browse files Browse the repository at this point in the history
Signed-off-by: Marcel Coetzee <[email protected]>
  • Loading branch information
Pipboyguy committed Apr 15, 2024
1 parent 5ff769c commit 077455d
Showing 1 changed file with 9 additions and 14 deletions.
23 changes: 9 additions & 14 deletions dlt/destinations/impl/clickhouse/clickhouse.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

import clickhouse_connect
from clickhouse_connect.driver.tools import insert_file
from jinja2 import Template

import dlt
from dlt import config
Expand Down Expand Up @@ -200,19 +199,15 @@ def __init__(

structure = "auto"

template = Template("""
SELECT * FROM s3('{{ url }}'{% if access_key_id and secret_access_key %},
'{{ access_key_id }}','{{ secret_access_key }}'{% else %},NOSIGN{% endif %},'{{ clickhouse_format }}','{{ structure }}','{{ compression }}')
""")

table_function = template.render(
url=bucket_http_url,
access_key_id=access_key_id,
secret_access_key=secret_access_key,
clickhouse_format=clickhouse_format,
structure=structure,
compression=compression,
).strip()
table_function = f"SELECT * FROM s3('{bucket_http_url}'"

if access_key_id and secret_access_key:
table_function += f",'{access_key_id}','{secret_access_key}'"
else:
table_function += ",NOSIGN"

table_function += f",'{clickhouse_format}','{structure}','{compression}')"

statement = f"INSERT INTO {qualified_table_name} {table_function}"

elif bucket_scheme in ("az", "abfs"):
Expand Down

0 comments on commit 077455d

Please sign in to comment.