-
Notifications
You must be signed in to change notification settings - Fork 14.3k
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(redshift): convert_dttm method for redshift dataset and tests #26283
fix(redshift): convert_dttm method for redshift dataset and tests #26283
Conversation
add convert_dttm method for redshift
@@ -147,6 +151,19 @@ def _mutate_label(label: str) -> str: | |||
""" | |||
return label.lower() | |||
|
|||
@classmethod |
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.
This seems to be identical with the PostgresEngineSpec.convert_dttm()
method which it inherits and thus this isn't needed.
Keeping the unit tests makes sense.
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.
but same postgres method is not getting called, when i use it?
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.
that's why if i remove method, test is getting failed as well
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.
i understand it inherits postgres, but somehow mixin is not working @john-bodley
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.
@gaurav7261 you're correct - @john-bodley my bad, convert_dttm
is actually defined in PostgresEngineSpec
, not PostgresBaseEngineSpec
like I said a moment ago. So this change LGTM.
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.
@john-bodley @villebro can you help why precommit failed,what i need to do
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.
Did you check the details of the CI workflow? https://github.com/apache/superset/actions/runs/7226045710/job/19691266350?pr=26283
It specifies which changes are needed. Tip: you can configure pre-commit
to do this automatically for you. Check here for details: https://github.com/apache/superset/blob/master/CONTRIBUTING.md#git-hooks
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, got it, actually i was confused when it highlight the line on another function get_cancel_query_id
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.
@john-bodley please approve the run
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #26283 +/- ##
==========================================
+ Coverage 66.99% 69.18% +2.18%
==========================================
Files 1945 1945
Lines 75949 75950 +1
Branches 8460 8460
==========================================
+ Hits 50885 52544 +1659
+ Misses 22879 21221 -1658
Partials 2185 2185
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
@gaurav7261 CI failing. If you run |
superset/db_engine_specs/redshift.py
Outdated
def convert_dttm( | ||
cls, target_type: str, dttm: datetime, db_extra: dict[str, Any] | None = None | ||
) -> str | None: | ||
sqla_type = cls.get_sqla_column_type(target_type) | ||
|
||
if isinstance(sqla_type, Date): | ||
return f"TO_DATE('{dttm.date().isoformat()}', 'YYYY-MM-DD')" | ||
if isinstance(sqla_type, DateTime): | ||
dttm_formatted = dttm.isoformat(sep=" ", timespec="microseconds") | ||
return f"""TO_TIMESTAMP('{dttm_formatted}', 'YYYY-MM-DD HH24:MI:SS.US')""" | ||
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.
It hit me, we should consider moving this method from PostgresEngineSpec
to PostgresBaseEngineSpec
, as I think it's probably a good default for Postgres-like databases. This way the Redshift spec would get it "for free".
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.
+1
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.
yes sure, doing that
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.
done @john-bodley @villebro , redshift test is also running, i have ran tox -e pre-commit
as well @john-bodley , please approve CI
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.
@john-bodley i think ci is not started yet, can you help
@john-bodley can we merge this pr ? |
@michael-s-molina can we add this to the 3.x releases? |
@villebro All fixes that are applicable to a release are automatically cherry-picked once merged to master and released in the next patch. You don't need to request their addition 😉 |
…6283) Co-authored-by: GauravM <[email protected]> (cherry picked from commit 60abf7e)
…6283) Co-authored-by: GauravM <[email protected]> (cherry picked from commit 60abf7e)
…ache#26283) Co-authored-by: GauravM <[email protected]> (cherry picked from commit 60abf7e)
…ache#26283) Co-authored-by: GauravM <[email protected]>
…ache#26283) Co-authored-by: GauravM <[email protected]>
add convert_dttm method for redshift
SUMMARY
raise exc.CompileError( sqlalchemy.exc.CompileError: Cannot compile Column object until its 'name' is assigned.
query that was getting submitted:
10:20:33,526:INFO:superset.connectors.sqla.models:SELECT day AS day FROM (SELECT date_trunc('day', created_on) as day FROM public.redshift_order) AS virtual_table WHERE day IN (<name unknown>)
BEFORE SCREENSHOTS OR ANIMATED GIF
TESTING INSTRUCTIONS
ADDITIONAL INFORMATION