//---------------------------------------------------------------------------
//	@function:
//		CParseHandlerStatsDerivedRelation::EndElement
//
//	@doc:
//		Invoked by Xerces to process a closing tag
//
//---------------------------------------------------------------------------
void
CParseHandlerStatsDerivedRelation::EndElement
	(
	const XMLCh* const, // element_uri,
	const XMLCh* const element_local_name,
	const XMLCh* const // element_qname
	)
{
	if (0 != XMLString::compareString(CDXLTokens::XmlstrToken(EdxltokenStatsDerivedRelation), element_local_name))
	{
		CWStringDynamic *str = CDXLUtils::CreateDynamicStringFromXMLChArray(m_parse_handler_mgr->GetDXLMemoryManager(), element_local_name);
		GPOS_RAISE(gpdxl::ExmaDXL, gpdxl::ExmiDXLUnexpectedTag, str->GetBuffer());
	}

	// must have at least one column stats
	GPOS_ASSERT(0 < this->Length());

	// array of derived column statistics
	CDXLStatsDerivedColumnArray *dxl_stats_derived_col_array = GPOS_NEW(m_mp) CDXLStatsDerivedColumnArray(m_mp);
	const ULONG num_of_drvd_col_stats = this->Length();
	for (ULONG idx = 0; idx < num_of_drvd_col_stats; idx++)
	{
		CParseHandlerStatsDerivedColumn *stats_derived_col_parse_handler = dynamic_cast<CParseHandlerStatsDerivedColumn*>( (*this)[idx]);

		CDXLStatsDerivedColumn *pdxlstatdercol = stats_derived_col_parse_handler->GetDxlStatsDerivedCol();
		pdxlstatdercol->AddRef();
		dxl_stats_derived_col_array->Append(pdxlstatdercol);
	}

	m_dxl_stats_derived_relation = GPOS_NEW(m_mp) CDXLStatsDerivedRelation(m_rows, m_empty, dxl_stats_derived_col_array);

	// deactivate handler
	m_parse_handler_mgr->DeactivateHandler();
}
//---------------------------------------------------------------------------
//	@function:
//		CParseHandlerStatsDerivedRelation::EndElement
//
//	@doc:
//		Invoked by Xerces to process a closing tag
//
//---------------------------------------------------------------------------
void
CParseHandlerStatsDerivedRelation::EndElement
	(
	const XMLCh* const, // xmlszUri,
	const XMLCh* const xmlszLocalname,
	const XMLCh* const // xmlszQname
	)
{
	if (0 != XMLString::compareString(CDXLTokens::XmlstrToken(EdxltokenStatsDerivedRelation), xmlszLocalname))
	{
		CWStringDynamic *pstr = CDXLUtils::PstrFromXMLCh(m_pphm->Pmm(), xmlszLocalname);
		GPOS_RAISE(gpdxl::ExmaDXL, gpdxl::ExmiDXLUnexpectedTag, pstr->Wsz());
	}

	// must have at least one column stats
	GPOS_ASSERT(0 < this->UlLength());

	// array of derived column statistics
	DrgPdxlstatsdercol *pdrgpdxlstatsdercol = GPOS_NEW(m_pmp) DrgPdxlstatsdercol(m_pmp);
	const ULONG ulDerCol = this->UlLength();
	for (ULONG ul = 0; ul < ulDerCol; ul++)
	{
		CParseHandlerStatsDerivedColumn *pph = dynamic_cast<CParseHandlerStatsDerivedColumn*>( (*this)[ul]);

		CDXLStatsDerivedColumn *pdxlstatdercol = pph->Pstatsdercol();
		pdxlstatdercol->AddRef();
		pdrgpdxlstatsdercol->Append(pdxlstatdercol);
	}

	m_pdxlstatsderrel = GPOS_NEW(m_pmp) CDXLStatsDerivedRelation(m_dRows, m_fEmpty, pdrgpdxlstatsdercol);

	// deactivate handler
	m_pphm->DeactivateHandler();
}