-
Notifications
You must be signed in to change notification settings - Fork 14.1k
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
fix(dashboard): Return columns and verbose_map for groupby values of Pivot Table v2 [ID-7] #17287
Conversation
d654531
to
eb55f31
Compare
Codecov Report
@@ Coverage Diff @@
## master #17287 +/- ##
==========================================
- Coverage 77.04% 76.80% -0.25%
==========================================
Files 1037 1037
Lines 55635 55718 +83
Branches 7594 7594
==========================================
- Hits 42863 42792 -71
- Misses 12522 12676 +154
Partials 250 250
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
superset/models/slice.py
Outdated
def get_query_context(self) -> Dict[str, Any]: | ||
query_context: Dict[str, Any] = {} | ||
if not self.query_context: | ||
return query_context | ||
try: | ||
query_context = json.loads(self.query_context) | ||
except json.decoder.JSONDecodeError as ex: | ||
logger.error("Malformed json in slice's query context", exc_info=True) | ||
logger.exception(ex) | ||
return query_context | ||
|
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.
We can make this function more generic. like this:
def get_query_context(self) -> QueryContext:
if self.query_context:
try:
return self.query_context(**json.loads(self.query_context))
except json.decoder.JSONDecodeError as ex:
logger.error("Malformed json in slice's query context", exc_info=True)
logger.exception(ex)
return QueryContext(
datasource={"type": self.datasource_type, "id": self.datasource_id},
queries=[self.viz.query_obj()],)
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.
@zhaoyongjie on the first return statement I believe we could instantiate the QueryContext
. Also, for non v1 charts or in the case there isn't a query context payload, we probably should just return None
, as the legacy charts aren't really compatible with QueryContext
. Could this work?
def get_query_context(self) -> Optional[QueryContext]:
if self.query_context:
try:
return QueryContext(**json.loads(self.query_context))
except json.decoder.JSONDecodeError as ex:
logger.error("Malformed json in slice's query context", exc_info=True)
logger.exception(ex)
return None
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.
Nice! It makes sense return None
in legacy chart.
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.
Thanks for suggestions! I made the change, would appreciate another look 🙂
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.
Looking good! get_query_context
may still need some iterations, would be interested in hearing @zhaoyongjie's thoughts
superset/models/slice.py
Outdated
def get_query_context(self) -> Dict[str, Any]: | ||
query_context: Dict[str, Any] = {} | ||
if not self.query_context: | ||
return query_context | ||
try: | ||
query_context = json.loads(self.query_context) | ||
except json.decoder.JSONDecodeError as ex: | ||
logger.error("Malformed json in slice's query context", exc_info=True) | ||
logger.exception(ex) | ||
return query_context | ||
|
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.
@zhaoyongjie on the first return statement I believe we could instantiate the QueryContext
. Also, for non v1 charts or in the case there isn't a query context payload, we probably should just return None
, as the legacy charts aren't really compatible with QueryContext
. Could this work?
def get_query_context(self) -> Optional[QueryContext]:
if self.query_context:
try:
return QueryContext(**json.loads(self.query_context))
except json.decoder.JSONDecodeError as ex:
logger.error("Malformed json in slice's query context", exc_info=True)
logger.exception(ex)
return None
/testenv up |
@kgabryje Ephemeral environment spinning up at http://54.213.130.117:8080. Credentials are |
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.
LGTM, solid work @kgabryje ! 🎉
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.
LGTM.
Ephemeral environment shutdown and build artifacts deleted. |
🏷️ 2021.46 |
…Pivot Table v2 [ID-7] (#17287) * fix(dashboard): Return columns and verbose_map for groupby values of Pivot Table v2 * Refactor * Fix test and lint * Fix test * Refactor * Fix lint
SUMMARY
Columns used by Pivot Table v2 were not processed correctly by
/dashboard/{id}/datasets
endpoint, resulting in chart not displaying custom column labels when added to dashboard. This PR fixes the issue.BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
Before:
After:
TESTING INSTRUCTIONS
ADDITIONAL INFORMATION
CC @junlincc