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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
// SPDX-License-Identifier: Apache-2.0
// Copyright (c) 2025 ReifyDB
//! User-facing API for defining virtual tables.
//!
//! This module provides simplified traits for users to implement custom virtual tables.
//! Users can choose between two levels of abstraction:
//!
//! - [`UserVTable`]: Simple API for tables that can return all rows at once
//! - [`UserVTableIterator`]: Advanced API for streaming large datasets with optional pushdown
//!
//! # Example
//!
//! ```ignore
//! use reifydb_catalog::vtable::user::{UserVTable, UserVTableColumn};
//! use reifydb_type::value::r#type::Type;
//! use reifydb_core::value::column::columns::Columns;
//!
//! struct MyApiTable {
//! api_client: ApiClient,
//! }
//!
//! impl UserVTable for MyApiTable {
//! fn definition(&self) -> Vec<UserVTableColumn> {
//! vec![
//! UserVTableColumn::new("id", Type::Uint8),
//! UserVTableColumn::new("name", Type::Utf8),
//! ]
//! }
//!
//! fn get(&self) -> Columns {
//! // Return column-oriented data
//! self.api_client.fetch_columns()
//! }
//! }
//! ```
use Columns;
use ;
use crateResult;
/// Column definition for user virtual tables.
/// Simple trait for user-defined virtual tables.
///
/// Implement this trait when your virtual table can return all data at once.
/// For large datasets that should be streamed, implement [`UserVTableIterator`] instead.
///
/// # Thread Safety
///
/// Implementations must be thread-safe (`Send + Sync`) as the same table instance
/// may be queried concurrently from multiple transactions.
/// Pushdown context for advanced virtual table implementations.
///
/// Contains optimization hints that can be used to reduce the amount of data
/// generated by the virtual table.
/// Advanced trait for streaming virtual table implementations.
///
/// Implement this trait when your virtual table needs to:
/// - Stream large datasets in batches
/// - Take advantage of pushdown optimizations (limit, filters)
///
/// # Thread Safety
///
/// Unlike [`UserVTable`], implementations of this trait are instantiated
/// fresh for each query. The factory creates a new instance per query execution.