This commit is contained in:
Yonatan Most 2019-07-22 21:25:29 +03:00
Родитель 88c60e23b5
Коммит 7d303ff0cc
2 изменённых файлов: 53 добавлений и 0 удалений

Просмотреть файл

@ -2,5 +2,14 @@
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="PyAbstractClassInspection" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
<inspection_tool class="PyPackageRequirementsInspection" enabled="true" level="WARNING" enabled_by_default="true">
<option name="ignoredPackages">
<value>
<list size="1">
<item index="0" class="java.lang.String" itemvalue="azure" />
</list>
</value>
</option>
</inspection_tool>
</profile>
</component>

44
tables.py Normal file
Просмотреть файл

@ -0,0 +1,44 @@
from typing import Sequence
# noinspection PyProtectedMember
from azure.kusto.data._response import KustoResponseDataSet
from azure.kusto.data.request import KustoClient
from query import Query
class BaseTable:
client: KustoClient
database: str
def __init__(self, client: KustoClient, database: str) -> None:
self.client = client
self.database = database
def execute(self, query: Query) -> KustoResponseDataSet:
raise NotImplementedError()
class SingleTable(BaseTable):
table: str
def __init__(self, client: KustoClient, database: str, table: str) -> None:
super().__init__(client, database)
self.table = table
def execute(self, query: Query) -> KustoResponseDataSet:
return self.client.execute(self.database, self.table + query.compile_all())
class UnionTable(BaseTable):
tables: Sequence[str]
def __init__(self, client: KustoClient, database: str, tables: Sequence[str]) -> None:
super().__init__(client, database)
self.tables = tables
def execute(self, query: Query) -> KustoResponseDataSet:
return self.client.execute(self.database, 'union {}{}'.format(
', '.join(self.table),
query.compile_all()
))