-
Notifications
You must be signed in to change notification settings - Fork 14.3k
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
feat: Save column data into json_metadata for all Query executions #20059
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
4a93a3c
add save_metadata function to QueryDAO
hughhhh 30a613b
use set_extra_json_key
hughhhh ba9506c
Merge branch 'master' of https://github.com/apache/superset into save…
hughhhh d34a054
added test
hughhhh ee932e0
Update queries_test.py
hughhhh 8ff1349
fix pylint
hughhhh 9396d3b
Merge branch 'save-col-on-query' of https://github.com/hve-labs/super…
hughhhh 3618c8a
add to session
hughhhh c806347
add to session
hughhhh 62669bc
Merge branch 'save-col-on-query' of https://github.com/hve-labs/super…
hughhhh 4c7549d
refactor
hughhhh 6af71ee
forgot the return
hughhhh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# Licensed to the Apache Software Foundation (ASF) under one | ||
# or more contributor license agreements. See the NOTICE file | ||
# distributed with this work for additional information | ||
# regarding copyright ownership. The ASF licenses this file | ||
# to you under the Apache License, Version 2.0 (the | ||
# "License"); you may not use this file except in compliance | ||
# with the License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, | ||
# software distributed under the License is distributed on an | ||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
# KIND, either express or implied. See the License for the | ||
# specific language governing permissions and limitations | ||
# under the License. | ||
import json | ||
from typing import Iterator | ||
|
||
import pytest | ||
from sqlalchemy.orm.session import Session | ||
|
||
|
||
def test_query_dao_save_metadata(app_context: None, session: Session) -> None: | ||
from superset.models.core import Database | ||
from superset.models.sql_lab import Query | ||
|
||
engine = session.get_bind() | ||
Query.metadata.create_all(engine) # pylint: disable=no-member | ||
|
||
db = Database(database_name="my_database", sqlalchemy_uri="sqlite://") | ||
|
||
query_obj = Query( | ||
client_id="foo", | ||
database=db, | ||
tab_name="test_tab", | ||
sql_editor_id="test_editor_id", | ||
sql="select * from bar", | ||
select_sql="select * from bar", | ||
executed_sql="select * from bar", | ||
limit=100, | ||
select_as_cta=False, | ||
rows=100, | ||
error_message="none", | ||
results_key="abc", | ||
) | ||
|
||
session.add(db) | ||
session.add(query_obj) | ||
|
||
from superset.queries.dao import QueryDAO | ||
|
||
query = session.query(Query).one() | ||
QueryDAO.save_metadata(query=query, payload={"columns": []}) | ||
assert query.extra.get("columns", None) == [] |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Can we maybe just let the command return raw dict here, too, and use
self.json_response
in whatever view handler the result may be used, so that json.dumps in the executor itself can be cleaned up?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.
but there is specific logic in the
json.dumps
that needs thestatus
to understand how to serialize. I don't see a clean way to do this unless we move all this logic outside of the command.Can we revisit this in another refactor ticket?
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.
Sounds good.