sqlmesh
sqlmesh copied to clipboard
Incorrect arguments to JSON_TABLE in SQLMesh MySQL based unit tests
MySQL JSON_TABLE fails to run in SQLMesh unit tests, giving the error 1210 'Incorrect arguments to JSON_TABLE'. Perhaps certain characters are not escaped or passed to pymysql properly? E.g. the * or $ sign? The same query runs fine in MySQL and through SQLMesh when the model executes.
Versions:
- SQLMesh: 0.225.0
- MySQL: 8.0.40
A reproducible example is here: https://github.com/jdddog/sqlmesh_json_table_tests
ERROR: test_example (/path/to/sqlmesh_json_table_tests/tests/test_example.yaml)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/path/to/sqlmesh_json_table_tests/.venv/lib/python3.12/site-packages/pandas/io/sql.py", line 2664, in execute
cur.execute(sql, *args)
File "/path/to/sqlmesh_json_table_tests/.venv/lib/python3.12/site-packages/pymysql/cursors.py", line 153, in execute
result = self._query(query)
^^^^^^^^^^^^^^^^^^
File "/path/to/sqlmesh_json_table_tests/.venv/lib/python3.12/site-packages/pymysql/cursors.py", line 322, in _query
conn.query(q)
File "/path/to/sqlmesh_json_table_tests/.venv/lib/python3.12/site-packages/pymysql/connections.py", line 575, in query
self._affected_rows = self._read_query_result(unbuffered=unbuffered)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/path/to/sqlmesh_json_table_tests/.venv/lib/python3.12/site-packages/pymysql/connections.py", line 826, in _read_query_result
result.read()
File "/path/to/sqlmesh_json_table_tests/.venv/lib/python3.12/site-packages/pymysql/connections.py", line 1203, in read
first_packet = self.connection._read_packet()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/path/to/sqlmesh_json_table_tests/.venv/lib/python3.12/site-packages/pymysql/connections.py", line 782, in _read_packet
packet.raise_for_error()
File "/path/to/sqlmesh_json_table_tests/.venv/lib/python3.12/site-packages/pymysql/protocol.py", line 219, in raise_for_error
err.raise_mysql_exception(self._data)
File "/path/to/sqlmesh_json_table_tests/.venv/lib/python3.12/site-packages/pymysql/err.py", line 150, in raise_mysql_exception
raise errorclass(errno, errval)
pymysql.err.OperationalError: (1210, 'Incorrect arguments to JSON_TABLE')
The above exception was the direct cause of the following exception:
pandas.errors.DatabaseError: Execution failed on sql 'SELECT ROW_NUMBER() OVER (ORDER BY `s`.`id` ASC) AS `id`, `links`.`link` AS `url` FROM `sqlmesh_test_v02tw9ld`.`source` AS `s` /* source */, JSON_TABLE(`s`.`links`,
'$.org[*]' COLUMNS(`link` VARCHAR(255) PATH '$.link')) AS `links`': (1210, 'Incorrect arguments to JSON_TABLE')