1//===----------------------------------------------------------------------===//
2// DuckDB
3//
4// duckdb/planner/bound_tableref.hpp
5//
6//
7//===----------------------------------------------------------------------===//
8
9#pragma once
10
11#include "duckdb/common/common.hpp"
12#include "duckdb/common/enums/tableref_type.hpp"
13#include "duckdb/parser/parsed_data/sample_options.hpp"
14
15namespace duckdb {
16
17class BoundTableRef {
18public:
19 explicit BoundTableRef(TableReferenceType type) : type(type) {
20 }
21 virtual ~BoundTableRef() {
22 }
23
24 //! The type of table reference
25 TableReferenceType type;
26 //! The sample options (if any)
27 unique_ptr<SampleOptions> sample;
28
29public:
30 template <class TARGET>
31 TARGET &Cast() {
32 if (type != TARGET::TYPE) {
33 throw InternalException("Failed to cast bound table ref to type - table ref type mismatch");
34 }
35 return reinterpret_cast<TARGET &>(*this);
36 }
37
38 template <class TARGET>
39 const TARGET &Cast() const {
40 if (type != TARGET::TYPE) {
41 throw InternalException("Failed to cast bound table ref to type - table ref type mismatch");
42 }
43 return reinterpret_cast<const TARGET &>(*this);
44 }
45};
46} // namespace duckdb
47