language-extensions/R/test/src/RExtensionGetResultColumnTests.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
//  if 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
if 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 if the upcoming chunks of data will contain nulls ) .
TEST_F(RExtensionApiTests, GetStreamIntegerResultColumnsTest)
	{
		InitializeSession(
			(*m_integerInfo).GetColumnsNumber(),  inputSchemaColumnsNumber
			m_scriptString,
			1                                     parametersNumber
			);
		 Initialize r_rowsPerRead parameter to set streaming mode
		SQLCHAR *paramName = static_cast<SQLCHAR*>(
			static_cast<void*>(const_cast<char *>(m_streamingParamName.c_str())));
		 chunkSize (number of rows to send in each chunk)
		SQLINTEGER paramValue = 1;
		SQLRETURN result = SQL_ERROR;
		result = (*sm_initParamFuncPtr)(
			*m_sessionId,
			m_taskId,
			0,
			paramName,                      paramName
			m_streamingParamName.length(),  paramSize
			SQL_C_SLONG,                    dataType
			sizeof(SQLINTEGER),             size of dataType
			0,                              decimalDigits
			&paramValue,                    chunkSize (@r_rowsPerRead)
			0,                              strLenOrInd
			SQL_PARAM_INPUT);               input output type
		EXPECT_EQ(result, SQL_SUCCESS);
		InitializeColumns<SQLINTEGER, SQL_C_SLONG>(m_integerInfo.get());
		Execute<SQLINTEGER, Rcpp::IntegerVector, SQL_C_SLONG>(
			ColumnInfo<SQLINTEGER>::sm_rowsNumber,
			(*m_integerInfo).m_dataSet.data(),
			(*m_integerInfo).m_strLen_or_Ind.data(),
			(*m_integerInfo).m_columnNames,
			false);   validate
		GetResultColumn(0,  columnNumber
			SQL_C_SLONG,    dataType
			m_IntSize,	    columnSize
			0,              decimalDigits
			SQL_NULLABLE);  must be verified as nullable
		GetResultColumn(1,  columnNumber
			SQL_C_SLONG,    dataType
			m_IntSize,	    columnSize
			0,              decimalDigits
			SQL_NULLABLE);  nullable
	}
TEST_F ( RExtensionApiTests , GetStreamIntegerResultColumnsTest ) { InitializeSession ( ( * m_integerInfo ) . GetColumnsNumber ( ) , m_scriptString , 1 ) ; SQLCHAR * paramName = static_cast < SQLCHAR * > ( static_cast < void * > ( const_cast < char * > ( m_streamingParamName . c_str ( ) ) ) ) ; SQLINTEGER paramValue = 1 ; SQLRETURN result = SQL_ERROR ; result = ( * sm_initParamFuncPtr ) ( * 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 ( ) ) ; Execute < SQLINTEGER , Rcpp :: IntegerVector , SQL_C_SLONG > ( ColumnInfo < SQLINTEGER > :: sm_rowsNumber , ( * m_integerInfo ) . m_dataSet . data ( ) , ( * m_integerInfo ) . m_strLen_or_Ind . data ( ) , ( * m_integerInfo ) . m_columnNames , false ) ; GetResultColumn ( 0 , SQL_C_SLONG , m_IntSize , 0 , SQL_NULLABLE ) ; GetResultColumn ( 1 , SQL_C_SLONG , m_IntSize , 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 RExtension // and assigns InputDataSet to OutputDataSet // // inputSchemaColumnsNumber // parametersNumber // Initialize r_rowsPerRead parameter to set streaming mode // // chunkSize (number of rows to send in each chunk) // // paramName // paramSize // dataType // size of dataType // decimalDigits // chunkSize (@r_rowsPerRead) // strLenOrInd // input output type // validate // columnNumber // dataType // columnSize // decimalDigits // must be verified as nullable // columnNumber // dataType // columnSize // decimalDigits // nullable