Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@ class TablesPlotOpDesc extends PythonOperatorDescriptor {
var includedColumns: List[TablesConfig] = List()

private def getAttributes: String =
includedColumns.map(c => pyb"""${c.attributeName}""").mkString("','")
// Join with a plain comma: each column renders to a decode_python_template(...)
// call, so joining with the literal ',' would put a string right after a call
// and produce invalid Python.
includedColumns.map(c => pyb"""${c.attributeName}""").mkString(",")

def manipulateTable(): PythonTemplateBuilder = {
assert(includedColumns.nonEmpty, "Included Columns cannot be empty")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,15 @@ class TablesPlotOpDescSpec extends AnyFlatSpec with BeforeAndAfter with Matchers
assert(carries(code, "col_two"))
code should include("class TableChartOperator(UDFTableOperator)")
}

it should "join multiple columns with a comma, not the literal ',' (valid Python)" in {
// Each column renders to a decode(...) call, so they must be comma-joined;
// joining with the literal ',' puts a string right after a call (invalid Python).
opDesc.includedColumns = List(column("col_one"), column("col_two"))
val code = opDesc.generatePythonCode()
code should include(
s"self.decode_python_template('${b64("col_one")}'),self.decode_python_template('${b64("col_two")}')"
)
code should not include "')','"
}
}
Loading