-
Notifications
You must be signed in to change notification settings - Fork 88
Expand file tree
/
Copy pathpython_replacement_scan.hpp
More file actions
38 lines (31 loc) · 1.41 KB
/
Copy pathpython_replacement_scan.hpp
File metadata and controls
38 lines (31 loc) · 1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#pragma once
#include "duckdb/main/client_context_state.hpp"
#include "duckdb/common/case_insensitive_map.hpp"
#include "duckdb/parser/tableref.hpp"
#include "duckdb/function/replacement_scan.hpp"
#include "duckdb_python/python_dependency.hpp"
#include "duckdb_python/pybind11/pybind_wrapper.hpp"
namespace duckdb {
class PythonRegisteredObjectState : public ClientContextState {
public:
static constexpr const char *Key = "python_registered_objects";
void Register(const string &name, const py::object &object);
void Unregister(const string &name);
py::object Get(const string &name);
bool Contains(const string &name);
private:
mutex lock;
case_insensitive_map_t<shared_ptr<DependencyItem>> registered_objects;
};
struct PythonReplacementScan {
public:
static unique_ptr<TableRef> Replace(ClientContext &context, ReplacementScanInput &input,
optional_ptr<ReplacementScanData> data);
//! Try to perform a replacement, returns NULL on error
static unique_ptr<TableRef> TryReplacementObject(const py::object &entry, const string &name,
ClientContext &context, bool relation = false);
//! Perform a replacement or throw if it failed
static unique_ptr<TableRef> ReplacementObject(const py::object &entry, const string &name, ClientContext &context,
bool relation = false);
};
} // namespace duckdb