コード例 #1
0
ファイル: simplecolumn.cpp プロジェクト: coderplay/infinidb
void SimpleColumn::setOID()
{
	boost::shared_ptr<CalpontSystemCatalog> csc = CalpontSystemCatalog::makeCalpontSystemCatalog(fSessionID);
	CalpontSystemCatalog::TableColName tcn;
	tcn = make_tcn(fSchemaName, fTableName, fColumnName);

	fOid = csc->lookupOID (tcn);
	if (fOid == -1)
	{
		// get colMap from CalpontSelectExecutionPlan
		// and try to map the schema and table name
		CalpontSelectExecutionPlan::ColumnMap::iterator iter;
		CalpontSelectExecutionPlan::ColumnMap colMap = CalpontSelectExecutionPlan::colMap();

		// if this is the only column name exist in the map, return it ??
		for (iter = colMap.find(fColumnName); iter != colMap.end(); ++iter)
		{
			SRCP srcp = iter->second;
			SimpleColumn* scp = dynamic_cast<SimpleColumn*>(srcp.get());
			if (colMap.count(fColumnName) == 1 ||
			    scp->tableName().compare(fTableName) == 0)
			{
				fOid = scp->oid();
				//@bug 221 fix
				fTableName = scp->tableName();
				fSchemaName = scp->schemaName();
				//@info assign tableAlias also. watch for other conflict
				fTableAlias = scp->tableAlias();
				fResultType = scp->resultType();
				return;
			}
		}
	}
	fResultType = csc->colType(fOid);
}
コード例 #2
0
ファイル: cseputils.cpp プロジェクト: Kangmo/infinidb
SimpleFilter* createSimpleFilter
				(
				CalpontSystemCatalog*& csc,
				const CalpontSystemCatalog::TableColName& tcn,
				const string& opstr,
				ConstantColumn* cc
				)
{
	SimpleFilter* lsf = new SimpleFilter();

	Operator* op = new Operator();
	op->data(opstr);
	CalpontSystemCatalog::ColType ccct;
	ccct = op->resultType();
	ccct.colDataType = cc->resultType().colDataType;
	op->operationType(ccct);

	SOP sop(op);
	lsf->op(sop);

	CalpontSystemCatalog::OID oid = csc->lookupOID(tcn);
	CalpontSystemCatalog::ColType ct = csc->colType(oid);

	SimpleColumn* sc = new SimpleColumn();
	sc->schemaName(tcn.schema);
	sc->tableName(tcn.table);
	sc->tableAlias(tcn.table);
	sc->columnName(tcn.column);
	sc->oid(oid);
	sc->resultType(ct);
	sc->alias(tcn.toString());

	lsf->lhs(sc);
	lsf->rhs(cc);

	return lsf;
}
コード例 #3
0
ファイル: virtualtable.cpp プロジェクト: coderplay/infinidb
void VirtualTable::addColumn(const SRCP& column)
{
	// As of bug3695, make sure varbinary is not used in subquery.
	if (column->resultType().colDataType == CalpontSystemCatalog::VARBINARY && !fVarBinOK)
		throw runtime_error ("VARBINARY in subquery is not supported.");

	AggregateColumn*      agc = NULL;
	ArithmeticColumn*     arc = NULL;
	ConstantColumn*       cc  = NULL;
	FunctionColumn*       fc  = NULL;
	SimpleColumn*         sc  = NULL;
	WindowFunctionColumn* wc  = NULL;

	string columnName;
	ostringstream oss;
	UniqId colId;
	if ((sc = dynamic_cast<SimpleColumn*>(column.get())) != NULL)
	{
		columnName = sc->columnName();
		colId = UniqId(sc);
	}
	else if ((agc = dynamic_cast<AggregateColumn*>(column.get())) != NULL)
	{
//		oss << agc->functionName() << "_" << agc->expressionId();
//		oss << "Aggregate_" << agc->expressionId();
		columnName = agc->data();
		colId = UniqId(agc->expressionId(), "", "", "");
	}
	else if ((wc = dynamic_cast<WindowFunctionColumn*>(column.get())) != NULL)
	{
//		oss << wc->functionName() << "_" << wc->expressionId();
//		oss << "Window_" << wc->expressionId();
		columnName = wc->data();
		colId = UniqId(wc->expressionId(), "", "", "");
	}
	else if ((arc = dynamic_cast<ArithmeticColumn*>(column.get())) != NULL)
	{
//		oss << "Arithmetic_" << arc->expressionId();
		columnName = arc->data();
		colId = UniqId(arc->expressionId(), "", "", "");
	}
	else if ((fc = dynamic_cast<FunctionColumn*>(column.get())) != NULL)
	{
//		oss << fc->functionName() << "_" << fc->expressionId();
		columnName = fc->data();
		colId = UniqId(fc->expressionId(), "", "", "");
	}
	else if ((cc = dynamic_cast<ConstantColumn*>(column.get())) != NULL)
	{
//		oss << "Constant_" << cc->expressionId();
		columnName = cc->data();
		colId = UniqId(cc->expressionId(), cc->alias(), "", fView);
	}
	else // new column type has added, but this code is not updated.
	{
		oss << "not supported column type: " << typeid(*(column.get())).name();
		throw runtime_error(oss.str());
	}

	if (columnName.empty())
		columnName = column->alias();

	SimpleColumn* vc = new SimpleColumn();
	vc->tableName(fName);
	vc->tableAlias(fAlias);
	vc->columnName(columnName);
	vc->alias(column->alias());
	vc->viewName(fView);

	uint32_t index = fColumns.size();
	vc->colPosition(index);
	vc->oid(fTableOid+index+1);
	vc->resultType(column->resultType());

	SSC ssc(vc);
	fColumns.push_back(ssc);
	fColumnTypes.push_back(column->resultType());
	fColumnMap.insert(make_pair(colId, index));
}