Skip to main content
Question

Potential Bug in Python SDK 25.4.1: addLongVarchar() Inconsistent Signatures

  • February 26, 2026
  • 0 replies
  • 3 views

steven_chang_tradevan_com_tw_

Vertica Version: 25.4.1 Category: SDK / Python UDx Function Type: ScalarFunction

Description

There is a critical inconsistency in the addLongVarchar() method signature within the Python SDK for ScalarFunctionFactory. The method behaves differently depending on whether it is called inside getPrototype() or getReturnType(), leading to TypeError in both scenarios if one tries to standardize the code.

Steps to Reproduce

In a standard ScalarFunctionFactory implementation:

  1. Scenario A: Passing a length argument

def getPrototype(self, server_interface, arg_types, return_type):
    arg_types.addVarchar()
    return_type.addLongVarchar(32000) # Throws TypeError
  • Result: TypeError: addLongVarchar() takes exactly 0 positional arguments (1 given)

  1. Scenario B: Passing no arguments

def getReturnType(self, server_interface, arg_types, return_type):
    return_type.addLongVarchar() # Throws TypeError
  • Result: TypeError: addLongVarchar() takes at least 1 positional argument (0 given)

Observed Behavior

  • In getPrototype, the ColumnTypes object treats addLongVarchar as a method that must not have arguments.

  • In getReturnType, the SizedColumnTypes object (or the underlying vertica_sdk.pyx implementation) treats addLongVarchar as a method that must have at least one argument (the length).

This makes it impossible to use LongVarchar reliably as a return type for Scalar Functions in Python without hitting an RPC error during function registration or execution.

Error Logs

From getPrototype:

(Python error type [<class 'TypeError'>])
Traceback (most recent call last):
  File ".../E5InternalLib.py", line 117, in getPrototype
    return_type.addLongVarchar(32000)
TypeError: addLongVarchar() takes exactly 0 positional arguments (1 given)

From getReturnType:

(Python error type [<class 'TypeError'>])
Traceback (most recent call last):
  File ".../E5InternalLib.py", line 118, in getReturnType
    return_type.addLongVarchar()
TypeError: addLongVarchar() takes at least 1 positional argument (0 given)

Workaround

The primary workaround for this issue is to avoid using ScalarFunction altogether when LongVarchar or complex array returns are required. Instead, developers should implement the logic using a TransformFunction, which provides a more consistent API (via getReturnType) and stable support for addArrayType and addLongVarchar. Alternatively, using addVarchar(N) with a large N in ScalarFunction may bypass the specific signature error but lacks the flexibility of LongVarchar.

Expected Behavior

The addLongVarchar() method should have a consistent signature across all SDK Metadata classes. Ideally, it should optionally accept a length or default to the maximum allowed size for LongVarchar.