[Python] Databricks Widget into list

Discussão em 'Python' iniciado por Stack, Fevereiro 18, 2025.

  1. Stack

    Stack Membro Participativo

    I am trying to pass a widget with multiple comma-separated widget values into a list into an SQL query. I can get the widget value into a list like so:

    # Create a widget for user input
    dbutils.widgets.text("codes_to_search", "", "Enter values separated by comma")

    # Get the input values from the widget
    input_values = dbutils.widgets.get("codes_to_search")

    # Convert the input string into a list
    input_list = input_values.split(",")

    # Display the input list
    input_list


    However, when I try to pass the list into the query using:

    and concept_name in ($(input_list))


    I get told I'm using a parameter, so I need to pass using parameter syntax, but when I use the parameter syntax, it tells me I'm trying to pass a python variable, and I need to use that syntax. I'm stuck in a loop. Can anybody help?

    Continue reading...

Compartilhe esta Página