fix: Address regression introduced in #22853#24121
Conversation
8116d38 to
4e6930c
Compare
There was a problem hiding this comment.
The SqlMetric class is still tightly bound to the SqlaTable.
Codecov Report
@@ Coverage Diff @@
## master #24121 +/- ##
==========================================
- Coverage 69.05% 69.01% -0.04%
==========================================
Files 1903 1903
Lines 74530 74522 -8
Branches 8105 8105
==========================================
- Hits 51464 51434 -30
- Misses 20955 20977 +22
Partials 2111 2111
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 2 files with indirect coverage changes 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
There was a problem hiding this comment.
The SqlaTable.make_sqla_column_compatible method was moved to Database.make_sqla_column_compatible given that now the TableColumn.table variable can be None.
There was a problem hiding this comment.
This is a rewrite of the previous logic using a list comprehension. The only addition is the database argument which is required given a SQL Lab Query object has no associated SqlaTable which is previously were/how the database was obtained.
4e6930c to
2f378e8
Compare
There was a problem hiding this comment.
A nice byproduct of this change is this previous logic can be removed given that the db_engine_spec is accessible if associated with a Query or SqlaTable.
2f378e8 to
f184fdc
Compare
There was a problem hiding this comment.
See https://docs.sqlalchemy.org/en/13/orm/constructors.html. Note I'm not overly sure if super is necessary—it's not included in the example, but I gather it doesn't hurt.
There was a problem hiding this comment.
Given that the database variable isn't part of the ORM I believe I'm correct in saying that it can only be defined via a keyword argument.
There was a problem hiding this comment.
@john-bodley is there a follow up PR where'd you be using the database arg? also can you annotate this somehow to let people know this is going to be an ORM object vs some might assume it's an id
f184fdc to
dcfa292
Compare
925ddae to
9c1ce2a
Compare
There was a problem hiding this comment.
By design either self.table or self._database (but not both) will be defined and thus the database property will always be non-null.
4251023 to
2ccf708
Compare
|
@hughhhh I've addressed your comments. |
2ccf708 to
e10b514
Compare
SUMMARY
Per #22853 (comment), this PR addresses an issue introduced in #22853 where chart exploration from SQL Lab would instantiate
TableColumnobjects however there was noSqlaTableassociated with said columns, which previously was a necessary requirement.This PR augments the
TableColumnclass to include aDatabaseobject which is external to the ORM.BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
TESTING INSTRUCTIONS
CI and added some basic unit/integration tests.
Note there is very little unit/integration tests for this work beyond broad workflows. If people are accepting of this approach, I'll strive to add tests before merging, but I first thought there was merit to presenting this approach as a solution.
ADDITIONAL INFORMATION