@@ -27,6 +27,7 @@ static PyObject* ipaddressV6Class;
2727
2828static PyObject * trinoErrorResultFunction ;
2929static PyObject * decimalToStringFunction ;
30+ static PyObject * numberToStringFunction ;
3031static PyObject * guestFunction ;
3132
3233static const u8 * trinoArgType ;
@@ -137,6 +138,7 @@ static void skipType(const u8** const type)
137138 case DOUBLE :
138139 case REAL :
139140 case DECIMAL :
141+ case NUMBER :
140142 case VARCHAR :
141143 case VARBINARY :
142144 case DATE :
@@ -241,7 +243,8 @@ static PyObject* doBuildArgs(const u8** const type, const u8** const data)
241243 * data += sizeof (f32 );
242244 return checked (PyFloat_FromDouble (value ));
243245 }
244- case DECIMAL : {
246+ case DECIMAL :
247+ case NUMBER : {
245248 PyObject * number = readString (data );
246249 PyObject * value = checked (PyObject_CallOneArg (decimalClass , number ));
247250 Py_DECREF (number );
@@ -657,6 +660,20 @@ static bool buildResult(const u8** const type, PyObject* input, Buffer* buffer)
657660 Py_DECREF (string );
658661 return true;
659662 }
663+ case NUMBER : {
664+ PyObject * string = PyObject_CallOneArg (numberToStringFunction , input );
665+ if (string == NULL ) {
666+ resultError (input , "NUMBER" );
667+ return false;
668+ }
669+ if (!bufferAppendString (buffer , string )) {
670+ Py_DECREF (string );
671+ resultError (input , "NUMBER" );
672+ return false;
673+ }
674+ Py_DECREF (string );
675+ return true;
676+ }
660677 case VARCHAR :
661678 case JSON : {
662679 const char * typeName = trinoType == VARCHAR ? "VARCHAR" : "JSON" ;
@@ -1011,6 +1028,7 @@ int main(const int argc, char* argv[])
10111028 PyObject * trinoModule = loadModule ("trino" );
10121029 trinoErrorResultFunction = findFunction (trinoModule , "_trino_error_result" );
10131030 decimalToStringFunction = findFunction (trinoModule , "_decimal_to_string" );
1031+ numberToStringFunction = findFunction (trinoModule , "_number_to_string" );
10141032
10151033 DEBUG ("Python host initialized" );
10161034 return 0 ;
0 commit comments