language-extensions/R/test/src/RExtensionGetResultColumnTests.cpp
//----------------------------------------------------------------------------------------------
// Name: GetRawResultColumnTest
//
// Description:
//  Tests GetResultColumn with a script that returns OutputDataSet with a single raw column.
//
GetRawResultColumnTest
Description:
Tests GetResultColumn with a script that returns OutputDataSet with a single raw column.
GetRawResultColumnTest Description : Tests GetResultColumn with a script that returns OutputDataSet with a single raw column .
TEST_F(RExtensionApiTests, GetRawResultColumnTest)
	{
		string scriptString = "rawChars <- charToRaw(paste(letters[1:26], collapse=''));"
			"OutputDataSet <- data.frame(rawChars);"
			"message(OutputDataSet)";
		InitializeSession(
			0,              inputSchemaColumnsNumber
			scriptString);
		SQLUSMALLINT outputSchemaColumnsNumber = 0;
		SQLRETURN result = (*sm_executeFuncPtr)(
			*m_sessionId,
			m_taskId,
			0,
			nullptr,
			nullptr,
			&outputSchemaColumnsNumber);
		ASSERT_EQ(result, SQL_SUCCESS);
		EXPECT_EQ(outputSchemaColumnsNumber, 1);
		GetResultColumn(0,  columnNumber
			SQL_C_BINARY,   dataType
			26,             columnSize
			0,              decimalDigits
			SQL_NO_NULLS);  nullable
		CleanupSession();
		scriptString = "rawChars <- raw(0);"
			"OutputDataSet <- data.frame(rawChars);"
			"message(OutputDataSet)";
		 that assigns creates an OutputDataSet with a null raw column.
		InitializeSession(
			0,              inputSchemaColumnsNumber
			scriptString);
		outputSchemaColumnsNumber = 0;
		result = (*sm_executeFuncPtr)(
			*m_sessionId,
			m_taskId,
			0,
			nullptr,
			nullptr,
			&outputSchemaColumnsNumber);
		ASSERT_EQ(result, SQL_SUCCESS);
		EXPECT_EQ(outputSchemaColumnsNumber, 1);
		GetResultColumn(0,  columnNumber
			SQL_C_BINARY,   dataType
			1,              columnSize
			0,              decimalDigits
			SQL_NULLABLE);  nullable
	}
TEST_F ( RExtensionApiTests , GetRawResultColumnTest ) { string scriptString = " " " " " " ; InitializeSession ( 0 , scriptString ) ; SQLUSMALLINT outputSchemaColumnsNumber = 0 ; SQLRETURN result = ( * sm_executeFuncPtr ) ( * m_sessionId , m_taskId , 0 , nullptr , nullptr , & outputSchemaColumnsNumber ) ; ASSERT_EQ ( result , SQL_SUCCESS ) ; EXPECT_EQ ( outputSchemaColumnsNumber , 1 ) ; GetResultColumn ( 0 , SQL_C_BINARY , 26 , 0 , SQL_NO_NULLS ) ; CleanupSession ( ) ; scriptString = " " " " " " ; InitializeSession ( 0 , scriptString ) ; outputSchemaColumnsNumber = 0 ; result = ( * sm_executeFuncPtr ) ( * m_sessionId , m_taskId , 0 , nullptr , nullptr , & outputSchemaColumnsNumber ) ; ASSERT_EQ ( result , SQL_SUCCESS ) ; EXPECT_EQ ( outputSchemaColumnsNumber , 1 ) ; GetResultColumn ( 0 , SQL_C_BINARY , 1 , 0 , SQL_NULLABLE ) ; }
Name: GetRawResultColumnTest
Description:
Tests GetResultColumn with a script that returns OutputDataSet with a single raw column.
Name : GetRawResultColumnTest Description : Tests GetResultColumn with a script that returns OutputDataSet with a single raw column .
// Initialize with a Session that executes the above script // that assigns creates an OutputDataSet with a single raw column. // // inputSchemaColumnsNumber // columnNumber // dataType // columnSize // decimalDigits // nullable // Initialize with a Session that executes the above script // that assigns creates an OutputDataSet with a null raw column. // // inputSchemaColumnsNumber // columnNumber // dataType // columnSize // decimalDigits // nullable