def evaluate_OperatorCall(opcall: irast.OperatorCall, schema: s_schema.Schema) -> irast.BaseConstant: if irutils.is_union_expr(opcall): return _evaluate_union(opcall, schema) eval_func = op_table.get((opcall.operator_kind, opcall.func_shortname)) if eval_func is None: raise UnsupportedExpressionError( f'unsupported operator: {opcall.func_shortname}', context=opcall.context) args = [] for arg in opcall.args: arg_val = evaluate_to_python_val(arg.expr, schema=schema) if isinstance(arg_val, tuple): raise UnsupportedExpressionError( f'non-singleton operations are not supported', context=opcall.context) args.append(arg_val) value = eval_func(*args) qlconst = qlast.BaseConstant.from_python(value) result = ql_compiler.compile_constant_tree_to_ir(qlconst, styperef=opcall.typeref, schema=schema) return result
def evaluate_OperatorCall(opcall: irast.OperatorCall, schema: s_schema.Schema) -> irast.ConstExpr: if irutils.is_union_expr(opcall): return _evaluate_union(opcall, schema) eval_func = op_table.get((opcall.operator_kind, opcall.func_shortname)) if eval_func is None: raise UnsupportedExpressionError( f'unsupported operator: {opcall.func_shortname}', context=opcall.context) args = [] for arg in opcall.args: arg_val = evaluate_to_python_val(arg.expr, schema=schema) if isinstance(arg_val, tuple): raise UnsupportedExpressionError( f'non-singleton operations are not supported', context=opcall.context) args.append(arg_val) value = eval_func(*args) # Since we only perform string concatenations here, the constant # in question is always a StringConstant. qlconst = qlast.StringConstant.from_python(value) result = qlcompiler.compile_constant_tree_to_ir(qlconst, styperef=opcall.typeref, schema=schema) assert isinstance(result, irast.ConstExpr), 'expected ConstExpr' return result