language-extensions/R/test/src/RExtensionGetResultColumnTests.cpp
//----------------------------------------------------------------------------------------------
// Name: GetNAOrEmptyCharResultColumnsTest
//
// Description:
//  Test GetResultColumn with a script that returns a dataset with
//  a default column of all NAs, a character column of all NAs,
//  and a character column of all empty strings.
//  In the result columns, we expect default NA column to be of type SQL_C_BIT and
//  the character columns to be of type SQL_C_CHAR with the minimum columnSize of 1.
//
GetNAOrEmptyCharResultColumnsTest
Description:
Test GetResultColumn with a script that returns a dataset with
a default column of all NAs, a character column of all NAs,
and a character column of all empty strings.
In the result columns, we expect default NA column to be of type SQL_C_BIT and
the character columns to be of type SQL_C_CHAR with the minimum columnSize of 1.
GetNAOrEmptyCharResultColumnsTest Description : Test GetResultColumn with a script that returns a dataset with a default column of all NAs a character column of all NAs and a character column of all empty strings . In the result columns we expect default NA column to be of type SQL_C_BIT and the character columns to be of type SQL_C_CHAR with the minimum columnSize of 1 .
TEST_F(RExtensionApiTests, GetNAOrEmptyCharResultColumnsTest)
	{
		string scriptString =
			"OutputDataSet <- data.frame(logicalNA = c(NA,NA),"
				" charNA = as.character(c(NA,NA)), emptyChar = as.character(c('', '')));"
			"print(OutputDataSet);";
		 Initialize with a Session that executes the above script
		 that creates an OutputDataSet with 2 columns of all NAs.
		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, 3);
		GetResultColumn(0,  columnNumber
			SQL_C_BIT,      dataType
			m_LogicalSize,  columnSize
			0,              decimalDigits
			SQL_NULLABLE);  nullable
		GetResultColumn(1,  columnNumber
			SQL_C_CHAR,     dataType
			m_CharSize,     columnSize
			0,              decimalDigits
			SQL_NULLABLE);  nullable
		GetResultColumn(2,  columnNumber
			SQL_C_CHAR,     dataType
			m_CharSize,     columnSize
			0,              decimalDigits
			SQL_NO_NULLS);  nullable
	}
TEST_F ( RExtensionApiTests , GetNAOrEmptyCharResultColumnsTest ) { 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 , 3 ) ; GetResultColumn ( 0 , SQL_C_BIT , m_LogicalSize , 0 , SQL_NULLABLE ) ; GetResultColumn ( 1 , SQL_C_CHAR , m_CharSize , 0 , SQL_NULLABLE ) ; GetResultColumn ( 2 , SQL_C_CHAR , m_CharSize , 0 , SQL_NO_NULLS ) ; }
Name: GetNAOrEmptyCharResultColumnsTest
Description:
Test GetResultColumn with a script that returns a dataset with
a default column of all NAs, a character column of all NAs,
and a character column of all empty strings.
Name : GetNAOrEmptyCharResultColumnsTest Description : Test GetResultColumn with a script that returns a dataset with a default column of all NAs a character column of all NAs and a character column of all empty strings .
// With this script, we create a DataFrame with 3 columns // 1. a default column of all NAs. // 2. a character column of all NAs. // 3. a character column of all empty strings. // // Initialize with a Session that executes the above script // that creates an OutputDataSet with 2 columns of all NAs. // // inputSchemaColumnsNumber // columnNumber // dataType // columnSize // decimalDigits // nullable // columnNumber // dataType // columnSize // decimalDigits // nullable // columnNumber // dataType // columnSize // decimalDigits // nullable