Unable pass array of tables names from for each and send it task param
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 weeks ago - last edited 4 weeks ago
sending below array list from for each task
["mv_t005u","mv_t005t","mv_t880"]
In the task , iam reading value as
key :mv_name
value :{{input}}
but in note book i am getting below error
Note book code:
Note book code:
%sql
REFRESH MATERIALIZED VIEW nonprod_emea.silver_location.${mv_name}
error: Its keep on giving issue with \n
REFRESH statements cannot contain ' ', '\n', '\r', '\t' inside unquoted resource paths.
File <command-5604424783070824>, line 1 ----> 1 get_ipython().run_cell_magic('sql', '', 'REFRESH MATERIALIZED VIEW nonprod_emea.silver_location.{{input.mv_name}}\n')
File /databricks/python/lib/python3.11/site-packages/pyspark/sql/connect/client/core.py:2149, in SparkConnectClient._handle_rpc_error(self, rpc_error) 2134 raise Exception( 2135 "Python versions in the Spark Connect client and server are different. " 2136 "To execute user-defined functions, client and server should have the " (...) 2145 "https://docs.databricks.com/en/release-notes/serverless.html" target="_blank" rel="noopener noreferrer">https://docs.databricks.com/en/release-notes/serverless.html</a>.</span><span>"</span> 2146 ) 2147 # END-EDGE -> 2149 raise convert_exception( 2150 info, 2151 status.message, 2152 self._fetch_enriched_error(info), 2153 self._display_server_stack_trace(), 2154 ) from None 2156 raise SparkConnectGrpcException(status.message) from None 2157 else:
Please help to resolve the issue
1 REPLY 1
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 weeks ago
Hi @sivaram_mandepu,
In the first screenshot, the input must be a valid JSON array, so instead of using {{mvname: "mv_......"}}, update it to [ { "mvname": "mv_......." } ].
In the third screenshot, the SQL error likely comes from a newline or extra space in the mv_name value. You can try trimming the value in Python using dbutils.widgets.get("mv_name").strip() before using it in the SQL command.
Let me know if this doesn’t work.

