Error when running dbt run-operations with stage_external_sources macro. Ending up with sytax error, sql erro. Can someone help me with this ?

dma_load = nonpiiDBTOperatorLoad(
    task_id = "dma_load",
    #bash_command = "dbt run-operation stage_external_sources --args 'select: Roundel_DMA.S3_ROUNDEL_DMA_WEEKLY' --vars 'ext_full_refresh: true' --target load_nonpii",
    bash_command = """dbt run-operation stage_external_sources_custom \

–args=‘{“select”: “Roundel_DMA.S3_ROUNDEL_DMA_WEEKLY”}’
–vars=‘{“ext_full_refresh”: true}’
–target load_nonpii --debug"“”,
retries = 0
)

[2025-08-08, 12:40:11 UTC] {subprocess.py:93} INFO - 12:40:11 On macro_stage_external_sources_custom: show objects in DEV_CONS360NONPII_LOAD.AWSS3_RAW [2025-08-08, 12:40:11 UTC] {subprocess.py:93} INFO - limit 10000 [2025-08-08, 12:40:11 UTC] {subprocess.py:93} INFO - [2025-08-08, 12:40:11 UTC] {subprocess.py:93} INFO - /* {“app”: “dbt”, “dbt_version”: “1.10.7”, “profile_name”: “elementary”, “target_name”: “load_nonpii”, “connection_name”: “macro_stage_external_sources_custom”} */; [2025-08-08, 12:40:11 UTC] {subprocess.py:93} INFO - 12:40:11 Opening a new connection, currently in state init [2025-08-08, 12:40:12 UTC] {subprocess.py:93} INFO - 12:40:12 SQL status: SUCCESS 250 in 0.930 seconds [2025-08-08, 12:40:12 UTC] {subprocess.py:93} INFO - 12:40:12 While listing relations in database=DEV_CONS360NONPII_LOAD, schema=AWSS3_RAW, found: BRZMT_LATITUDE_LONGITUDE, “macro_stage_external_sources_custom”} */ [2025-08-08, 12:40:12 UTC] {subprocess.py:93} INFO - 12:40:12 Snowflake adapter: Snowflake query id: 01be3b78-0a0b-a45a-0002-a656a0fe75ca [2025-08-08, 12:40:12 UTC] {subprocess.py:93} INFO - 12:40:12 Snowflake adapter: Snowflake error: 001003 (42000): SQL compilation error: [2025-08-08, 12:40:12 UTC] {subprocess.py:93} INFO - syntax error line 2 at position 163 unexpected ‘’. [2025-08-08, 12:40:12 UTC] {subprocess.py:93} INFO - 12:40:12 Snowflake adapter: Error running SQL: macro stage_external_sources_custom [2025-08-08, 12:40:12 UTC] {subprocess.py:93} INFO - 12:40:12 Snowflake adapter: Rolling back transaction. [2025-08-08, 12:40:12 UTC] {subprocess.py:93} INFO - 12:40:12 On macro_stage_external_sources_custom: Close [2025-08-08, 12:40:12 UTC] {subprocess.py:93} INFO - 12:40:12 Encountered an error while running operation: Database Error [2025-08-08, 12:40:12 UTC] {subprocess.py:93} INFO - 001003 (42000): SQL compilation error: [2025-08-08, 12:40:12 UTC] {subprocess.py:93} INFO - syntax error line 2 at position 163 unexpected ‘’. [2025-08-08, 12:40:12 UTC] {subprocess.py:93} INFO - 12:40:12 Traceback (most recent call last): [2025-08-08, 12:40:12 UTC] {subprocess.py:93} INFO - File “/tmp/venv/lib/python3.12/site-packages/dbt/adapters/snowflake/connections.py”, line 320, in exception_handler [2025-08-08, 12:40:12 UTC] {subprocess.py:93} INFO - yield [2025-08-08, 12:40:12 UTC] {subprocess.py:93} INFO - File “/tmp/venv/lib/python3.12/site-packages/dbt/adapters/sql/connections.py”, line 148, in add_query [2025-08-08, 12:40:12 UTC] {subprocess.py:93} INFO - _execute_query_with_retry( [2025-08-08, 12:40:12 UTC] {subprocess.py:93} INFO - File “/tmp/venv/lib/python3.12/site-packages/dbt/adapters/sql/connections.py”, line 97, in _execute_query_with_retry [2025-08-08, 12:40:12 UTC] {subprocess.py:93} INFO - cursor.execute(sql, bindings) [2025-08-08, 12:40:12 UTC] {subprocess.py:93} INFO - File “/tmp/venv/lib/python3.12/site-packages/snowflake/connector/cursor.py”, line 1137, in execute [2025-08-08, 12:40:12 UTC] {subprocess.py:93} INFO - Error.errorhandler_wrapper(self.connection, self, error_class, errvalue) [2025-08-08, 12:40:12 UTC] {subprocess.py:93} INFO - File “/tmp/venv/lib/python3.12/site-packages/snowflake/connector/errors.py”, line 279, in errorhandler_wrapper [2025-08-08, 12:40:12 UTC] {subprocess.py:93} INFO - handed_over = Error.hand_to_other_handler( [2025-08-08, 12:40:12 UTC] {subprocess.py:93} INFO - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ [2025-08-08, 12:40:12 UTC] {subprocess.py:93} INFO - File “/tmp/venv/lib/python3.12/site-packages/snowflake/connector/errors.py”, line 334, in hand_to_other_handler [2025-08-08, 12:40:12 UTC] {subprocess.py:93} INFO - cursor.errorhandler(connection, cursor, error_class, error_value) [2025-08-08, 12:40:12 UTC] {subprocess.py:93} INFO - File “/tmp/venv/lib/python3.12/site-packages/snowflake/connector/errors.py”, line 210, in default_errorhandler [2025-08-08, 12:40:12 UTC] {subprocess.py:93} INFO - raise error_class( [2025-08-08, 12:40:12 UTC] {subprocess.py:93} INFO - snowflake.connector.errors.ProgrammingError: 001003 (42000): SQL compilation error: [2025-08-08, 12:40:12 UTC] {subprocess.py:93} INFO - syntax error line 2 at position 163 unexpected ‘’. [2025-08-08, 12:40:12 UTC] {subprocess.py:93} INFO - [2025-08-08, 12:40:12 UTC] {subprocess.py:93} INFO - During handling of the above exception, another exception occurred:


I fixed this myself, I was using --debug, actually --compile, --debug, or --defer flags that prevent full execution.

I removed this —debug from my operator and Bash command and its solved the issue.