0

So I am trying to insert data into a snowflake transient table (from a parquet file), but my syntax doesn't allow me to go past our SAST test in the pipeline.

Do you see anything wrong with the following code snippet (especially the insert into step since it is causing the error):

with snowflake_engine.begin() as tx:
(SOME WORKING CODE)...
        if table == "lending_adjudications":
            tx.execute(
                f"put file://{pq_filepath_2} @{destination_schema}.{stage_guid_part_2}"
            ).fetchall()

            stmts = [
                f"create or replace transient table {destination_schema}.{table} as "  # nosec
                f"select $1 as fields from @{destination_schema}.{stage_guid}",  # nosec
                f"insert into {destination_schema}.{table} "
                f"select $1 as fields from @{destination_schema}.{stage_guid_part_2}",
            ]

            [tx.execute(stmt).fetchall() for stmt in stmts]

        else:
            tx.execute(
                f"create or replace transient table {destination_schema}.{table} as "  # nosec
                f"select $1 as fields from @{destination_schema}.{stage_guid}"  # nosec
            ).fetchall()
...

Thank you so much for your help, any insight is highly appreciated.

Salahddin-Warid
  • 105
  • 1
  • 1
  • 5
  • Also, please post the error. – Pankaj Apr 14 '22 at 22:51
  • @Pankaj I dont have access to the error, all I can see is a failure for this step of the pipeline: sast: stage: test tags: - k8s image: python:${PYTHON_VERSION} script: - pip install bandit - bandit -r . -f xml -ll -o sast.xml artifacts: when: always paths: - sast.xml reports: junit: sast.xml – Salahddin-Warid Apr 14 '22 at 23:15
  • Using a statement like **select $1 as fields from @{destination_schema}.{stage_guid_part_2}** without specifying the file can cause improper output or even error if you have more than one file with different formats. Are you sure you have only **{pq_filepath_2}** file there? – Sergiu Apr 19 '22 at 17:32

0 Answers0