|
3 | 3 | from cloudquery.sdk import schema
|
4 | 4 | from typing import List, Generator, Dict
|
5 | 5 | import pyarrow as pa
|
| 6 | +from cloudquery.sdk.types import JSONType |
6 | 7 |
|
7 | 8 | NAME = "memdb"
|
8 | 9 | VERSION = "development"
|
9 | 10 |
|
10 | 11 |
|
11 | 12 | class MemDB(plugin.Plugin):
|
12 | 13 | def __init__(self) -> None:
|
13 |
| - super().__init__(NAME, VERSION) |
| 14 | + super().__init__( |
| 15 | + NAME, VERSION, opts=plugin.plugin.Options(team="cloudquery", kind="source") |
| 16 | + ) |
14 | 17 | self._db: Dict[str, pa.RecordBatch] = {}
|
15 |
| - self._tables: Dict[str, schema.Table] = {} |
| 18 | + self._tables: Dict[str, schema.Table] = { |
| 19 | + "table_1": schema.Table( |
| 20 | + name="table_1", |
| 21 | + columns=[ |
| 22 | + schema.Column( |
| 23 | + name="name", |
| 24 | + type=pa.string(), |
| 25 | + primary_key=True, |
| 26 | + not_null=True, |
| 27 | + unique=True, |
| 28 | + ), |
| 29 | + schema.Column( |
| 30 | + name="id", |
| 31 | + type=pa.string(), |
| 32 | + primary_key=True, |
| 33 | + not_null=True, |
| 34 | + unique=True, |
| 35 | + incremental_key=True, |
| 36 | + ), |
| 37 | + ], |
| 38 | + title="Table 1", |
| 39 | + description="Test Table 1", |
| 40 | + is_incremental=True, |
| 41 | + relations=[ |
| 42 | + schema.Table( |
| 43 | + name="table_1_relation_1", |
| 44 | + columns=[ |
| 45 | + schema.Column( |
| 46 | + name="name", |
| 47 | + type=pa.string(), |
| 48 | + primary_key=True, |
| 49 | + not_null=True, |
| 50 | + unique=True, |
| 51 | + ), |
| 52 | + schema.Column(name="data", type=JSONType()), |
| 53 | + ], |
| 54 | + title="Table 1 Relation 1", |
| 55 | + description="Test Table 1 Relation 1", |
| 56 | + ) |
| 57 | + ], |
| 58 | + ), |
| 59 | + "table_2": schema.Table( |
| 60 | + name="table_2", |
| 61 | + columns=[ |
| 62 | + schema.Column( |
| 63 | + name="name", |
| 64 | + type=pa.string(), |
| 65 | + primary_key=True, |
| 66 | + not_null=True, |
| 67 | + unique=True, |
| 68 | + ), |
| 69 | + schema.Column(name="id", type=pa.string()), |
| 70 | + ], |
| 71 | + title="Table 2", |
| 72 | + description="Test Table 2", |
| 73 | + ), |
| 74 | + } |
16 | 75 |
|
17 | 76 | def get_tables(self, options: plugin.TableOptions = None) -> List[plugin.Table]:
|
18 | 77 | tables = list(self._tables.values())
|
|
0 commit comments