forked from aballiet/data-check
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathquery_client.py
More file actions
35 lines (26 loc) · 817 Bytes
/
query_client.py
File metadata and controls
35 lines (26 loc) · 817 Bytes
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
from abc import ABC, abstractmethod
import pandas as pd
from sqlglot.expressions import Select
from .models.table import TableSchema
class QueryClient(ABC):
###### ABSTRACT METHODS ######
@abstractmethod
def get_credentials(self):
pass
@abstractmethod
def init_client(self):
pass
@abstractmethod
def get_table(self, table: str):
pass
@abstractmethod
def run_query_to_dataframe(self, query: Select) -> pd.DataFrame:
pass
@abstractmethod
def get_table_schema_from_table(self, table: str) -> TableSchema:
"""Get the schema from an existing table or view"""
pass
@abstractmethod
def get_table_schema_from_sql(self, query: Select) -> TableSchema:
"""Get the schema of a table from a query"""
pass