File tree Expand file tree Collapse file tree 2 files changed +12
-3
lines changed
core/compile/sqlglot/expressions Expand file tree Collapse file tree 2 files changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -83,7 +83,6 @@ def _(expr: TypedExpr) -> sge.Expression:
8383
8484@register_nary_op (ops .SqlScalarOp , pass_op = True )
8585def _ (* operands : TypedExpr , op : ops .SqlScalarOp ) -> sge .Expression :
86- # TODO: can we include a string in the sqlglot expression without parsing?
8786 return sg .parse_one (
8887 op .sql_template .format (
8988 * [operand .expr .sql (dialect = "bigquery" ) for operand in operands ]
Original file line number Diff line number Diff line change @@ -475,13 +475,23 @@ def _apply_binary_op(
475475) -> str :
476476 """Applies a binary op to the given DataFrame and return the SQL representing
477477 the resulting DataFrame."""
478+ return _apply_nary_op (obj , op , l_arg , r_arg )
479+
480+
481+ def _apply_nary_op (
482+ obj : bpd .DataFrame ,
483+ op : Union [ops .BinaryOp , ops .NaryOp ],
484+ * args : Union [str , ex .Expression ],
485+ ) -> str :
486+ """Applies a nary op to the given DataFrame and return the SQL representing
487+ the resulting DataFrame."""
478488 array_value = obj ._block .expr
479- op_expr = op .as_expr (l_arg , r_arg )
489+ op_expr = op .as_expr (* args )
480490 result , col_ids = array_value .compute_values ([op_expr ])
481491
482492 # Rename columns for deterministic golden SQL results.
483493 assert len (col_ids ) == 1
484- result = result .rename_columns ({col_ids [0 ]: l_arg }).select_columns ([l_arg ])
494+ result = result .rename_columns ({col_ids [0 ]: args [ 0 ] }).select_columns ([args [ 0 ] ])
485495
486496 sql = result .session ._executor .to_sql (result , enable_cache = False )
487497 return sql
You can’t perform that action at this time.
0 commit comments