Repository: duckdb/duckdb
File: src/planner/operator/logical_get.cpp (C++)

Code before:
		for (auto &proj_index : projection_ids) {
			auto &index = column_ids[proj_index];
			types.push_back(GetColumnType(index));
		}
	}
	if (!projected_input.empty()) {
		if (children.size() != 1) {
			throw InternalException("LogicalGet::project_input can only be set for table-in-out functions");
		}
		for (auto entry : projected_input) {
			D_ASSERT(entry < children[0]->types.size());
			types.push_back(children[0]->types[entry]);
		}
	}
}

bool LogicalGet::TryGetStorageIndex(const ColumnIndex &column_index, StorageIndex &out_index) const {
	if (column_index.IsRowIdColumn()) {
		return false;
	}
	if (column_index.IsVirtualColumn()) {
		return false;
	}

	auto table = GetTable();
	if (!table || !table->IsDuckTable()) {
		//! If there's no table (or the table is not a DuckDB table) we assume there's no mismatch between
		//! logical/storage index
		out_index = StorageIndex::FromColumnIndex(column_index);
		return true;
	}

	auto &column = table->GetColumn(LogicalIndex(column_index.GetPrimaryIndex()));
	if (column.Generated()) {
		//! This is a generated column, can't use the row group pruner
		return false;
	}
	out_index = StorageIndex::FromColumnIndex(column_index);
	out_index.SetIndex(column.StorageOid());
	return true;
}

idx_t LogicalGet::EstimateCardinality(ClientContext &context) {
	// join order optimizer does better cardinality estimation.
	if (has_estimated_cardinality) {
		return estimated_cardinality;
	}
	if (function.cardinality) {
		auto node_stats = function.cardinality(context, bind_data.get());
		if (node_stats && node_stats->has_estimated_cardinality) {
			return node_stats->estimated_cardinality;

Review comment (suggestion):
The logic below doesn't seem related to DuckDB tables, no? We should be able to remove the `IsDuckTable` check here I think

Code after:
		for (auto &proj_index : projection_ids) {
			auto &index = column_ids[proj_index];
			types.push_back(GetColumnType(index));
		}
	}
	if (!projected_input.empty()) {
		if (children.size() != 1) {
			throw InternalException("LogicalGet::project_input can only be set for table-in-out functions");
		}
		for (auto entry : projected_input) {
			D_ASSERT(entry < children[0]->types.size());
			types.push_back(children[0]->types[entry]);
		}
	}
}

bool LogicalGet::TryGetStorageIndex(const ColumnIndex &column_index, StorageIndex &out_index) const {
	if (column_index.IsRowIdColumn()) {
		return false;
	}
	if (column_index.IsVirtualColumn()) {
		return false;
	}

	auto table = GetTable();
	if (!table) {
		//! If there's no table (or the table is not a DuckDB table) we assume there's no mismatch between
		//! logical/storage index
		out_index = StorageIndex::FromColumnIndex(column_index);
		return true;
	}

	auto &column = table->GetColumn(LogicalIndex(column_index.GetPrimaryIndex()));
	if (column.Generated()) {
		//! This is a generated column, can't use the row group pruner
		return false;
	}
	out_index = StorageIndex::FromColumnIndex(column_index);
	out_index.SetIndex(column.StorageOid());
	return true;
}

idx_t LogicalGet::EstimateCardinality(ClientContext &context) {
	// join order optimizer does better cardinality estimation.
	if (has_estimated_cardinality) {
		return estimated_cardinality;
	}
	if (function.cardinality) {
		auto node_stats = function.cardinality(context, bind_data.get());
		if (node_stats && node_stats->has_estimated_cardinality) {
			return node_stats->estimated_cardinality;