Closed shahargl closed 1 year ago
Hi @shahargl, thank you for reaching out, we really appreciate your investigation! Would you like to submit a PR to fix the Regex? If not, I will start working on this. Again, thank you for bringing this to our attention! We will introduce some tests to make sure this issue is caught.
Hi @sfc-gh-stan, thanks for the quick response
I've opened a PR that fixes the formatting bug - https://github.com/snowflakedb/snowflake-connector-python/pull/657 I've tested it locally and it does the work for me.
In the solution, I've assumpted that %(VARNAME)s
is the convention (e.g. https://realpython.com/python-f-strings/)
To clean up and re-prioritize bugs and feature requests we are closing all issues older than 6 months as of March 1, 2023. If there are any issues or feature requests that you would like us to address, please re-create them. For urgent issues, opening a support case with this link Snowflake Community is the fastest way to get a response
Please answer these questions before submitting your issue. Thanks!
What version of Python are you using (
python --version
)? Python 3.7.3What operating system and processor architecture are you using (
python -c 'import platform; print(platform.platform())'
)? Darwin-19.5.0-x86_64-i386-64bitWhat are the component versions in the environment (
pip freeze
)?I'm trying to insert multiple rows with VARIANT column. The problem is that it currently not supported both in python connector and sqlalchemy extension.
So my way to overcome this is to use SQLAlchemy events to achieve it:
This works perfectly for one row. But when I try to commit multiple rows at once, there is a redundant ")" after every row.
Digging in, the problem is the
INSERT_SQL_VALUES_RE
regex insnowflake/connector/cursor.py
:The problem is that this regex is greedy and catches also the second ")", so in line 800,
makes fmt to be
'(%(raw)s))'
instead of just'(%(raw)s)'
, which in turn breaks the query.What did you expect to see? The INSERT_SQL_VALUES_RE should be NOT greedy and stop after the first ")", so the query won't be broken.
What did you see instead? INSERT_SQL_VALUES_RE is greedy and takes also the second ")", which relevant to the
(SELECT PARSE_JSON(column1)
and not to the specific row/value.Can you set logging to DEBUG and collect the logs?