Skip to content

Commit 38808a8

Browse files
Fix test
1 parent 962db5f commit 38808a8

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

superset/queries/schemas.py

+15-1
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,14 @@
1414
# KIND, either express or implied. See the License for the
1515
# specific language governing permissions and limitations
1616
# under the License.
17-
from marshmallow import fields
17+
from typing import List
18+
19+
from marshmallow import fields, Schema
1820
from marshmallow_sqlalchemy import SQLAlchemyAutoSchema
1921

22+
from superset.dashboards.schemas import UserSchema
2023
from superset.models.sql_lab import Query
24+
from superset.sql_parse import Table
2125

2226
openapi_spec_methods_override = {
2327
"get": {"get": {"description": "Get query detail information."}},
@@ -31,15 +35,25 @@
3135
}
3236

3337

38+
class DatabaseSchema(Schema):
39+
database_name = fields.String()
40+
41+
3442
class QuerySchema(SQLAlchemyAutoSchema):
3543
"""
3644
Schema for the ``Query`` model.
3745
"""
3846

3947
start_time = fields.Float(attribute="start_time")
4048
end_time = fields.Float(attribute="end_time")
49+
user = fields.Nested(UserSchema)
50+
database = fields.Nested(DatabaseSchema)
51+
sql_tables = fields.Method("get_sql_tables")
4152

4253
class Meta: # pylint: disable=too-few-public-methods
4354
model = Query
4455
load_instance = True
4556
include_relationships = True
57+
58+
def get_sql_tables(_, obj: Query) -> List[Table]:
59+
return obj.sql_tables

0 commit comments

Comments
 (0)