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

chore: refactor SqlTable and BaseDatasource into Dataset #28875

Draft
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

mistercrunch
Copy link
Member

Summary

Refactoring BaseDatasource into SqlaTable, and renaming this Dataset to reflect the current information architecture.

Looiking to do more renaming over time, things like:

  • slice -> chart
  • datasource -> dataset
  • ...

@github-actions github-actions bot added risk:db-migration PRs that require a DB migration api Related to the REST API labels Jun 3, 2024
@mistercrunch mistercrunch force-pushed the Dataset branch 2 times, most recently from aa29cc9 to f952323 Compare June 6, 2024 22:58
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)
Copy link
Member Author

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:
Copy link
Member Author

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(
Copy link
Member Author

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]:
Copy link
Member Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api Related to the REST API review:draft risk:db-migration PRs that require a DB migration size/XXL
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants