Closed vvkh closed 1 year ago
At this point, there is no reliable workaround apart from converting the timestamp to some other type on the database side, which is not convenient if you have many existing queries. Although it's hard to imagine a generic solution that will not cause some other nasty bugs, It would be nice to be able to configure the behaviour for such timestamps. For example, configure treating timestamps as floats or something like that.
I believe https://github.com/snowflakedb/snowflake-connector-python/issues/3 is somewhat related.
I wonder if the way to handle this by design is to provide a custom converter_class. Is this part of a stable API that one can rely on?
I see that converter_class
methods might be called only for json
-type response:
https://github.com/snowflakedb/snowflake-connector-python/blob/ec95c563ded4694f69e8bde4eb2f010f92681e58/src/snowflake/connector/result_batch.py#L86 Otherwise, methods from ArrowContext will be used to parse result data.
Do i understand correctly that ArrowContext
is always used if a flag CAN_USE_ARROW_RESULT_FORMAT
set to True
https://github.com/snowflakedb/snowflake-connector-python/blob/ec95c563ded4694f69e8bde4eb2f010f92681e58/src/snowflake/connector/cursor.py#L90-L92
and there is no way to use a custom converter class in that case?
Hey @vvkh, have you tried writing your own converter class? I think you would have to inherit SnowflakeConverter
and have a custom implementation for _TIME_to_python
.
Hey @vvkh, have you tried writing your own converter class? I think you would have to inherit
SnowflakeConverter
and have a custom implementation for_TIME_to_python
.
@sfc-gh-aalam yep, working on it right now. Do you think there must be something that would let you handle such timestamps out of the box, though? Like a parameter for the connector class or a built-in converter.
based on dicussion in https://github.com/snowflakedb/snowflake-connector-python/issues/3, we will create add an option to return None
and log warning when there is a conversion datetime util cannot handle.
Please answer these questions before submitting your issue. Thanks!
What version of Python are you using?
Python 3.10.10 (main, Feb 8 2023, 05:34:50) [Clang 14.0.0 (clang-1400.0.29.202)]
What operating system and processor architecture are you using?
macOS-13.1-arm64-arm-64bit
What are the component versions in the environment (
pip freeze
)?What did you expect to see?
1 row fetched from the database.
Can you set logging to DEBUG and collect the logs?