-
Notifications
You must be signed in to change notification settings - Fork 13.7k
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
chore: refactor SqlTable and BaseDatasource into Dataset #28875
base: master
Are you sure you want to change the base?
Conversation
aa29cc9
to
f952323
Compare
result = db_engine_spec.fetch_data(cursor, limit=1) | ||
result_set = SupersetResultSet(result, cursor.description, db_engine_spec) | ||
return result_set.columns | ||
result_set = database.get_result_set(query, catalog, schema, limit=1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Streamlining with a factored-out Dataset.get_result_set
@@ -636,14 +636,24 @@ def mutate_sql_based_on_config(self, sql_: str, is_split: bool = False) -> str: | |||
) | |||
return sql_ | |||
|
|||
def get_df( # pylint: disable=too-many-locals | |||
def render_sql(self, sql: str, **kwargs: Any) -> str: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this method (Database.render_sql
) allows quite a bite of simplification as the template renderer was getting passed around like crazy
tp = jinja_context.get_template_processor(self) | ||
return tp.process_template(sql, **kwargs) | ||
|
||
def get_result_set( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Factoring get_result_set
out of get_df
as its needed places, and makes the method a bit more pallatable.
@@ -144,15 +143,6 @@ def validate_adhoc_subquery( | |||
return ";\n".join(str(statement) for statement in statements) | |||
|
|||
|
|||
def json_to_dict(json_str: str) -> dict[Any, Any]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
moved to utils/json.py
Summary
Refactoring BaseDatasource into SqlaTable, and renaming this Dataset to reflect the current information architecture.
Looiking to do more renaming over time, things like: