cancel
Showing results forย 
Search instead forย 
Did you mean:ย 
Data Engineering
Join discussions on data engineering best practices, architectures, and optimization strategies within the Databricks Community. Exchange insights and solutions with fellow data engineers.
cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

Databricks SDK for Python: Errors with parameters for Statement Execution

Phuonganh
New Contributor II

Hi team,

Im using Databricks SDK for python to run SQL queries. I created a variable as below:

param = [{'name' : 'a', 'value' :x'}, {'name' : 'b', 'value' : 'y'}]

and passed it the statement as below

_ = w.statement_execution.execute_statement( warehouse_id = "123", catalog = "aaa", statement = "SELECT * FROM table_a WHERE name = :a and age = :b", parameters = param)

and I get an attribute error: 'dict' object has no attribute 'as_dict'

But this is exactly how databricks instructed on their website. Thank you for your help

 

2 REPLIES 2

DonkeyKong
New Contributor II

@Retired_mod This does not help resolve the issue. I am experiencing the same issue when following the above pointers. Here is the statement:

response = w.statement_execution.execute_statement(
    statement='ALTER TABLE users ALTER COLUMN :col_name SET NOT NULL', 
    warehouse_id='<warehouseID>',
    parameters=[{'name': 'col_name', 'value': 'user', 'type': 'STRING'}]
)

This results in the same AttributeError outlined by @Phuonganh above.

jessica3
New Contributor II

Has anyone found the solution to this? I am running into the same error

Connect with Databricks Users in Your Area

Join a Regional User Group to connect with local Databricks users. Events will be happening in your city, and you wonโ€™t want to miss the chance to attend and share knowledge.

If there isnโ€™t a group near you, start one and help create a community that brings people together.

Request a New Group