Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions superset/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -1090,6 +1090,7 @@ def CSV_TO_HIVE_UPLOAD_DIRECTORY_FUNC(
"MySQL",
"SQLite",
"Neo4j",
"Materialize",
# etc.
]

Expand Down
2 changes: 1 addition & 1 deletion superset/databases/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -919,7 +919,7 @@ def available(self) -> Response:
preferred_databases: List[str] = app.config.get("PREFERRED_DATABASES", [])
#print(preferred_databases)
available_databases = []
#print(get_available_engine_specs().items())
print(get_available_engine_specs().items())
for engine_spec, drivers in get_available_engine_specs().items():
payload: Dict[str, Any] = {
"name": engine_spec.engine_name,
Expand Down
1 change: 0 additions & 1 deletion superset/datasets/commands/create.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ def run(self) -> Model:
print(dataset.schema_perm)
# Updates columns and metrics from the dataset
if str(self._properties['database']) == 'Neo4j':
print("We are here now!")
security_manager.add_permission_view_menu(
"datasource_access", dataset.get_perm()
)
Expand Down
50 changes: 50 additions & 0 deletions superset/models/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import enum
import json
import logging
from os import name
import textwrap
# import py2neo here
from py2neo import *
Expand Down Expand Up @@ -73,6 +74,19 @@
PASSWORD_MASK = "X" * 10
DB_CONNECTION_MUTATOR = config["DB_CONNECTION_MUTATOR"]

class ViewColumn():
def __init__(self, name, is_default, type):
self.name = name
self.is_default = is_default
self.type = type

class VIEWS_SOURCES():
name: str
columns: list
def __init__(self, name, columns):
self.name = name
self.columns = columns


class Url(Model, AuditMixinNullable):
"""Used for the short url feature"""
Expand Down Expand Up @@ -513,6 +527,14 @@ def database_kind(self) -> bool:
database_kind = False
return database_kind

@property
def is_materialize(self) -> bool:
if str(self.sqlalchemy_uri).endswith('materialize'):
print('Is Materialize database.')
return True
else:
return False

@cache_util.memoized_func(
key=lambda self, *args, **kwargs: f"db:{self.id}:schema:None:table_list",
cache=cache_manager.data_cache,
Expand Down Expand Up @@ -668,6 +690,34 @@ def get_table(self, table_name: str, schema: Optional[str] = None) -> Table:
meta = MetaData(**extra.get("metadata_params", {}))
if self.database_kind:
return self.get_sqla_engine()
elif self.is_materialize:
sql1 = 'SHOW SOURCES;'
sql2 = 'SHOW VIEWS;'
r1 = self.get_sqla_engine().execute(sql1)
r2 = self.get_sqla_engine().execute(sql2)
print("SOURCES: ", r1)
print("VIEWS: ", r2)
table = []
for source in r1:
table.append(source[0])
for view in r2:
table.append(view[0])
if table_name not in table:
raise Exception("Entered Table Not Found")
else:
sql = 'SHOW COLUMNS FROM ' + table_name + ';'
res = self.get_sqla_engine().execute(sql)
columns = []
for column in res:
columns.append(
ViewColumn(
column[0], column[1], column[2]
)
)
return VIEWS_SOURCES(
name = table_name,
columns = columns
)
else:
return Table(
table_name,
Expand Down