language-extensions/python/test/src/PythonGetResultColumnTests.cpp
// Name: GetRawResultColumnTest
//
// Description:
//  Test GetResultColumn with a script that returns OutputDataSet with raw columns.
//

GetRawResultColumnTest
Description:
Test GetResultColumn with a script that returns OutputDataSet with raw columns.
GetRawResultColumnTest Description : Test GetResultColumn with a script that returns OutputDataSet with raw columns .
TEST_F(PythonExtensionApiTests, GetRawResultColumnsTest)
	{
		SQLUSMALLINT inputSchemaColumnsNumber = 3;
		InitializeSession(0, 
			inputSchemaColumnsNumber,
			m_scriptString);
		const SQLCHAR BinaryValue1[] = { 0x01, 0x01, 0xe2, 0x40 };
		const SQLCHAR BinaryValue2[] = { 0x04, 0x05, 0xe1 };
		const SQLCHAR BinaryValue3[] = { 0x00, 0x00, 0x00, 0x01 };
		const SQLCHAR BinaryValue4[] = { 0xff };
		const SQLCHAR BinaryValue5[] = { 0x00 };
		const SQLCHAR BinaryValue6[] = { 0xff, 0xff, 0xff, 0xff };
		const SQLCHAR BinaryValue7[] = { 0x00, 0x12, 0xd2, 0xff, 0x00, 0x12, 0xd2, 0xff, 0x00, 0x12, 0xd2, 0xff };
		string binaryColumn1Name = "BinaryColumn1";
		InitializeColumn(0, binaryColumn1Name, SQL_C_BINARY, m_BinarySize);
		string binaryColumn2Name = "BinaryColumn2";
		InitializeColumn(1, binaryColumn2Name, SQL_C_BINARY, m_BinarySize);
		string binaryColumn3Name = "BinaryColumn3";
		InitializeColumn(2, binaryColumn3Name, SQL_C_BINARY, m_BinarySize);
		vector<const SQLCHAR*> binaryCol1{ BinaryValue1, BinaryValue2, BinaryValue3, BinaryValue4 };
		vector<const SQLCHAR*> binaryCol2{ BinaryValue5, BinaryValue6, nullptr, BinaryValue7 };
		SQLINTEGER strLenOrIndCol1[] =
		{
			static_cast<SQLINTEGER>(sizeof(BinaryValue1) / m_BinarySize),
			static_cast<SQLINTEGER>(sizeof(BinaryValue2) / m_BinarySize),
			static_cast<SQLINTEGER>(sizeof(BinaryValue3) / m_BinarySize),
			static_cast<SQLINTEGER>(sizeof(BinaryValue4) / m_BinarySize)
		};
		SQLINTEGER strLenOrIndCol2[] =
		{
			SQL_NULL_DATA,
			static_cast<SQLINTEGER>(sizeof(BinaryValue6) / m_BinarySize),
			SQL_NULL_DATA,
			static_cast<SQLINTEGER>(sizeof(BinaryValue7) / m_BinarySize)
		};
		vector<SQLINTEGER*> strLen_or_Ind{ strLenOrIndCol1, strLenOrIndCol2, nullptr };
		int rowsNumber = binaryCol1.size();
		vector<SQLCHAR> binaryCol1Data = GenerateContiguousData<SQLCHAR>(binaryCol1, strLenOrIndCol1);
		vector<SQLCHAR> binaryCol2Data = GenerateContiguousData<SQLCHAR>(binaryCol2, strLenOrIndCol2);
		void* dataSet[] = { binaryCol1Data.data(),
							binaryCol2Data.data(),
							nullptr };
		vector<string> columnNames{ binaryColumn1Name, binaryColumn2Name, binaryColumn3Name };
		SQLULEN maxCol1Len = GetMaxLength(strLenOrIndCol1, rowsNumber);
		SQLULEN maxCol2Len = GetMaxLength(strLenOrIndCol2, rowsNumber);
		TestExecute<SQLCHAR, SQL_C_BINARY>(
			rowsNumber,
			dataSet,
			strLen_or_Ind.data(),
			columnNames,
			false);
		TestGetResultColumn(0, 
			SQL_C_CHAR,        
			maxCol1Len,        
			0,                 
			SQL_NO_NULLS);     
		TestGetResultColumn(1, 
			SQL_C_CHAR,        
			maxCol2Len,        
			0,                 
			SQL_NULLABLE);     
		TestGetResultColumn(2, 
			SQL_C_CHAR,        
			sizeof(SQLCHAR),   
			0,                 
			SQL_NULLABLE);     
	}
TEST_F ( PythonExtensionApiTests , GetRawResultColumnsTest ) { SQLUSMALLINT inputSchemaColumnsNumber = 3 ; InitializeSession ( 0 , inputSchemaColumnsNumber , m_scriptString ) ; const SQLCHAR BinaryValue1 [ ] = { 0x01 , 0x01 , 0xe2 , 0x40 } ; const SQLCHAR BinaryValue2 [ ] = { 0x04 , 0x05 , 0xe1 } ; const SQLCHAR BinaryValue3 [ ] = { 0x00 , 0x00 , 0x00 , 0x01 } ; const SQLCHAR BinaryValue4 [ ] = { 0xff } ; const SQLCHAR BinaryValue5 [ ] = { 0x00 } ; const SQLCHAR BinaryValue6 [ ] = { 0xff , 0xff , 0xff , 0xff } ; const SQLCHAR BinaryValue7 [ ] = { 0x00 , 0x12 , 0xd2 , 0xff , 0x00 , 0x12 , 0xd2 , 0xff , 0x00 , 0x12 , 0xd2 , 0xff } ; string binaryColumn1Name = " " ; InitializeColumn ( 0 , binaryColumn1Name , SQL_C_BINARY , m_BinarySize ) ; string binaryColumn2Name = " " ; InitializeColumn ( 1 , binaryColumn2Name , SQL_C_BINARY , m_BinarySize ) ; string binaryColumn3Name = " " ; InitializeColumn ( 2 , binaryColumn3Name , SQL_C_BINARY , m_BinarySize ) ; vector < const SQLCHAR * > binaryCol1 { BinaryValue1 , BinaryValue2 , BinaryValue3 , BinaryValue4 } ; vector < const SQLCHAR * > binaryCol2 { BinaryValue5 , BinaryValue6 , nullptr , BinaryValue7 } ; SQLINTEGER strLenOrIndCol1 [ ] = { static_cast < SQLINTEGER > ( sizeof ( BinaryValue1 ) / m_BinarySize ) , static_cast < SQLINTEGER > ( sizeof ( BinaryValue2 ) / m_BinarySize ) , static_cast < SQLINTEGER > ( sizeof ( BinaryValue3 ) / m_BinarySize ) , static_cast < SQLINTEGER > ( sizeof ( BinaryValue4 ) / m_BinarySize ) } ; SQLINTEGER strLenOrIndCol2 [ ] = { SQL_NULL_DATA , static_cast < SQLINTEGER > ( sizeof ( BinaryValue6 ) / m_BinarySize ) , SQL_NULL_DATA , static_cast < SQLINTEGER > ( sizeof ( BinaryValue7 ) / m_BinarySize ) } ; vector < SQLINTEGER * > strLen_or_Ind { strLenOrIndCol1 , strLenOrIndCol2 , nullptr } ; int rowsNumber = binaryCol1 . size ( ) ; vector < SQLCHAR > binaryCol1Data = GenerateContiguousData < SQLCHAR > ( binaryCol1 , strLenOrIndCol1 ) ; vector < SQLCHAR > binaryCol2Data = GenerateContiguousData < SQLCHAR > ( binaryCol2 , strLenOrIndCol2 ) ; void * dataSet [ ] = { binaryCol1Data . data ( ) , binaryCol2Data . data ( ) , nullptr } ; vector < string > columnNames { binaryColumn1Name , binaryColumn2Name , binaryColumn3Name } ; SQLULEN maxCol1Len = GetMaxLength ( strLenOrIndCol1 , rowsNumber ) ; SQLULEN maxCol2Len = GetMaxLength ( strLenOrIndCol2 , rowsNumber ) ; TestExecute < SQLCHAR , SQL_C_BINARY > ( rowsNumber , dataSet , strLen_or_Ind . data ( ) , columnNames , false ) ; TestGetResultColumn ( 0 , SQL_C_CHAR , maxCol1Len , 0 , SQL_NO_NULLS ) ; TestGetResultColumn ( 1 , SQL_C_CHAR , maxCol2Len , 0 , SQL_NULLABLE ) ; TestGetResultColumn ( 2 , SQL_C_CHAR , sizeof ( SQLCHAR ) , 0 , SQL_NULLABLE ) ; }
Name: GetRawResultColumnTest
Description:
Test GetResultColumn with a script that returns OutputDataSet with raw columns.
Name : GetRawResultColumnTest Description : Test GetResultColumn with a script that returns OutputDataSet with raw columns .
// Initialize with a default Session that prints Hello PythonExtension
 // and assigns InputDataSet to OutputDataSet
 //
 // parametersNumber
 // Coalesce the arrays of each row of each column
 // into a contiguous array for each column.
 //
 // columnNumber
 // dataType
 // columnSize
 // decimalDigits
 // nullable
 // columnNumber
 // dataType
 // columnSize
 // decimalDigits
 // nullable
 // columnNumber
 // dataType
 // columnSize
 // decimalDigits
 // nullable
