john-bodley commented on a change in pull request #8464: [SIP-15] Fixing
datetime conversion and SQL literal
URL:
https://github.com/apache/incubator-superset/pull/8464#discussion_r340341849
##########
File path: superset/db_engine_specs/sqlite.py
##########
@@ -75,11 +75,10 @@ def get_all_datasource_names(
raise Exception(f"Unsupported datasource_type: {datasource_type}")
@classmethod
- def convert_dttm(cls, target_type: str, dttm: datetime) -> str:
- iso = dttm.isoformat().replace("T", " ")
- if "." not in iso:
- iso += ".000000"
- return "'{}'".format(iso)
+ def convert_dttm(cls, target_type: str, dttm: datetime) -> Optional[str]:
+ if target_type.upper() == "TEXT":
+ return f"""'{dttm.isoformat(sep=" ", timespec="microseconds")}'"""
+ return None
Review comment:
@willbarrett epoch is handled by specifying `epoch_s` in the
python-date-format.
Note per the referenced PoC PR the future end goal is to provide an engine
specific graph which maps between various SQLAlchemy and `datetime` types. Much
of the time grain bucketing is potentially wrong for string columns.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]