Commit 38808a8 1 parent 962db5f commit 38808a8 Copy full SHA for 38808a8
File tree 1 file changed +15
-1
lines changed
1 file changed +15
-1
lines changed Original file line number Diff line number Diff line change 14
14
# KIND, either express or implied. See the License for the
15
15
# specific language governing permissions and limitations
16
16
# under the License.
17
- from marshmallow import fields
17
+ from typing import List
18
+
19
+ from marshmallow import fields , Schema
18
20
from marshmallow_sqlalchemy import SQLAlchemyAutoSchema
19
21
22
+ from superset .dashboards .schemas import UserSchema
20
23
from superset .models .sql_lab import Query
24
+ from superset .sql_parse import Table
21
25
22
26
openapi_spec_methods_override = {
23
27
"get" : {"get" : {"description" : "Get query detail information." }},
31
35
}
32
36
33
37
38
+ class DatabaseSchema (Schema ):
39
+ database_name = fields .String ()
40
+
41
+
34
42
class QuerySchema (SQLAlchemyAutoSchema ):
35
43
"""
36
44
Schema for the ``Query`` model.
37
45
"""
38
46
39
47
start_time = fields .Float (attribute = "start_time" )
40
48
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" )
41
52
42
53
class Meta : # pylint: disable=too-few-public-methods
43
54
model = Query
44
55
load_instance = True
45
56
include_relationships = True
57
+
58
+ def get_sql_tables (_ , obj : Query ) -> List [Table ]:
59
+ return obj .sql_tables
You can’t perform that action at this time.
0 commit comments