-
Notifications
You must be signed in to change notification settings - Fork 31
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
Return TIMESTAMP columns as native Python datetime objects to improve support for Apache Superset #395
Return TIMESTAMP columns as native Python datetime objects to improve support for Apache Superset #395
Changes from 3 commits
0212487
f9bd08c
66e7b51
3dc5cb7
8dfcf80
b08cb16
efe8bfb
2d1f41f
246d917
94b3d1e
85b7c7f
2cf32e2
fbef448
3b66626
57ec090
9b82ac2
5b4d5ec
e9788ea
eebd670
187ed3f
e3b8d50
32a4826
2c9e3aa
2adf833
9bc5f51
8e53da5
5ddced3
aaaf7ee
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,6 +43,7 @@ | |
"smallint": sqltypes.SmallInteger, | ||
"timestamp": sqltypes.TIMESTAMP, | ||
"timestamp with time zone": sqltypes.TIMESTAMP, | ||
"timestamp without time zone": sqltypes.TIMESTAMP, | ||
"object": Object, | ||
"integer": sqltypes.Integer, | ||
"long": sqltypes.NUMERIC, | ||
|
@@ -64,6 +65,7 @@ | |
TYPES_MAP["smallint_array"] = ARRAY(sqltypes.SmallInteger) | ||
TYPES_MAP["timestamp_array"] = ARRAY(sqltypes.TIMESTAMP) | ||
TYPES_MAP["timestamp with time zone_array"] = ARRAY(sqltypes.TIMESTAMP) | ||
TYPES_MAP["timestamp without time zone_array"] = ARRAY(sqltypes.TIMESTAMP) | ||
TYPES_MAP["long_array"] = ARRAY(sqltypes.NUMERIC) | ||
TYPES_MAP["bigint_array"] = ARRAY(sqltypes.NUMERIC) | ||
TYPES_MAP["double_array"] = ARRAY(sqltypes.DECIMAL) | ||
|
@@ -75,7 +77,6 @@ | |
except Exception: | ||
pass | ||
|
||
|
||
log = logging.getLogger(__name__) | ||
|
||
|
||
|
@@ -261,7 +262,7 @@ def get_pk_constraint(self, engine, table_name, schema=None, **kw): | |
|
||
def result_fun(result): | ||
rows = result.fetchall() | ||
return set(map(lambda el: el[0], rows)) | ||
return list(set(map(lambda el: el[0], rows))) | ||
Comment on lines
-264
to
+269
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. While I don't know about the specific background why there has been a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Dear @Aymaru, apologies for the late reply. We've split off this amendment into #426. For you, it apparently solved this issue:
With the patch at #426, we are observing a regression. Maybe due to the upgrade to SQLAlchemy 1.4, and maybe other changes in Apache Superset, this is not needed anymore? With kind regards, |
||
else: | ||
query = """SELECT constraint_name | ||
FROM information_schema.table_constraints | ||
|
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.
Maybe we can come up with a more elegant and efficient implementation. When trying to follow the code, I recognize that it builds up a list of boolean flags which designates which columns to apply the datetime conversion to, right?
Based on that information, the code will then apply the conversion function on each column while mapping each row into memory through the
list()
function.I am a bit hesitant on this and wanted to share my specific concerns:
a) The code might allocate a significant amount of memory on larger results.
b) On a very large result set, it might even run out of memory.
c) When applying the conversion, there are currently no sanity checks around which test for
NULL
- or other emptyness. I am specifically looking atfloat(str(x)[0:10])
here. Also, there is no other exception handling either. We might want to improve on this aspect.Maybe we can wrap that conversion into a generator function in order to keep the memory footprint low and, while being at it, add some more bells and whistles on the error handling side?