language-extensions/python/test/src/PythonGetResultColumnTests.cpp
//----------------------------------------------------------------------------------------------
// Name: GetStreamIntegerResultColumnsTest
//
// Description:
//  Tests GetResultColumn with default script expecting an OutputDataSet of Integer columns.
//  When `r_rowsPerRead` parameter is set (streaming), both nullable and non-nullable
//  columns must return as nullable (since in streaming, it is not predictable
//  whether the upcoming chunks of data will contain nulls).
//

GetStreamIntegerResultColumnsTest
Description:
Tests GetResultColumn with default script expecting an OutputDataSet of Integer columns.
When `r_rowsPerRead` parameter is set (streaming), both nullable and non-nullable
columns must return as nullable (since in streaming, it is not predictable
whether the upcoming chunks of data will contain nulls).
GetStreamIntegerResultColumnsTest Description : Tests GetResultColumn with default script expecting an OutputDataSet of Integer columns . When ` r_rowsPerRead ` parameter is set ( streaming ) both nullable and non - nullable columns must return as nullable ( since in streaming it is not predictable whether the upcoming chunks of data will contain nulls ) .
TEST_F(PythonExtensionApiTests, GetStreamIntegerResultColumnsTest)
	{
		InitializeSession(1, 
			(*m_integerInfo).GetColumnsNumber(), 
			m_scriptString);
		SQLCHAR *paramName = static_cast<SQLCHAR *>(
			static_cast<void *>(const_cast<char *>(m_streamingParamName.c_str())));
		SQLINTEGER paramValue = 1;
		SQLRETURN result = SQL_ERROR;
		result = InitParam(
			*m_sessionId,
			m_taskId,
			0,
			paramName,                     
			m_streamingParamName.length(), 
			SQL_C_SLONG,                   
			sizeof(SQLINTEGER),            
			0,                             
			&paramValue,                   
			0,                             
			SQL_PARAM_INPUT);              
		EXPECT_EQ(result, SQL_SUCCESS);
		InitializeColumns<SQLINTEGER, SQL_C_SLONG>(m_integerInfo.get());
		TestExecute<SQLINTEGER, SQL_C_SLONG>(
			ColumnInfo<SQLINTEGER>::sm_rowsNumber,
			(*m_bigIntInfo).m_dataSet.data(),
			(*m_bigIntInfo).m_strLen_or_Ind.data(),
			(*m_bigIntInfo).m_columnNames,
			false); 
		TestGetResultColumn(0, 
			SQL_C_DOUBLE,      
			m_DoubleSize,      
			0,                 
			SQL_NULLABLE);     
		TestGetResultColumn(1, 
			SQL_C_DOUBLE,      
			m_DoubleSize,      
			0,                 
			SQL_NULLABLE);     
	}
TEST_F ( PythonExtensionApiTests , GetStreamIntegerResultColumnsTest ) { InitializeSession ( 1 , ( * m_integerInfo ) . GetColumnsNumber ( ) , m_scriptString ) ; SQLCHAR * paramName = static_cast < SQLCHAR * > ( static_cast < void * > ( const_cast < char * > ( m_streamingParamName . c_str ( ) ) ) ) ; SQLINTEGER paramValue = 1 ; SQLRETURN result = SQL_ERROR ; result = InitParam ( * m_sessionId , m_taskId , 0 , paramName , m_streamingParamName . length ( ) , SQL_C_SLONG , sizeof ( SQLINTEGER ) , 0 , & paramValue , 0 , SQL_PARAM_INPUT ) ; EXPECT_EQ ( result , SQL_SUCCESS ) ; InitializeColumns < SQLINTEGER , SQL_C_SLONG > ( m_integerInfo . get ( ) ) ; TestExecute < SQLINTEGER , SQL_C_SLONG > ( ColumnInfo < SQLINTEGER > :: sm_rowsNumber , ( * m_bigIntInfo ) . m_dataSet . data ( ) , ( * m_bigIntInfo ) . m_strLen_or_Ind . data ( ) , ( * m_bigIntInfo ) . m_columnNames , false ) ; TestGetResultColumn ( 0 , SQL_C_DOUBLE , m_DoubleSize , 0 , SQL_NULLABLE ) ; TestGetResultColumn ( 1 , SQL_C_DOUBLE , m_DoubleSize , 0 , SQL_NULLABLE ) ; }
Name: GetStreamIntegerResultColumnsTest
Description:
Tests GetResultColumn with default script expecting an OutputDataSet of Integer columns.
Name : GetStreamIntegerResultColumnsTest Description : Tests GetResultColumn with default script expecting an OutputDataSet of Integer columns .
// Initialize with a default Session that prints Hello PythonExtension
 // and assigns InputDataSet to OutputDataSet
 //
 // parametersNumber
 // Initialize @r_rowsPerRead input param which sets session as streaming mode
 //
 // chunk size, # of rows per chunk
 //
 // paramName
 // paramSize
 // dataType
 // size of dataType
 // decimalDigits
 // chunkSize (@r_rowsPerRead)
 // strLenOrInd
 // input output type
 // validate
 // When streaming, we return a broader type because we don't know if later 
 // values will have bigger values than those in the first chunk.
 //
 // columnNumber
 // dataType
 // columnSize
 // decimalDigits
 // nullable
 // columnNumber
 // dataType
 // columnSize
 // decimalDigits
 // nullable
