Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

how to pass python variable to %%sql cell ? #810

Unanswered
cometta asked this question in Q&A
Discussion options

let say i have value in python variable call a= 'something'
in

%%sql 
select * from table_name where field = variable_a
You must be logged in to vote

Replies: 1 comment

Comment options

I don't think this is possible. Instead, I would use regular pyspark to create a temp view matching the condition you need, like so

someDf.where(F.col('field') == x).createTempView('tmp')

and then separately run

%%sql
select * from tmp
You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #808 on April 04, 2023 23:46.

AltStyle によって変換されたページ (->オリジナル) /