language-extensions/python/test/src/PythonGetResultColumnTests.cpp
// Name: GetDifferentResultColumnsTest
//
// Description:
//  Test GetResultColumn with default script using an OutputDataSet of different column types.
//

GetDifferentResultColumnsTest
Description:
Test GetResultColumn with default script using an OutputDataSet of different column types.
GetDifferentResultColumnsTest Description : Test GetResultColumn with default script using an OutputDataSet of different column types .
TEST_F(PythonExtensionApiTests, GetDifferentResultColumnsTest)
	{
		SQLUSMALLINT inputSchemaColumnsNumber = 3;
		InitializeSession(0, 
			inputSchemaColumnsNumber,
			m_scriptString);
		string integerColumnName = "IntegerColumn";
		InitializeColumn(0, integerColumnName, SQL_C_SLONG, m_IntSize);
		string doubleColumnName = "DoubleColumn";
		InitializeColumn(1, doubleColumnName, SQL_C_DOUBLE, m_DoubleSize);
		string stringColumnName = "StringColumn";
		InitializeColumn(2, stringColumnName, SQL_C_CHAR, m_CharSize);
		vector<SQLINTEGER> intColData{ m_MaxInt, m_MinInt, 0, 1320, -1 };
		vector<SQLDOUBLE> doubleColData{ m_MinDouble, 1.33, 83.98, 72.45, m_MaxDouble };
		vector<const char*> stringCol{ "Hello", "test", "data", "World", "-123" };
		const SQLINTEGER intSize = m_IntSize;
		SQLINTEGER strLenOrIndCol1[] = { intSize, intSize, SQL_NULL_DATA, SQL_NULL_DATA, intSize };
		SQLINTEGER strLenOrIndCol3[] =
		{ static_cast<SQLINTEGER>(strlen(stringCol[0])),
		static_cast<SQLINTEGER>(strlen(stringCol[1])),
		static_cast<SQLINTEGER>(strlen(stringCol[2])),
		static_cast<SQLINTEGER>(strlen(stringCol[3])),
		static_cast<SQLINTEGER>(strlen(stringCol[4])) };
		vector<SQLINTEGER*> strLen_or_Ind{ strLenOrIndCol1, nullptr, strLenOrIndCol3 };
		int rowsNumber = intColData.size();
		vector<char> stringColData = GenerateContiguousData<char>(stringCol, strLenOrIndCol3);
		vector<void*> dataSet{ intColData.data(), doubleColData.data(), stringColData.data() };
		SQLUSMALLINT outputschemaColumnsNumber = 0;
		SQLRETURN result = Execute(
			*m_sessionId,
			m_taskId,
			rowsNumber,
			dataSet.data(),
			strLen_or_Ind.data(),
			&outputschemaColumnsNumber);
		ASSERT_EQ(result, SQL_SUCCESS);
		TestGetResultColumn(0,  
			SQL_C_DOUBLE,       
			m_DoubleSize,       
			0,                  
			SQL_NULLABLE);      
		TestGetResultColumn(1, 
			SQL_C_DOUBLE,      
			m_DoubleSize,      
			0,                 
			SQL_NO_NULLS);     
		SQLULEN maxLen = GetMaxLength(strLenOrIndCol3, rowsNumber);
		TestGetResultColumn(2, 
			SQL_C_CHAR,        
			maxLen,            
			0,                 
			SQL_NO_NULLS);     
	}
TEST_F ( PythonExtensionApiTests , GetDifferentResultColumnsTest ) { SQLUSMALLINT inputSchemaColumnsNumber = 3 ; InitializeSession ( 0 , inputSchemaColumnsNumber , m_scriptString ) ; string integerColumnName = " " ; InitializeColumn ( 0 , integerColumnName , SQL_C_SLONG , m_IntSize ) ; string doubleColumnName = " " ; InitializeColumn ( 1 , doubleColumnName , SQL_C_DOUBLE , m_DoubleSize ) ; string stringColumnName = " " ; InitializeColumn ( 2 , stringColumnName , SQL_C_CHAR , m_CharSize ) ; vector < SQLINTEGER > intColData { m_MaxInt , m_MinInt , 0 , 1320 , -1 } ; vector < SQLDOUBLE > doubleColData { m_MinDouble , 1.33 , 83.98 , 72.45 , m_MaxDouble } ; vector < const char * > stringCol { " " , " " , " " , " " , " " } ; const SQLINTEGER intSize = m_IntSize ; SQLINTEGER strLenOrIndCol1 [ ] = { intSize , intSize , SQL_NULL_DATA , SQL_NULL_DATA , intSize } ; SQLINTEGER strLenOrIndCol3 [ ] = { static_cast < SQLINTEGER > ( strlen ( stringCol [ 0 ] ) ) , static_cast < SQLINTEGER > ( strlen ( stringCol [ 1 ] ) ) , static_cast < SQLINTEGER > ( strlen ( stringCol [ 2 ] ) ) , static_cast < SQLINTEGER > ( strlen ( stringCol [ 3 ] ) ) , static_cast < SQLINTEGER > ( strlen ( stringCol [ 4 ] ) ) } ; vector < SQLINTEGER * > strLen_or_Ind { strLenOrIndCol1 , nullptr , strLenOrIndCol3 } ; int rowsNumber = intColData . size ( ) ; vector < char > stringColData = GenerateContiguousData < char > ( stringCol , strLenOrIndCol3 ) ; vector < void * > dataSet { intColData . data ( ) , doubleColData . data ( ) , stringColData . data ( ) } ; SQLUSMALLINT outputschemaColumnsNumber = 0 ; SQLRETURN result = Execute ( * m_sessionId , m_taskId , rowsNumber , dataSet . data ( ) , strLen_or_Ind . data ( ) , & outputschemaColumnsNumber ) ; ASSERT_EQ ( result , SQL_SUCCESS ) ; TestGetResultColumn ( 0 , SQL_C_DOUBLE , m_DoubleSize , 0 , SQL_NULLABLE ) ; TestGetResultColumn ( 1 , SQL_C_DOUBLE , m_DoubleSize , 0 , SQL_NO_NULLS ) ; SQLULEN maxLen = GetMaxLength ( strLenOrIndCol3 , rowsNumber ) ; TestGetResultColumn ( 2 , SQL_C_CHAR , maxLen , 0 , SQL_NO_NULLS ) ; }
Name: GetDifferentResultColumnsTest
Description:
Test GetResultColumn with default script using an OutputDataSet of different column types.
Name : GetDifferentResultColumnsTest Description : Test GetResultColumn with default script using an OutputDataSet of different column types .
// Initialize with a default Session that prints Hello PythonExtension
 // and assigns InputDataSet to OutputDataSet
 //
 // parametersNumber
 // Returns double type because NULLs get changed to NaN 
 // and column changes to float64
 //
 // columnNumber
 // dataType
 // columnSize
 // decimalDigits
 // nullable
 // columnNumber
 // dataType
 // columnSize
 // decimalDigits
 // nullable
 // columnNumber
 // dataType
 // columnSize
 // decimalDigits
 // nullable
