Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-24-2025 05:01 PM
CJS had the best answer by virtue of it being code-based rather than widget-based. In a notebook where the value of the variable must continually be reset, widgets are suboptimal. That said, the easiest way is to wrap the code in python:
%py
var1 = some_value ##string, int, whatever
var2 = some_other_value
qry = f"select * from {var1} where some_field = {var2}" ##use python's format feature to place variables cleanly
display(spark.sql(qry))