Skip to content

Commit

Permalink
Fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
diegomedina248 committed Apr 26, 2022
1 parent 962db5f commit 38808a8
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion superset/queries/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,14 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
from marshmallow import fields
from typing import List

from marshmallow import fields, Schema
from marshmallow_sqlalchemy import SQLAlchemyAutoSchema

from superset.dashboards.schemas import UserSchema
from superset.models.sql_lab import Query
from superset.sql_parse import Table

openapi_spec_methods_override = {
"get": {"get": {"description": "Get query detail information."}},
Expand All @@ -31,15 +35,25 @@
}


class DatabaseSchema(Schema):
database_name = fields.String()


class QuerySchema(SQLAlchemyAutoSchema):
"""
Schema for the ``Query`` model.
"""

start_time = fields.Float(attribute="start_time")
end_time = fields.Float(attribute="end_time")
user = fields.Nested(UserSchema)
database = fields.Nested(DatabaseSchema)
sql_tables = fields.Method("get_sql_tables")

class Meta: # pylint: disable=too-few-public-methods
model = Query
load_instance = True
include_relationships = True

def get_sql_tables(_, obj: Query) -> List[Table]:
return obj.sql_tables

0 comments on commit 38808a8

Please sign in to comment.