-
Notifications
You must be signed in to change notification settings - Fork 23
/
interface.py
68 lines (51 loc) · 1.61 KB
/
interface.py
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
import typing
from pathlib import Path
from abc import ABC, abstractmethod
from .job import DEFAULT_RETRY_COUNT
from .job import DEFAULT_RETRY_PAUSE_SEC
from bigflow.commons import public
DEFAULT_RUNTIME = '1970-01-01'
@public()
class BigQueryOperation(ABC):
@abstractmethod
def to_job(self, id: str, retry_count: int = DEFAULT_RETRY_COUNT, retry_pause_sec: int = DEFAULT_RETRY_PAUSE_SEC):
pass
@abstractmethod
def run(self, runtime=DEFAULT_RUNTIME):
pass
@public()
class Dataset(ABC):
@abstractmethod
def write_truncate(self, table_name: str, sql: str, partitioned: bool = True) -> BigQueryOperation:
pass
@abstractmethod
def write_append(self, table_name: str, sql: str, partitioned: bool = True) -> BigQueryOperation:
pass
@abstractmethod
def write_tmp(self, table_name: str, sql: str) -> BigQueryOperation:
pass
@abstractmethod
def collect(self, sql: str) -> BigQueryOperation:
pass
@abstractmethod
def collect_list(self, sql: str, record_as_dict: bool = False) -> BigQueryOperation:
pass
@abstractmethod
def create_table(self, create_query: str) -> BigQueryOperation:
pass
@abstractmethod
def create_table_from_schema(
self,
table_name: str,
schema: typing.Union[typing.List[dict], Path, None] = None,
table=None):
pass
@abstractmethod
def insert(
self,
table_name: str,
records: typing.Union[typing.List[dict], Path]):
pass
@abstractmethod
def delete_dataset(self):
pass