Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: make cte_alias compatible with Ocient #16

Merged
merged 2 commits into from
Feb 8, 2023
Merged
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
51 changes: 27 additions & 24 deletions superset/db_engine_specs/ocient.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,9 @@ class OcientEngineSpec(BaseEngineSpec):
force_column_alias_quotes = True
max_column_name_length = 30

allows_cte_in_subquery = False
# Ocient does not support cte names starting with underscores
cte_alias = "cte__"
# Store mapping of superset Query id -> Ocient ID
# These are inserted into the cache when executing the query
# They are then removed, either upon cancellation or query completion
Expand Down Expand Up @@ -260,30 +263,30 @@ def fetch_data(
cursor
)

if columns_to_sanitize:
# At least 1 column has to be sanitized.

def identity(x: Any) -> Any:
return x

# Use the identity function if the column type doesn't need to be
# sanitized.
sanitization_functions: List[SanitizeFunc] = [
identity for _ in range(len(cursor.description))
]
for info in columns_to_sanitize:
sanitization_functions[info.column_index] = info.sanitize_func

# pyocient returns a list of NamedTuple objects which represent a
# single row. We have to do this copy because that data type is
# NamedTuple's are immutable.
rows = [
tuple(
sanitize_func(val)
for sanitize_func, val in zip(sanitization_functions, row)
)
for row in rows
]
if columns_to_sanitize:
# At least 1 column has to be sanitized.

def identity(x: Any) -> Any:
return x

# Use the identity function if the column type doesn't need to be
# sanitized.
sanitization_functions: List[SanitizeFunc] = [
identity for _ in range(len(cursor.description))
]
for info in columns_to_sanitize:
sanitization_functions[info.column_index] = info.sanitize_func

# pyocient returns a list of NamedTuple objects which represent a
# single row. We have to do this copy because that data type is
# NamedTuple's are immutable.
rows = [
tuple(
sanitize_func(val)
for sanitize_func, val in zip(sanitization_functions, row)
)
for row in rows
]
return rows

@classmethod
Expand Down