forked from feldera/feldera
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path_sql_table.py
More file actions
25 lines (18 loc) · 734 Bytes
/
_sql_table.py
File metadata and controls
25 lines (18 loc) · 734 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
from typing import Optional
from feldera.sql_schema import SQLSchema
class SQLTable:
def __init__(self, name: str, ddl: Optional[str] = None, schema: Optional[SQLSchema] = None):
if ddl is None and schema is None:
raise ValueError("Either ddl or schema must be provided")
self.name: str = name
self.ddl: str = ddl
self.schema: Optional[SQLSchema] = schema
def build_ddl(self):
"""
Either returns the provided ddl or builds it from the schema
"""
if self.schema is None:
return self.ddl
if self.ddl is not None:
raise ValueError("Both ddl and schema are provided")
return self.schema.build_ddl(self.name)