table/
dist_table.rs

1// Copyright 2023 Greptime Team
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15use std::sync::Arc;
16
17use common_error::ext::BoxedError;
18use common_recordbatch::SendableRecordBatchStream;
19use store_api::data_source::DataSource;
20use store_api::storage::ScanRequest;
21
22use crate::error::UnsupportedSnafu;
23use crate::metadata::{FilterPushDownType, TableInfoRef};
24use crate::{Table, TableRef};
25
26#[derive(Clone)]
27pub struct DistTable;
28
29impl DistTable {
30    pub fn table(table_info: TableInfoRef) -> TableRef {
31        let data_source = Arc::new(DummyDataSource);
32        let table = Table::new(table_info, FilterPushDownType::Inexact, data_source);
33        Arc::new(table)
34    }
35}
36
37pub struct DummyDataSource;
38
39impl DataSource for DummyDataSource {
40    fn get_stream(
41        &self,
42        _request: ScanRequest,
43    ) -> std::result::Result<SendableRecordBatchStream, BoxedError> {
44        UnsupportedSnafu {
45            operation: "get stream from a distributed table",
46        }
47        .fail()
48        .map_err(BoxedError::new)
49    }
50}